use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class LocksInMainTest method testLockPkgVarsWithinLockInWorkers.
@Test(description = "Tests locking variables from different package within lock in workers")
public void testLockPkgVarsWithinLockInWorkers() {
CompileResult compileResult = BCompileUtil.compile(this, "test-src/lock", "pkg.bc");
BValue[] returns = BRunUtil.invoke(compileResult, "lockWithinLockInWorkers");
assertEquals(returns.length, 2);
assertSame(returns[0].getClass(), BInteger.class);
assertSame(returns[1].getClass(), BString.class);
assertEquals(((BInteger) returns[0]).intValue(), 66);
assertEquals(returns[1].stringValue(), "sample output from package");
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class LocksInMainTest method testThrowErrorInsideTryFinallyInsideLock.
@Test(description = "Tests throwing an error inside try finally block inside a lock")
public void testThrowErrorInsideTryFinallyInsideLock() {
CompileResult compileResult = BCompileUtil.compile("test-src/lock/locks-in-functions.bal");
BValue[] returns = BRunUtil.invoke(compileResult, "throwErrorInsideTryFinallyInsideLock");
assertEquals(returns.length, 2);
assertSame(returns[0].getClass(), BInteger.class);
assertSame(returns[1].getClass(), BString.class);
assertEquals(((BInteger) returns[0]).intValue(), 52);
assertEquals(returns[1].stringValue(), "worker 2 sets the string after try finally");
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class FunctionPointersNegativeTest method testAnyToFunctionPointer.
@Test(expectedExceptions = SemanticException.class, enabled = false)
public void testAnyToFunctionPointer() {
// TODO : Fix this. This is not supported in 0.94 release. issue #2944
CompileResult result = BCompileUtil.compile("test-src/expressions/lambda/negative/fp2any-negative.bal");
BValue[] args = new BValue[0];
BValue[] returns = BRunUtil.invoke(result, "test1", args);
Assert.assertNotNull(returns);
Assert.assertEquals(returns.length, 1);
Assert.assertNotNull(returns[0]);
Assert.assertEquals(returns[0].stringValue(), "test1");
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class FunctionPointersNegativeTest method testFPInStruct.
@Test()
public void testFPInStruct() {
CompileResult result = BCompileUtil.compile("test-src/expressions/lambda/negative/fp-struct-negative.bal");
Assert.assertEquals(result.getErrorCount(), 1);
BAssertUtil.validateError(result, 0, "undefined function 'getFullName' in struct 'Person'", 17, 16);
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class FunctionPointersTest method testFunctionPointerNative.
@Test()
public void testFunctionPointerNative() {
CompileResult result = BCompileUtil.compile("test-src/expressions/lambda/function-pointer-native.bal");
BValue[] returns = BRunUtil.invoke(result, "test1");
Assert.assertNotNull(returns);
Assert.assertEquals(returns.length, 1);
Assert.assertNotNull(returns[0]);
Assert.assertEquals(returns[0].stringValue(), "1500526800000");
}
Aggregations