Search in sources :

Example 51 with CompileResult

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

the class StructNegativeTest method testGetNonInitLastField.

@Test(description = "Test accessing the field of a noninitialized struct", expectedExceptions = { BLangRuntimeException.class }, expectedExceptionsMessageRegExp = ".*error:.*array index out of range.*")
public void testGetNonInitLastField() {
    CompileResult compileResult = BCompileUtil.compile("test-src/structs/struct.bal");
    Assert.assertEquals(compileResult.getWarnCount(), 0);
    Assert.assertEquals(compileResult.getErrorCount(), 0);
    BRunUtil.invoke(compileResult, "testGetNonInitLastAttribute");
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 52 with CompileResult

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

the class StructNegativeTest method testSetNonInitField.

@Test(description = "Test setting an field of a noninitialized child struct")
public void testSetNonInitField() {
    CompileResult compileResult = BCompileUtil.compile("test-src/structs/struct.bal");
    Assert.assertEquals(compileResult.getWarnCount(), 0);
    Assert.assertEquals(compileResult.getErrorCount(), 0);
    BRunUtil.invoke(compileResult, "testSetFieldOfNonInitChildStruct");
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 53 with CompileResult

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

the class StructNegativeTest method testGetNonInitArrayField.

@Test(description = "Test accessing an arrays field of a noninitialized struct", expectedExceptions = { BLangRuntimeException.class }, expectedExceptionsMessageRegExp = ".*error:.*array index out of range.*")
public void testGetNonInitArrayField() {
    CompileResult compileResult = BCompileUtil.compile("test-src/structs/struct.bal");
    Assert.assertEquals(compileResult.getWarnCount(), 0);
    Assert.assertEquals(compileResult.getErrorCount(), 0);
    BRunUtil.invoke(compileResult, "testGetNonInitArrayAttribute");
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 54 with CompileResult

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

the class StructNegativeTest method testSetNonInitLastField.

@Test(description = "Test setting the field of a noninitialized root struct")
public void testSetNonInitLastField() {
    CompileResult compileResult = BCompileUtil.compile("test-src/structs/struct.bal");
    Assert.assertEquals(compileResult.getWarnCount(), 0);
    Assert.assertEquals(compileResult.getErrorCount(), 0);
    BRunUtil.invoke(compileResult, "testSetFieldOfNonInitStruct");
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 55 with CompileResult

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

the class TypeCastExprTest method testCastToStructInDifferentPkg.

@Test(description = "Test casting a struct to another struct in a different package", enabled = false)
public void testCastToStructInDifferentPkg() {
    CompileResult res = BCompileUtil.compile(this, "test-src", "expressions.typecast.foo");
    BValue[] returns = BRunUtil.invoke(res, "testCastToStructInDifferentPkg");
}
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