This repository has been archived by the owner on Oct 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #671 from Shan1024/update-tests-temp
Update tests
- Loading branch information
Showing
21 changed files
with
939 additions
and
556 deletions.
There are no files selected for viewing
556 changes: 0 additions & 556 deletions
556
src/test/java/org/ballerinalang/completion/BallerinaCompletionTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
src/test/java/org/ballerinalang/completion/BallerinaConstantCompletionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
/* | ||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.ballerinalang.completion; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
public class BallerinaConstantCompletionTest extends BallerinaCompletionTestBase { | ||
|
||
/** | ||
* Test constants. | ||
*/ | ||
public void testConstTypes() { | ||
doTest("const <caret>", DATA_TYPES.toArray(new String[DATA_TYPES.size()])); | ||
} | ||
|
||
public void testConstIdentifier() { | ||
doTest("const boolean <caret>"); | ||
} | ||
|
||
public void testConstValues() { | ||
doTest("const string NAME = <caret>", "true", "false", "null"); | ||
} | ||
|
||
public void testConstantAnnotation() { | ||
doCheckResult("test.bal", "@<caret> const string S=\"\";", null, '@'); | ||
} | ||
|
||
public void testConstantAnnotationWithImports() { | ||
myFixture.addFileToProject("org/test/file.bal", "string s = \"\";"); | ||
doCheckResult("test.bal", "import org.test; <caret> const string S=\"\";", null, '@', "test"); | ||
} | ||
|
||
public void testConstantAnnotationWithImportsNoAnnotationDefinitions() { | ||
myFixture.addFileToProject("org/test/file.bal", "function test(){}"); | ||
doCheckResult("test.bal", "import org.test; @test<caret> const string S=\"\";", null, ':'); | ||
} | ||
|
||
public void testConstantAnnotationWithImportsWithNoMatchingAnnotationDefinitions() { | ||
myFixture.addFileToProject("org/test/file.bal", "public annotation TEST attach service {}"); | ||
doCheckResult("test.bal", "import org.test; @test:<caret> const string S=\"\";", null, null); | ||
} | ||
|
||
public void testConstantAnnotationWithImportsWithMatchingAnnotationDefinitions() { | ||
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:<caret> const string S=\"\";", null, null, "TEST"); | ||
} | ||
|
||
public void testConstantAnnotationWithImportsWithMatchingAnnotationDefinitionsAutoCompletion() { | ||
myFixture.addFileToProject("org/test/file.bal", "package org.test; public annotation TEST attach const {}"); | ||
doCheckResult("test.bal", "import org.test; @test:T<caret> const string S=\"\";", | ||
"import org.test; @test:TEST {} const string S=\"\";", null); | ||
} | ||
|
||
public void testConstantAnnotationInCurrentPackageSameFile() { | ||
doCheckResult("test.bal", "annotation TEST attach const {} <caret> const string S=\"\";", null, '@', | ||
"TEST"); | ||
} | ||
|
||
public void testConstantAnnotationInCurrentPackageSameFileAutoComplete() { | ||
doCheckResult("test.bal", "annotation TEST attach const {} @T<caret> const string S=\"\";", | ||
"annotation TEST attach const {} @TEST {} const string S=\"\";", null); | ||
} | ||
|
||
public void testConstantAnnotationInCurrentPackageDifferentFile() { | ||
myFixture.addFileToProject("file.bal", "annotation TEST attach const {}"); | ||
doCheckResult("test.bal", "<caret> const string S=\"\";", null, '@', "TEST"); | ||
} | ||
|
||
public void testConstantAnnotationInCurrentPackageDifferentFileAutoComplete() { | ||
myFixture.addFileToProject("file.bal", "annotation TEST attach function {}"); | ||
doCheckResult("test.bal", "@T<caret> function A(){}", "@TEST {} function A(){}", null); | ||
} | ||
|
||
public void testConstantAnnotationInCurrentPackageDifferentFileHasMoreDefinitionsAfter() { | ||
myFixture.addFileToProject("file.bal", "annotation TEST attach const {}"); | ||
doCheckResult("test.bal", "<caret> const string S=\"\"; service R{}", null, '@', "TEST"); | ||
} | ||
|
||
public void testConstantAnnotationInCurrentPackageSameFileHasMoreDefinitionsAfter() { | ||
doCheckResult("test.bal", "annotation TEST attach const {} <caret> const string S=\"\"; service R{}", null, '@', | ||
"TEST"); | ||
} | ||
|
||
public void testConstantTypesBeforeGlobalVarDef() { | ||
doTest("const <caret>\n string test =\"\";", DATA_TYPES.toArray(new String[DATA_TYPES.size()])); | ||
} | ||
|
||
public void testConstantInSamePackageSameFile() { | ||
List<String> expectedLookups = new LinkedList<>(); | ||
expectedLookups.addAll(DATA_TYPES); | ||
expectedLookups.addAll(OTHER_TYPES); | ||
expectedLookups.addAll(XMLNS_TYPE); | ||
expectedLookups.addAll(REFERENCE_TYPES); | ||
expectedLookups.addAll(COMMON_KEYWORDS); | ||
expectedLookups.addAll(FUNCTION_LEVEL_KEYWORDS); | ||
expectedLookups.add("S"); | ||
expectedLookups.add("F"); | ||
doTest("string S=\"\"; function F(){ <caret> }", expectedLookups.toArray(new String[expectedLookups.size()])); | ||
} | ||
|
||
public void testConstantInSamePackageDifferentFile() { | ||
myFixture.addFileToProject("file.bal", "const string S=\"\";"); | ||
List<String> expectedLookups = new LinkedList<>(); | ||
expectedLookups.addAll(DATA_TYPES); | ||
expectedLookups.addAll(OTHER_TYPES); | ||
expectedLookups.addAll(XMLNS_TYPE); | ||
expectedLookups.addAll(REFERENCE_TYPES); | ||
expectedLookups.addAll(COMMON_KEYWORDS); | ||
expectedLookups.addAll(FUNCTION_LEVEL_KEYWORDS); | ||
expectedLookups.add("S"); | ||
expectedLookups.add("F"); | ||
doTest("function F(){ <caret> }", expectedLookups.toArray(new String[expectedLookups.size()])); | ||
} | ||
|
||
public void testConstantInDifferentPackage() { | ||
myFixture.addFileToProject("org/test/file.bal", "public const string S=\"\";"); | ||
doTest("import org.test; function F(){ test:<caret> }", "S"); | ||
} | ||
|
||
public void testConstantInDifferentPackageImportedAsAlias() { | ||
myFixture.addFileToProject("org/test/file.bal", "cont string S=\"\";"); | ||
doTest("import org.test as utils; function F(){ utils:<caret> }", "S"); | ||
} | ||
} |
200 changes: 200 additions & 0 deletions
200
src/test/java/org/ballerinalang/completion/BallerinaFileLevelCompletionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
/* | ||
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.ballerinalang.completion; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
public class BallerinaFileLevelCompletionTest extends BallerinaCompletionTestBase { | ||
|
||
/** | ||
* Test file level lookups. | ||
*/ | ||
public void testEmptyFile() { | ||
List<String> expectedLookups = new LinkedList<>(); | ||
expectedLookups.addAll(FILE_LEVEL_KEYWORDS); | ||
expectedLookups.addAll(OTHER_TYPES); | ||
expectedLookups.addAll(XMLNS_TYPE); | ||
expectedLookups.addAll(DATA_TYPES); | ||
expectedLookups.addAll(REFERENCE_TYPES); | ||
doTest("<caret>", expectedLookups.toArray(new String[expectedLookups.size()])); | ||
} | ||
|
||
public void testEmptyFilePackageKeyword() { | ||
doTest("p<caret>", "public", "import", "package", "typemapper", "map", "type"); | ||
} | ||
|
||
public void testEmptyFileImportKeyword() { | ||
doTest("i<caret>", "public", "annotation", "function", "import", "service", "int", "string"); | ||
} | ||
|
||
public void testEmptyFileWithSpaceBeforeCaret() { | ||
List<String> expectedLookups = new LinkedList<>(); | ||
expectedLookups.addAll(FILE_LEVEL_KEYWORDS); | ||
expectedLookups.addAll(OTHER_TYPES); | ||
expectedLookups.addAll(XMLNS_TYPE); | ||
expectedLookups.addAll(DATA_TYPES); | ||
expectedLookups.addAll(REFERENCE_TYPES); | ||
doTest("\n<caret>", expectedLookups.toArray(new String[expectedLookups.size()])); | ||
} | ||
|
||
public void testEmptyFileWithSpaceBeforeCaretPackageKeyword() { | ||
doTest("\np<caret>", "public", "import", "package", "typemapper", "map", "type"); | ||
} | ||
|
||
public void testEmptyFileWithSpaceBeforeCaretImportKeyword() { | ||
doTest("\ni<caret>", "public", "annotation", "function", "import", "service", "int", "string"); | ||
} | ||
|
||
public void testEmptyFileWithSpaceAfterCaret() { | ||
List<String> expectedLookups = new LinkedList<>(); | ||
expectedLookups.addAll(FILE_LEVEL_KEYWORDS); | ||
expectedLookups.addAll(OTHER_TYPES); | ||
expectedLookups.addAll(XMLNS_TYPE); | ||
expectedLookups.addAll(DATA_TYPES); | ||
expectedLookups.addAll(REFERENCE_TYPES); | ||
doTest("<caret>\n", expectedLookups.toArray(new String[expectedLookups.size()])); | ||
} | ||
|
||
public void testEmptyFileWithSpaceAfterCaretPackageKeyword() { | ||
doTest("p<caret>\n", "public", "import", "package", "typemapper", "map", "type"); | ||
} | ||
|
||
public void testEmptyFileWithSpaceAfterCaretImportKeyword() { | ||
doTest("i<caret>\n", "public", "annotation", "function", "import", "service", "int", "string"); | ||
} | ||
|
||
public void testEmptyFileWithSpaces() { | ||
List<String> expectedLookups = new LinkedList<>(); | ||
expectedLookups.addAll(FILE_LEVEL_KEYWORDS); | ||
expectedLookups.addAll(OTHER_TYPES); | ||
expectedLookups.addAll(XMLNS_TYPE); | ||
expectedLookups.addAll(DATA_TYPES); | ||
expectedLookups.addAll(REFERENCE_TYPES); | ||
doTest("\n<caret>\n", expectedLookups.toArray(new String[expectedLookups.size()])); | ||
} | ||
|
||
public void testEmptyFileWithSpacesPackageKeyword() { | ||
doTest("\np<caret>\n", "public", "import", "package", "typemapper", "map", "type"); | ||
} | ||
|
||
public void testEmptyFileWithSpacesImportKeyword() { | ||
doTest("\ni<caret>\n", "public", "annotation", "function", "import", "service", "int", "string"); | ||
} | ||
|
||
public void testImportAfterPackage() { | ||
List<String> expectedLookups = new LinkedList<>(); | ||
expectedLookups.addAll(OTHER_TYPES); | ||
expectedLookups.addAll(XMLNS_TYPE); | ||
expectedLookups.addAll(DATA_TYPES); | ||
expectedLookups.addAll(REFERENCE_TYPES); | ||
expectedLookups.add("public"); | ||
expectedLookups.add("import"); | ||
expectedLookups.add("const"); | ||
expectedLookups.add("service"); | ||
expectedLookups.add("function"); | ||
expectedLookups.add("connector"); | ||
expectedLookups.add("struct"); | ||
expectedLookups.add("typemapper"); | ||
expectedLookups.add("annotation"); | ||
expectedLookups.add("enum"); | ||
doTest("package test; \n<caret>\n", expectedLookups.toArray(new String[expectedLookups.size()])); | ||
} | ||
|
||
public void testImportAfterPackagePartialIdentifier() { | ||
doTest("package test; \ni<caret>\n", "public", "annotation", "function", "import", "service", "int", "string"); | ||
} | ||
|
||
public void testImportAfterPackageBeforeFunction() { | ||
List<String> expectedLookups = new LinkedList<>(); | ||
expectedLookups.addAll(OTHER_TYPES); | ||
expectedLookups.addAll(XMLNS_TYPE); | ||
expectedLookups.addAll(DATA_TYPES); | ||
expectedLookups.addAll(REFERENCE_TYPES); | ||
expectedLookups.add("public"); | ||
expectedLookups.add("import"); | ||
expectedLookups.add("const"); | ||
expectedLookups.add("service"); | ||
expectedLookups.add("function"); | ||
expectedLookups.add("connector"); | ||
expectedLookups.add("struct"); | ||
expectedLookups.add("typemapper"); | ||
expectedLookups.add("annotation"); | ||
expectedLookups.add("enum"); | ||
doTest("package test; \n<caret>\nfunction A(){}", expectedLookups.toArray(new String[expectedLookups.size()])); | ||
} | ||
|
||
public void testImportAfterPackageBeforeFunctionPartialIdentifier() { | ||
doTest("package test; \ni<caret>\nfunction A(){}", "public", "annotation", "function", "import", "service", | ||
"int", "string"); | ||
} | ||
|
||
public void testPackageBeforeImport() { | ||
List<String> expectedLookups = new LinkedList<>(); | ||
expectedLookups.addAll(FILE_LEVEL_KEYWORDS); | ||
expectedLookups.addAll(OTHER_TYPES); | ||
expectedLookups.addAll(XMLNS_TYPE); | ||
expectedLookups.addAll(DATA_TYPES); | ||
expectedLookups.addAll(REFERENCE_TYPES); | ||
doTest("<caret>\nimport test; \nfunction A(){}", expectedLookups.toArray(new String[expectedLookups.size()])); | ||
} | ||
|
||
public void testPackageBeforeImportPartialIdentifier() { | ||
doTest("p<caret>\nimport test; \nfunction A(){}", "public", "import", "package", "typemapper", "map", "type"); | ||
} | ||
|
||
public void testImportBeforeImport() { | ||
List<String> expectedLookups = new LinkedList<>(); | ||
expectedLookups.addAll(FILE_LEVEL_KEYWORDS); | ||
expectedLookups.addAll(OTHER_TYPES); | ||
expectedLookups.addAll(XMLNS_TYPE); | ||
expectedLookups.addAll(DATA_TYPES); | ||
expectedLookups.addAll(REFERENCE_TYPES); | ||
doTest("<caret>\nimport test; \nfunction A(){}", expectedLookups.toArray(new String[expectedLookups.size()])); | ||
} | ||
|
||
public void testImportBeforeImportPartialIdentifier() { | ||
doTest("i<caret>\nimport test; \nfunction A(){}", "public", "annotation", "function", "import", "service", | ||
"int", "string"); | ||
} | ||
|
||
public void testImportAfterImport() { | ||
List<String> expectedLookups = new LinkedList<>(); | ||
expectedLookups.addAll(OTHER_TYPES); | ||
expectedLookups.addAll(XMLNS_TYPE); | ||
expectedLookups.addAll(DATA_TYPES); | ||
expectedLookups.addAll(REFERENCE_TYPES); | ||
expectedLookups.add("public"); | ||
expectedLookups.add("import"); | ||
expectedLookups.add("const"); | ||
expectedLookups.add("service"); | ||
expectedLookups.add("function"); | ||
expectedLookups.add("connector"); | ||
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<caret> \nfunction A(){}", expectedLookups.toArray(new String[expectedLookups.size()])); | ||
} | ||
|
||
public void testImportAfterImportPartialIdentifier() { | ||
doTest("import test; \ni<caret> \nfunction A(){}", "public", "annotation", "function", "import", "service", | ||
"int", "string"); | ||
} | ||
} |
Oops, something went wrong.