use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class BJSONValueTest method testJSONWithExpressionKey.
@Test
public void testJSONWithExpressionKey() {
CompileResult result = BCompileUtil.compile("test-src/types/jsontype/json-literal-with-expr-key.bal");
BValue[] returns = BRunUtil.invoke(result, "testJSONWithExpressionKey");
Assert.assertTrue(returns[0] instanceof BJSON);
Assert.assertEquals(returns[0].stringValue(), "{\"a\":\"Lion\",\"key1\":\"Cat\",\"key2\":\"Dog\"}");
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class ConstrainedJSONTest method testStructConstraintInPkg.
@Test(description = "Test json imported struct constraint", enabled = false)
public void testStructConstraintInPkg() {
CompileResult compileResult = BCompileUtil.compile(this, "test-src/types/jsontype/pkg", "main");
Assert.assertEquals(compileResult.getWarnCount(), 0);
Assert.assertEquals(compileResult.getErrorCount(), 0);
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class BMapValueTest method testInvalidGrammar1.
@Test(description = "Testing map value access in variableDefStmt")
void testInvalidGrammar1() {
CompileResult compileResult = BCompileUtil.compile("test-src/types/map/map-value-validator-1-negative.bal");
Assert.assertTrue(compileResult.getDiagnostics().length == 1);
Assert.assertEquals(compileResult.getDiagnostics()[0].getMessage(), "incompatible types: expected 'string', found 'any'");
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class BMapValueTest method testInvalidGrammar2.
@Test(description = "Testing map value access in assignStmt")
void testInvalidGrammar2() {
CompileResult compileResult = BCompileUtil.compile("test-src/types/map/map-value-validator-2-negative.bal");
Assert.assertTrue(compileResult.getDiagnostics().length == 1);
Assert.assertEquals(compileResult.getDiagnostics()[0].getMessage(), "incompatible types: expected 'string', found 'any'");
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class MapAccessExprTest method testNestedMapAccess.
@Test(description = "Test nested map access")
public void testNestedMapAccess() {
CompileResult incorrectCompileResult = BCompileUtil.compile("test-src/types/map/nested-map-access.bal");
Assert.assertTrue(incorrectCompileResult.getDiagnostics().length == 1);
Assert.assertEquals(incorrectCompileResult.getDiagnostics()[0].getMessage(), "invalid operation: type 'any' does not support field access");
}
Aggregations