Search in sources :

Example 6 with CompileResult

use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.

the class MapInitializerExprTest method testMapInitWithPackageVars.

@Test(enabled = false)
public void testMapInitWithPackageVars() {
    CompileResult result = BCompileUtil.compile(this, "test-src/types/map/", "a.b");
    BValue[] returns = BRunUtil.invoke(result, "testMapInitWithPackageVars");
    Assert.assertEquals(returns.length, 1);
    Assert.assertSame(returns[0].getClass(), BMap.class);
    BMap<String, ?> mapValue = (BMap<String, BString>) returns[0];
    Assert.assertEquals(mapValue.size(), 2);
    Assert.assertEquals(mapValue.get("name").stringValue(), "PI");
    Assert.assertEquals(((BFloat) mapValue.get("value")).floatValue(), 3.14159);
}
Also used : BMap(org.ballerinalang.model.values.BMap) BValue(org.ballerinalang.model.values.BValue) CompileResult(org.ballerinalang.launcher.util.CompileResult) BString(org.ballerinalang.model.values.BString) BeforeTest(org.testng.annotations.BeforeTest) Test(org.testng.annotations.Test)

Example 7 with CompileResult

use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.

the class VarDeclaredAssignmentStmtTest method testVarDeclarationWithDuplicateVariableRefs.

@Test
public void testVarDeclarationWithDuplicateVariableRefs() {
    CompileResult res = BCompileUtil.compile("test-src/types/var/var-duplicate-variable-ref-lhs-negative.bal");
    Assert.assertEquals(res.getErrorCount(), 1);
    BAssertUtil.validateError(res, 0, "redeclared symbol 'age'", 2, 15);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 8 with CompileResult

use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.

the class VarDeclaredAssignmentStmtTest method testVarDeclarationWithAllDeclaredSymbols.

@Test
public void testVarDeclarationWithAllDeclaredSymbols() {
    CompileResult res = BCompileUtil.compile("test-src/types/var/var-declared-symbols-negative.bal");
    Assert.assertEquals(res.getErrorCount(), 1);
    BAssertUtil.validateError(res, 0, "no new variables on left side", 4, 5);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 9 with CompileResult

use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.

the class VarDeclaredAssignmentStmtTest method testVarTypeInServiceLevelVariableDefStatement.

@Test
public void testVarTypeInServiceLevelVariableDefStatement() {
    // var type is not not allowed in service level variable def statements
    CompileResult res = BCompileUtil.compile("test-src/types/var/service-level-variable-def-with-var-negative.bal");
    BAssertUtil.validateError(res, 0, "extraneous input 'var'", 9, 5);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 10 with CompileResult

use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.

the class XMLLiteralTest method testCombinedExpressionsAsElementName.

@Test
public void testCombinedExpressionsAsElementName() {
    CompileResult negativeResult = BCompileUtil.compile("test-src/types/xml/xml-invalid-syntax-1.bal");
    Assert.assertEquals(negativeResult.getErrorCount(), 1);
    BAssertUtil.validateError(negativeResult, 0, "invalid token '{{'", 3, 24);
}
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