Search in sources :

Example 1 with CompileResult

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\"}");
}
Also used : BValue(org.ballerinalang.model.values.BValue) CompileResult(org.ballerinalang.launcher.util.CompileResult) BJSON(org.ballerinalang.model.values.BJSON) Test(org.testng.annotations.Test)

Example 2 with CompileResult

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);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 3 with CompileResult

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'");
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 4 with CompileResult

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'");
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 5 with CompileResult

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");
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Aggregations

CompileResult (org.ballerinalang.launcher.util.CompileResult)291 Test (org.testng.annotations.Test)287 BValue (org.ballerinalang.model.values.BValue)60 PackageNode (org.ballerinalang.model.tree.PackageNode)16 BLangDocumentation (org.wso2.ballerinalang.compiler.tree.BLangDocumentation)14 BString (org.ballerinalang.model.values.BString)13 BInteger (org.ballerinalang.model.values.BInteger)12 Path (java.nio.file.Path)5 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)5 File (java.io.File)4 GrpcCmd (org.ballerinalang.protobuf.cmd.GrpcCmd)4 BStringArray (org.ballerinalang.model.values.BStringArray)3 BLangDeprecatedNode (org.wso2.ballerinalang.compiler.tree.BLangDeprecatedNode)3 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)3 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)3 BFloat (org.ballerinalang.model.values.BFloat)2 BIntArray (org.ballerinalang.model.values.BIntArray)2 BMap (org.ballerinalang.model.values.BMap)2 BeforeTest (org.testng.annotations.BeforeTest)2 BLangService (org.wso2.ballerinalang.compiler.tree.BLangService)2