use of org.ballerinalang.model.tree.PackageNode in project ballerina by ballerina-lang.
the class DocumentationTest method testDocNativeFunction.
@Test(description = "Test doc native function.")
public void testDocNativeFunction() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/native_function.bal", CompilerPhase.TYPE_CHECK);
Assert.assertEquals(1, compileResult.getWarnCount());
BAssertUtil.validateWarning(compileResult, 0, "no such documentable attribute 'successful' with doc prefix 'P'", 6, 1);
PackageNode packageNode = compileResult.getAST();
List<BLangDocumentation> docNodes = ((BLangFunction) packageNode.getFunctions().get(0)).docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.documentationText, "\n" + "Gets a access parameter value (`true` or `false`) for a given key. " + "Please note that #foo will always be bigger than #bar.\n" + "Example:\n" + "``SymbolEnv pkgEnv = symbolEnter.packageEnvs.get(pkgNode.symbol);``\n");
Assert.assertEquals(dNode.getAttributes().size(), 2);
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "accessMode");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " read or write mode\n");
Assert.assertEquals(dNode.getAttributes().get(1).documentationField.getValue(), "successful");
Assert.assertEquals(dNode.getAttributes().get(1).documentationText, " boolean `true` or `false`\n");
}
Aggregations