Search in sources :

Example 16 with PackageNode

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");
}
Also used : BLangFunction(org.wso2.ballerinalang.compiler.tree.BLangFunction) BLangDocumentation(org.wso2.ballerinalang.compiler.tree.BLangDocumentation) CompileResult(org.ballerinalang.launcher.util.CompileResult) PackageNode(org.ballerinalang.model.tree.PackageNode) Test(org.testng.annotations.Test)

Aggregations

CompileResult (org.ballerinalang.launcher.util.CompileResult)16 PackageNode (org.ballerinalang.model.tree.PackageNode)16 Test (org.testng.annotations.Test)16 BLangDocumentation (org.wso2.ballerinalang.compiler.tree.BLangDocumentation)14 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)5 BLangDeprecatedNode (org.wso2.ballerinalang.compiler.tree.BLangDeprecatedNode)3 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)3 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)3 BLangService (org.wso2.ballerinalang.compiler.tree.BLangService)2 BLangTransformer (org.wso2.ballerinalang.compiler.tree.BLangTransformer)2 BLangConnector (org.wso2.ballerinalang.compiler.tree.BLangConnector)1 BLangEnum (org.wso2.ballerinalang.compiler.tree.BLangEnum)1