Search in sources :

Example 71 with CompileResult

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

the class FunctionSignatureNegativeTest method testFuncWithTwoRestParams.

@Test
public void testFuncWithTwoRestParams() {
    CompileResult result = BCompileUtil.compile("test-src/functions/function-with-two-rest-params.bal");
    BAssertUtil.validateError(result, 0, "mismatched input ','. expecting ')'", 1, 52);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 72 with CompileResult

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

the class LaunchTest method testRunPackageWithFileSeparater.

// @Test
// public void testRunEmptyPackage() {
// CompileResult result = BCompileUtil.compile(this, "test-src/launch/", "foo");
// Assert.assertEquals(result.getErrorCount(), 0);
// Assert.assertNull(result.getProgFile());
// }
@Test
public void testRunPackageWithFileSeparater() {
    CompileResult compileResult = BCompileUtil.compile(this, "test-src/launch/", "foo.bar");
    Assert.assertEquals(compileResult.getErrorCount(), 0);
    BValue[] result = BRunUtil.invoke(compileResult, "foo");
    Assert.assertEquals(result[0].stringValue(), "hello!");
}
Also used : BValue(org.ballerinalang.model.values.BValue) CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 73 with CompileResult

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

the class LaunchTest method testRunNonExistingPackage.

@Test(expectedExceptions = { BLangCompilerException.class }, expectedExceptionsMessageRegExp = "cannot find package 'xxxx'")
public void testRunNonExistingPackage() {
    CompileResult result = BCompileUtil.compile(this, "test-src/launch/", "xxxx");
    Assert.assertEquals(result.getErrorCount(), 0);
    Assert.assertNull(result.getProgFile());
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 74 with CompileResult

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

the class LocksInMainTest method testThrowErrorInsideTryCatchFinallyInsideLock.

@Test(description = "Tests throwing an error inside try catch finally block inside a lock")
public void testThrowErrorInsideTryCatchFinallyInsideLock() {
    CompileResult compileResult = BCompileUtil.compile("test-src/lock/locks-in-functions.bal");
    BValue[] returns = BRunUtil.invoke(compileResult, "throwErrorInsideTryCatchFinallyInsideLock");
    assertEquals(returns.length, 2);
    assertSame(returns[0].getClass(), BInteger.class);
    assertSame(returns[1].getClass(), BString.class);
    assertEquals(((BInteger) returns[0]).intValue(), 53);
    assertEquals(returns[1].stringValue(), "worker 2 sets the string after try catch finally inside lock");
}
Also used : BValue(org.ballerinalang.model.values.BValue) CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 75 with CompileResult

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

the class LocksInMainTest method testLockWithinLockInWorkersForBlobAndBoolean.

@Test(description = "Tests lock within lock in workers for boolean and blob")
public void testLockWithinLockInWorkersForBlobAndBoolean() {
    CompileResult compileResult = BCompileUtil.compile("test-src/lock/locks-in-functions.bal");
    BValue[] returns = BRunUtil.invoke(compileResult, "lockWithinLockInWorkersForBlobAndBoolean");
    assertEquals(returns.length, 2);
    assertSame(returns[0].getClass(), BBoolean.class);
    assertSame(returns[1].getClass(), BBlob.class);
    assertEquals(((BBoolean) returns[0]).booleanValue(), true);
    assertEquals(returns[1].stringValue(), "sample blob output");
}
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