From 32c9c1a8b6c7133da0fde734e8701d3f3e82c2b1 Mon Sep 17 00:00:00 2001 From: shan1024 Date: Wed, 18 Oct 2017 17:17:22 +0530 Subject: [PATCH] Update tests --- .../BallerinaCompletionTestBase.java | 7 ++-- .../BallerinaConstantCompletionTest.java | 13 +++---- .../BallerinaFileLevelCompletionTest.java | 38 +++++++++++-------- ...BallerinaGlobalVariableCompletionTest.java | 6 +-- ...BallerinaHiddenTemplateCompletionTest.java | 9 ++--- .../BallerinaParameterCompletionTest.java | 8 ++-- 6 files changed, 39 insertions(+), 42 deletions(-) diff --git a/src/test/java/org/ballerinalang/completion/BallerinaCompletionTestBase.java b/src/test/java/org/ballerinalang/completion/BallerinaCompletionTestBase.java index 37394680..8511098c 100644 --- a/src/test/java/org/ballerinalang/completion/BallerinaCompletionTestBase.java +++ b/src/test/java/org/ballerinalang/completion/BallerinaCompletionTestBase.java @@ -28,17 +28,16 @@ public abstract class BallerinaCompletionTestBase extends BallerinaCodeInsightFixtureTestCase { - static final List FILE_LEVEL_KEYWORDS = Arrays.asList("package", "import", "const", "service", - "function", "connector", "struct", "typemapper", "annotation"); + static final List FILE_LEVEL_KEYWORDS = Arrays.asList("public", "package", "import", "const", + "service", "function", "connector", "struct", "typemapper", "annotation", "enum"); static final List DATA_TYPES = Arrays.asList("boolean", "int", "float", "string", "blob"); static final List REFERENCE_TYPES = Arrays.asList("message", "map", "xml", "json", "datatable"); static final List XMLNS_TYPE = Collections.singletonList("xmlns"); static final List OTHER_TYPES = Arrays.asList("any", "type", "var"); static final List COMMON_KEYWORDS = Arrays.asList("if", "else", "fork", "join", "timeout", "worker", "transform", "transaction", "failed", "aborted", "committed", "abort", "try", "catch", "finally", - "iterate", "while", "continue", "break", "throw"); + "iterate", "while", "next", "break", "throw"); static final List VALUE_KEYWORDS = Arrays.asList("true", "false", "null"); - static final List FUNCTION_LEVEL_KEYWORDS = Collections.singletonList("return"); void doTestFile(String... expectedLookups) { diff --git a/src/test/java/org/ballerinalang/completion/BallerinaConstantCompletionTest.java b/src/test/java/org/ballerinalang/completion/BallerinaConstantCompletionTest.java index 977d4e98..2652fc07 100644 --- a/src/test/java/org/ballerinalang/completion/BallerinaConstantCompletionTest.java +++ b/src/test/java/org/ballerinalang/completion/BallerinaConstantCompletionTest.java @@ -51,18 +51,18 @@ public void testConstantAnnotationWithImportsNoAnnotationDefinitions() { } public void testConstantAnnotationWithImportsWithNoMatchingAnnotationDefinitions() { - myFixture.addFileToProject("org/test/file.bal", "annotation TEST attach service {}"); + myFixture.addFileToProject("org/test/file.bal", "public annotation TEST attach service {}"); doCheckResult("test.bal", "import org.test; @test: const string S=\"\";", null, null); } public void testConstantAnnotationWithImportsWithMatchingAnnotationDefinitions() { - myFixture.addFileToProject("org/test/file.bal", "package org.test; annotation TEST attach const {} " + + myFixture.addFileToProject("org/test/file.bal", "package org.test; public annotation TEST attach const {} " + "annotation TEST2 attach resource {}"); doCheckResult("test.bal", "import org.test; @test: const string S=\"\";", null, null, "TEST"); } public void testConstantAnnotationWithImportsWithMatchingAnnotationDefinitionsAutoCompletion() { - myFixture.addFileToProject("org/test/file.bal", "package org.test; annotation TEST attach const {}"); + myFixture.addFileToProject("org/test/file.bal", "package org.test; public annotation TEST attach const {}"); doCheckResult("test.bal", "import org.test; @test:T const string S=\"\";", "import org.test; @test:TEST {} const string S=\"\";", null); } @@ -108,12 +108,10 @@ public void testConstantInSamePackageSameFile() { expectedLookups.addAll(XMLNS_TYPE); expectedLookups.addAll(REFERENCE_TYPES); expectedLookups.addAll(COMMON_KEYWORDS); - expectedLookups.addAll(VALUE_KEYWORDS); expectedLookups.addAll(FUNCTION_LEVEL_KEYWORDS); expectedLookups.add("S"); expectedLookups.add("F"); - doTest("const string S=\"\"; function F(){ }", - expectedLookups.toArray(new String[expectedLookups.size()])); + doTest("string S=\"\"; function F(){ }", expectedLookups.toArray(new String[expectedLookups.size()])); } public void testConstantInSamePackageDifferentFile() { @@ -124,7 +122,6 @@ public void testConstantInSamePackageDifferentFile() { expectedLookups.addAll(XMLNS_TYPE); expectedLookups.addAll(REFERENCE_TYPES); expectedLookups.addAll(COMMON_KEYWORDS); - expectedLookups.addAll(VALUE_KEYWORDS); expectedLookups.addAll(FUNCTION_LEVEL_KEYWORDS); expectedLookups.add("S"); expectedLookups.add("F"); @@ -132,7 +129,7 @@ public void testConstantInSamePackageDifferentFile() { } public void testConstantInDifferentPackage() { - myFixture.addFileToProject("org/test/file.bal", "const string S=\"\";"); + myFixture.addFileToProject("org/test/file.bal", "public const string S=\"\";"); doTest("import org.test; function F(){ test: }", "S"); } diff --git a/src/test/java/org/ballerinalang/completion/BallerinaFileLevelCompletionTest.java b/src/test/java/org/ballerinalang/completion/BallerinaFileLevelCompletionTest.java index f195cf4e..183219f6 100644 --- a/src/test/java/org/ballerinalang/completion/BallerinaFileLevelCompletionTest.java +++ b/src/test/java/org/ballerinalang/completion/BallerinaFileLevelCompletionTest.java @@ -35,11 +35,11 @@ public void testEmptyFile() { } public void testEmptyFilePackageKeyword() { - doTest("p", "import", "package", "typemapper", "map", "type"); + doTest("p", "public", "import", "package", "typemapper", "map", "type"); } public void testEmptyFileImportKeyword() { - doTest("i", "annotation", "function", "import", "service", "int", "string"); + doTest("i", "public", "annotation", "function", "import", "service", "int", "string"); } public void testEmptyFileWithSpaceBeforeCaret() { @@ -53,11 +53,11 @@ public void testEmptyFileWithSpaceBeforeCaret() { } public void testEmptyFileWithSpaceBeforeCaretPackageKeyword() { - doTest("\np", "import", "package", "typemapper", "map", "type"); + doTest("\np", "public", "import", "package", "typemapper", "map", "type"); } public void testEmptyFileWithSpaceBeforeCaretImportKeyword() { - doTest("\ni", "annotation", "function", "import", "service", "int", "string"); + doTest("\ni", "public", "annotation", "function", "import", "service", "int", "string"); } public void testEmptyFileWithSpaceAfterCaret() { @@ -71,11 +71,11 @@ public void testEmptyFileWithSpaceAfterCaret() { } public void testEmptyFileWithSpaceAfterCaretPackageKeyword() { - doTest("p\n", "import", "package", "typemapper", "map", "type"); + doTest("p\n", "public", "import", "package", "typemapper", "map", "type"); } public void testEmptyFileWithSpaceAfterCaretImportKeyword() { - doTest("i\n", "annotation", "function", "import", "service", "int", "string"); + doTest("i\n", "public", "annotation", "function", "import", "service", "int", "string"); } public void testEmptyFileWithSpaces() { @@ -89,11 +89,11 @@ public void testEmptyFileWithSpaces() { } public void testEmptyFileWithSpacesPackageKeyword() { - doTest("\np\n", "import", "package", "typemapper", "map", "type"); + doTest("\np\n", "public", "import", "package", "typemapper", "map", "type"); } public void testEmptyFileWithSpacesImportKeyword() { - doTest("\ni\n", "annotation", "function", "import", "service", "int", "string"); + doTest("\ni\n", "public", "annotation", "function", "import", "service", "int", "string"); } public void testImportAfterPackage() { @@ -102,6 +102,7 @@ public void testImportAfterPackage() { expectedLookups.addAll(XMLNS_TYPE); expectedLookups.addAll(DATA_TYPES); expectedLookups.addAll(REFERENCE_TYPES); + expectedLookups.add("public"); expectedLookups.add("import"); expectedLookups.add("const"); expectedLookups.add("service"); @@ -110,11 +111,12 @@ public void testImportAfterPackage() { expectedLookups.add("struct"); expectedLookups.add("typemapper"); expectedLookups.add("annotation"); + expectedLookups.add("enum"); doTest("package test; \n\n", expectedLookups.toArray(new String[expectedLookups.size()])); } public void testImportAfterPackagePartialIdentifier() { - doTest("package test; \ni\n", "annotation", "function", "import", "service", "int", "string"); + doTest("package test; \ni\n", "public", "annotation", "function", "import", "service", "int", "string"); } public void testImportAfterPackageBeforeFunction() { @@ -123,6 +125,7 @@ public void testImportAfterPackageBeforeFunction() { expectedLookups.addAll(XMLNS_TYPE); expectedLookups.addAll(DATA_TYPES); expectedLookups.addAll(REFERENCE_TYPES); + expectedLookups.add("public"); expectedLookups.add("import"); expectedLookups.add("const"); expectedLookups.add("service"); @@ -131,12 +134,13 @@ public void testImportAfterPackageBeforeFunction() { expectedLookups.add("struct"); expectedLookups.add("typemapper"); expectedLookups.add("annotation"); + expectedLookups.add("enum"); doTest("package test; \n\nfunction A(){}", expectedLookups.toArray(new String[expectedLookups.size()])); } public void testImportAfterPackageBeforeFunctionPartialIdentifier() { - doTest("package test; \ni\nfunction A(){}", "annotation", "function", "import", "service", "int", - "string"); + doTest("package test; \ni\nfunction A(){}", "public", "annotation", "function", "import", "service", + "int", "string"); } public void testPackageBeforeImport() { @@ -150,7 +154,7 @@ public void testPackageBeforeImport() { } public void testPackageBeforeImportPartialIdentifier() { - doTest("p\nimport test; \nfunction A(){}", "import", "package", "typemapper", "map", "type"); + doTest("p\nimport test; \nfunction A(){}", "public", "import", "package", "typemapper", "map", "type"); } public void testImportBeforeImport() { @@ -164,8 +168,8 @@ public void testImportBeforeImport() { } public void testImportBeforeImportPartialIdentifier() { - doTest("i\nimport test; \nfunction A(){}", "annotation", "function", "import", "service", "int", - "string"); + doTest("i\nimport test; \nfunction A(){}", "public", "annotation", "function", "import", "service", + "int", "string"); } public void testImportAfterImport() { @@ -174,6 +178,7 @@ public void testImportAfterImport() { expectedLookups.addAll(XMLNS_TYPE); expectedLookups.addAll(DATA_TYPES); expectedLookups.addAll(REFERENCE_TYPES); + expectedLookups.add("public"); expectedLookups.add("import"); expectedLookups.add("const"); expectedLookups.add("service"); @@ -182,13 +187,14 @@ public void testImportAfterImport() { expectedLookups.add("struct"); expectedLookups.add("typemapper"); expectedLookups.add("annotation"); + expectedLookups.add("enum"); expectedLookups.add("test"); myFixture.addFileToProject("test/file.bal", "string s = \"\";"); doTest("import test; \n \nfunction A(){}", expectedLookups.toArray(new String[expectedLookups.size()])); } public void testImportAfterImportPartialIdentifier() { - doTest("import test; \ni \nfunction A(){}", "annotation", "function", "import", "service", "int", - "string"); + doTest("import test; \ni \nfunction A(){}", "public", "annotation", "function", "import", "service", + "int", "string"); } } diff --git a/src/test/java/org/ballerinalang/completion/BallerinaGlobalVariableCompletionTest.java b/src/test/java/org/ballerinalang/completion/BallerinaGlobalVariableCompletionTest.java index 44e76f0c..748bfb5b 100644 --- a/src/test/java/org/ballerinalang/completion/BallerinaGlobalVariableCompletionTest.java +++ b/src/test/java/org/ballerinalang/completion/BallerinaGlobalVariableCompletionTest.java @@ -45,12 +45,12 @@ public void testGlobalVariablePackageValueCompletion() { } public void testGlobalVariablePackageValueDifferentPackage() { - myFixture.addFileToProject("org/test/file.bal", "function getValue()(string){return \"\";}"); + myFixture.addFileToProject("org/test/file.bal", "public function getValue()(string){return \"\";}"); doTest("import org.test; string s = test: ", "getValue"); } public void testGlobalVariablePackageValueCompletionDifferentPackage() { - myFixture.addFileToProject("org/test/file.bal", "function getValue()(string){return \"\";}"); + myFixture.addFileToProject("org/test/file.bal", "public function getValue()(string){return \"\";}"); doCheckResult("test.bal", "import org.test; string s = test:g ", "import org.test; string s = test:getValue() ", null); } @@ -72,7 +72,6 @@ public void testGlobalVariableInSamePackageSameFile() { expectedLookups.addAll(XMLNS_TYPE); expectedLookups.addAll(REFERENCE_TYPES); expectedLookups.addAll(COMMON_KEYWORDS); - expectedLookups.addAll(VALUE_KEYWORDS); expectedLookups.addAll(FUNCTION_LEVEL_KEYWORDS); expectedLookups.add("S"); expectedLookups.add("F"); @@ -87,7 +86,6 @@ public void testGlobalVariableInSamePackageDifferentFile() { expectedLookups.addAll(XMLNS_TYPE); expectedLookups.addAll(REFERENCE_TYPES); expectedLookups.addAll(COMMON_KEYWORDS); - expectedLookups.addAll(VALUE_KEYWORDS); expectedLookups.addAll(FUNCTION_LEVEL_KEYWORDS); expectedLookups.add("S"); expectedLookups.add("F"); diff --git a/src/test/java/org/ballerinalang/completion/BallerinaHiddenTemplateCompletionTest.java b/src/test/java/org/ballerinalang/completion/BallerinaHiddenTemplateCompletionTest.java index f6e22368..d5539e68 100644 --- a/src/test/java/org/ballerinalang/completion/BallerinaHiddenTemplateCompletionTest.java +++ b/src/test/java/org/ballerinalang/completion/BallerinaHiddenTemplateCompletionTest.java @@ -16,9 +16,6 @@ package org.ballerinalang.completion; -import java.util.LinkedList; -import java.util.List; - public class BallerinaHiddenTemplateCompletionTest extends BallerinaCompletionTestBase { /** @@ -45,12 +42,12 @@ public void testForkKeyword() { } public void testJoinKeyword() { - doCheckResult("test.bal", "function test(){ join }", "function test(){ join () (message[] ) {\n \n}" + + doCheckResult("test.bal", "function test(){ join }", "function test(){ join () () {\n \n}" + " }", null); } public void testTimeoutKeyword() { - doCheckResult("test.bal", "function test(){ timeout }", "function test(){ timeout () (message[] ) " + + doCheckResult("test.bal", "function test(){ timeout }", "function test(){ timeout () () " + "{\n \n} }", null); } @@ -102,7 +99,7 @@ public void testWhileKeyword() { } public void testContinueKeyword() { - doCheckResult("test.bal", "function test(){ continue }", "function test(){ continue; }", null); + doCheckResult("test.bal", "function test(){ next }", "function test(){ next; }", null); } public void testBreakKeyword() { diff --git a/src/test/java/org/ballerinalang/completion/BallerinaParameterCompletionTest.java b/src/test/java/org/ballerinalang/completion/BallerinaParameterCompletionTest.java index 04e64d94..c265b025 100644 --- a/src/test/java/org/ballerinalang/completion/BallerinaParameterCompletionTest.java +++ b/src/test/java/org/ballerinalang/completion/BallerinaParameterCompletionTest.java @@ -112,23 +112,23 @@ public void testParamAnnotationsPackageAutoCompletion() { } public void testParamAnnotationsFromAPackage() { - myFixture.addFileToProject("org/test/file.bal", "annotation TEST attach parameter {}"); + myFixture.addFileToProject("org/test/file.bal", "public annotation TEST attach parameter {}"); doTest("import org.test; function A(@test:)", "TEST"); } public void testParamAnnotationsFromAPackageAutoCompletion() { - myFixture.addFileToProject("org/test/file.bal", "annotation TEST attach parameter {}"); + myFixture.addFileToProject("org/test/file.bal", "public annotation TEST attach parameter {}"); doCheckResult("test.bal", "import org.test; function A(@test:T)", "import org.test; function A(@test:TEST {})", null); } public void testPackageInvocationInParameter() { - myFixture.addFileToProject("org/test/file.bal", "struct test {}"); + myFixture.addFileToProject("org/test/file.bal", "public struct test {}"); doTest("import org.test; function A(test:)", "test"); } public void testPackageInvocationInParameterAutoCompletion() { - myFixture.addFileToProject("org/test/file.bal", "struct test {}"); + myFixture.addFileToProject("org/test/file.bal", "public struct test {}"); doCheckResult("test.bal", "import org.test; function A(test:t)", "import org.test; function A(test:test )", null); }