Search in sources :

Example 76 with CompileResult

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

Example 77 with CompileResult

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

Example 78 with CompileResult

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

Example 79 with CompileResult

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

Example 80 with CompileResult

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");
}
Also used : BValue(org.ballerinalang.model.values.BValue) 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