use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class TypeCastExprTest method testIncompatibleStructToStructCast.
@Test
public void testIncompatibleStructToStructCast() {
CompileResult res = BCompileUtil.compile("test-src/expressions/typecast/incompatible-struct-cast-negative.bal");
Assert.assertEquals(res.getErrorCount(), 1);
BAssertUtil.validateError(res, 0, "incompatible types: expected 'Person', found 'Student'", 24, 16);
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class TypeCastExprTest method testCastingWithTooManyReturns.
@Test(description = "Test casting with too many returns")
public void testCastingWithTooManyReturns() {
CompileResult res = BCompileUtil.compile("test-src/expressions/typecast/cast-too-many-returns-negative.bal");
Assert.assertEquals(res.getErrorCount(), 1);
BAssertUtil.validateError(res, 0, "invalid token '=?'", 15, 15);
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class IdentifierLiteralPackageTest method testAccessingVarsInOtherPackage.
@Test(description = "Test accessing variable in other packages defined with identifier literal")
public void testAccessingVarsInOtherPackage() {
CompileResult result = BCompileUtil.compile(this, "test-src/expressions/identifierliteral", "pkg.main");
BValue[] returns = BRunUtil.invoke(result, "pkg.main", "getVarsInOtherPkg");
Assert.assertEquals(returns.length, 4);
Assert.assertSame(returns[0].getClass(), BInteger.class);
Assert.assertSame(returns[1].getClass(), BString.class);
Assert.assertSame(returns[2].getClass(), BFloat.class);
Assert.assertSame(returns[3].getClass(), BInteger.class);
Assert.assertEquals(((BInteger) returns[0]).intValue(), 800);
Assert.assertEquals(((BString) returns[1]).stringValue(), "value");
Assert.assertEquals(((BFloat) returns[2]).floatValue(), 99.34323);
Assert.assertEquals(((BInteger) returns[3]).intValue(), 88343);
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class BuiltinLoadingTest method testRedeclaredSymbols.
@Test
public void testRedeclaredSymbols() {
CompileResult result = BCompileUtil.compile("test-src/natives/builtin-symbol-negative.bal");
BAssertUtil.validateError(result, 0, "redeclared builtin symbol 'error'", 5, 1);
BAssertUtil.validateError(result, 1, "function 'getMessage' defined on non-local type 'error'", 13, 11);
BAssertUtil.validateError(result, 2, "redeclared builtin symbol 'error'", 10, 5);
BAssertUtil.validateError(result, 3, "break cannot be used outside of a loop", 2, 5);
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class DocumentationTest method testDocConstant.
@Test(description = "Test doc constant.")
public void testDocConstant() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/constant.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
List<BLangDocumentation> docNodes = ((BLangVariable) packageNode.getGlobalVariables().get(0)).docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.documentationText, " Documentation for testConst constant\n");
Assert.assertEquals(dNode.getAttributes().size(), 1);
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "testConst");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " constant variable `testConst`");
}
Aggregations