Search in sources :

Example 96 with CompileResult

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

the class InvalidSyntaxParserTest method testParseIdentifierMissingSerivce.

/**
 * Test invalid identifier. i.e: {@link org.antlr.v4.runtime.NoViableAltException}
 */
@Test
public void testParseIdentifierMissingSerivce() {
    CompileResult result = BCompileUtil.compile("test-src/parser/identifier-missing-service-negative.bal");
    BAssertUtil.validateError(result, 0, "invalid token ';'", 10, 10);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 97 with CompileResult

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

the class ForeachNegativeTests method testSemanticErrors.

@Test
public void testSemanticErrors() {
    CompileResult compile = BCompileUtil.compile("test-src/statements/foreach/foreach-negative.bal");
    Assert.assertEquals(compile.getErrorCount(), 12);
    BAssertUtil.validateError(compile, 0, "too many variables are defined for iterable type 'string[]'", 4, 24);
    BAssertUtil.validateError(compile, 1, "redeclared symbol 'i'", 13, 13);
    BAssertUtil.validateError(compile, 2, "redeclared symbol 's'", 13, 16);
    BAssertUtil.validateError(compile, 3, "undefined symbol 'i'", 23, 16);
    BAssertUtil.validateError(compile, 4, "incompatible types: 'string' is not an iterable collection", 28, 18);
    BAssertUtil.validateError(compile, 5, "invalid assignment in variable 'p.id'", 41, 13);
    BAssertUtil.validateError(compile, 6, "too many variables are defined for iterable type 'string[]'", 49, 24);
    BAssertUtil.validateError(compile, 7, "incompatible types: expected 'int', found 'string'", 55, 20);
    BAssertUtil.validateError(compile, 8, "incompatible types: expected 'int', found 'string'", 55, 25);
    BAssertUtil.validateError(compile, 9, "unreachable code", 74, 9);
    BAssertUtil.validateError(compile, 10, "unreachable code", 79, 9);
    BAssertUtil.validateError(compile, 11, "next cannot be used outside of a loop", 81, 5);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 98 with CompileResult

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

the class MatchStatementTest method testMatchStmtNegative1.

@Test(description = "Test basics of match statement")
public void testMatchStmtNegative1() {
    CompileResult compile = BCompileUtil.compile("test-src/statements/matchstmt/match_stmt_negative.bal");
    Assert.assertEquals(compile.getErrorCount(), 4);
    BAssertUtil.validateError(compile, 0, "A matching pattern cannot be guaranteed for types '[boolean]'", 9, 31);
    BAssertUtil.validateError(compile, 1, "this function must return a result", 5, 1);
    BAssertUtil.validateError(compile, 2, "unreachable pattern: preceding patterns are " + "too general or the pattern ordering is not correct", 21, 9);
    BAssertUtil.validateError(compile, 3, "pattern will not be matched", 18, 9);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 99 with CompileResult

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

the class PackageImportTest method testDuplicatePackageImports.

@Test
public void testDuplicatePackageImports() {
    CompileResult result = BCompileUtil.compile("test-src/statements/package/imports/duplicate-import-negative.bal");
    Assert.assertTrue(result.getDiagnostics().length > 0);
    BAssertUtil.validateWarning(result, 0, "redeclared import package 'ballerina.math'", 4, 1);
}
Also used : CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Example 100 with CompileResult

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

the class PackageImportTest method testExtraneousPackageDeclr.

@Test(enabled = false)
public void testExtraneousPackageDeclr() {
    CompileResult result = BCompileUtil.compile("test-src/statements/package/extraneous-package-declr-negative.bal");
    Assert.assertTrue(result.getDiagnostics().length > 0);
    BAssertUtil.validateError(result, 0, "invalid package declaration 'x.y.z': no package declaration is needed " + "for default package", 1, 1);
}
Also used : 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