use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class DocumentationTest method testNestedInline.
@Test(description = "Test doc nested inline.")
public void testNestedInline() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/nested_inline.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
BLangVariable constant = (BLangVariable) packageNode.getGlobalVariables().get(0);
List<BLangDocumentation> docNodes = constant.docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.getAttributes().size(), 0);
Assert.assertEquals(dNode.documentationText, "\n" + " Example of a string template:\n" + " ``` This starts ends triple backtick ``string s = string `hello {{name}}`;`` " + "ends triple backtick```\n" + "\n" + " Example for an xml literal:\n" + " ``xml x = xml `<{{tagName}}>hello</{{tagName}}>`;``\n");
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class DocumentationTest method testDocService.
@Test(description = "Test doc service.", enabled = false)
public void testDocService() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/service.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
BLangService service = (BLangService) packageNode.getServices().get(0);
List<BLangDocumentation> docNodes = service.docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.documentationText, "PizzaService HTTP Service");
dNode = service.getResources().get(0).docAttachments.get(0);
Assert.assertEquals(dNode.getAttributes().size(), 2);
Assert.assertEquals(dNode.documentationText, "Check orderPizza resource. ");
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "conn");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " HTTP connection. ");
Assert.assertEquals(dNode.getAttributes().get(1).documentationField.getValue(), "req");
Assert.assertEquals(dNode.getAttributes().get(1).documentationText, " In request.");
dNode = service.getResources().get(1).docAttachments.get(0);
Assert.assertEquals(dNode.documentationText, "Check status resource. ");
Assert.assertEquals(dNode.getAttributes().size(), 2);
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "conn");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " HTTP connection. ");
Assert.assertEquals(dNode.getAttributes().get(1).documentationField.getValue(), "req");
Assert.assertEquals(dNode.getAttributes().get(1).documentationText, " In request.");
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class CustomFunctionTest method testDuplicateParameters.
@Test(description = "Test defining ballerina function with duplicate parameters")
public void testDuplicateParameters() {
CompileResult compile = BCompileUtil.compile("test-src/functions/duplicate-parameters.bal");
Assert.assertEquals(compile.getErrorCount(), 1);
// Checking duplicate parameter definition in a function starting at 31st column
BAssertUtil.validateError(compile, 0, "redeclared symbol 'param'", 1, 31);
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class CustomFunctionTest method testDuplicateFunction.
@Test(description = "Test defining duplicate ballerina function")
public void testDuplicateFunction() {
CompileResult compile = BCompileUtil.compile("test-src/functions/duplicate-function.bal");
Assert.assertEquals(compile.getErrorCount(), 1);
BAssertUtil.validateError(compile, 0, "redeclared symbol 'foobar'", 5, 1);
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class FunctionOverloadTest method testFunctionOverloadingSameArgCountTest.
@Test(description = "Test functino overloading which has same argument count")
public void testFunctionOverloadingSameArgCountTest() {
CompileResult compile = BCompileUtil.compile("test-src/functions/function-overloading.bal");
Assert.assertEquals(compile.getErrorCount(), 1);
BAssertUtil.validateError(compile, 0, "redeclared symbol 'testOverloading'", 5, 1);
}
Aggregations