use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class GlobalVarFunctionTest method testChangeGlobalVarWithinFunction.
@Test(description = "Test change global var within functions")
public void testChangeGlobalVarWithinFunction() {
BValue[] args = { new BInteger(88) };
BValue[] returns = BRunUtil.invoke(result, "changeGlobalVar", args);
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BFloat.class);
Assert.assertEquals(((BFloat) returns[0]).floatValue(), 165.0);
CompileResult resultGlobalVar = BCompileUtil.compile("test-src/statements/variabledef/global-var-function.bal");
BValue[] returnsChanged = BRunUtil.invoke(resultGlobalVar, "getGlobalFloatVar");
Assert.assertEquals(returnsChanged.length, 1);
Assert.assertSame(returnsChanged[0].getClass(), BFloat.class);
Assert.assertEquals(((BFloat) returnsChanged[0]).floatValue(), 80.0);
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class StructEquivalencyNegativeTest method testEquivalenceOfStructsInSamePackage.
@Test(description = "Test equivalence of structs that are in the same package", enabled = false)
public void testEquivalenceOfStructsInSamePackage() {
CompileResult compileResult = BCompileUtil.compile("test-src/structs/struct-equivalency-01-negative.bal");
BAssertUtil.validateError(compileResult, 0, "unsafe cast from 'employee01' to 'person01', use multi-return cast expression", 17, 18);
BAssertUtil.validateError(compileResult, 1, "unsafe cast from 'employee02' to 'person02', use multi-return cast expression", 36, 18);
BAssertUtil.validateError(compileResult, 2, "unsafe cast from 'employee03' to 'person03', use multi-return cast expression", 54, 18);
BAssertUtil.validateError(compileResult, 3, "unsafe cast from 'employee04' to 'person04', use multi-return cast expression", 76, 18);
BAssertUtil.validateError(compileResult, 4, "unsafe cast from 'employee05' to 'person05', use multi-return cast expression", 100, 18);
BAssertUtil.validateError(compileResult, 5, "unsafe cast from 'employee06' to 'person06', use multi-return cast expression", 122, 18);
BAssertUtil.validateError(compileResult, 6, "unsafe cast from 'employee07' to 'person07', use multi-return cast expression", 166, 18);
BAssertUtil.validateError(compileResult, 7, "unsafe cast from 'employee08' to 'person08', use multi-return cast expression", 214, 18);
BAssertUtil.validateError(compileResult, 8, "unsafe cast from 'employee09' to 'person09', use multi-return cast expression", 262, 18);
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class StructEquivalencyNegativeTest method testEquivalenceOfStructsInSamePackageFromDifferentPackage.
@Test(description = "Test equivalence of structs that are in the same package from a third package", enabled = false)
public void testEquivalenceOfStructsInSamePackageFromDifferentPackage() {
CompileResult compileResult = BCompileUtil.compile("test-src/structs/struct-equivalency-02-negative.bal");
BAssertUtil.validateError(compileResult, 0, "unsafe cast from 'org.foo.bar:userBar' to 'org.foo:userFoo', " + "use multi-return cast expression", 11, 23);
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class StructInitializerTest method testInvalidStructLiteralKey.
@Test(description = "Test negative structs initializers scenarios")
public void testInvalidStructLiteralKey() {
CompileResult result = BCompileUtil.compile(this, "test-src/structs", "init.negative");
Assert.assertEquals(2, result.getErrorCount());
BAssertUtil.validateError(result, 0, "explicit invocation of 'init.negative:person' struct initializer is not allowed", 24, 5);
BAssertUtil.validateError(result, 1, "attempt to create a struct with a non-public initializer ", 28, 21);
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class StructNegativeTest method testGetNonInitField.
@Test(description = "Test accessing an field of a noninitialized struct", expectedExceptions = { BLangRuntimeException.class }, expectedExceptionsMessageRegExp = ".*error:.*array index out of range.*")
public void testGetNonInitField() {
CompileResult compileResult = BCompileUtil.compile("test-src/structs/struct.bal");
Assert.assertEquals(compileResult.getWarnCount(), 0);
Assert.assertEquals(compileResult.getErrorCount(), 0);
BRunUtil.invoke(compileResult, "testGetNonInitAttribute");
}
Aggregations