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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations