aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-03-23 03:25:56 (EDT)
committersefftinge2009-03-23 03:25:56 (EDT)
commit1bbc9e02d24701e428b63d43a626e291f7784427 (patch)
tree59cb63be748085c7b0c5ca22f9b4a01da7d3a681
parenta34f82b9b2b7ec562f3eb3745097316c70a2d589 (diff)
downloadorg.eclipse.xtext-1bbc9e02d24701e428b63d43a626e291f7784427.zip
org.eclipse.xtext-1bbc9e02d24701e428b63d43a626e291f7784427.tar.gz
org.eclipse.xtext-1bbc9e02d24701e428b63d43a626e291f7784427.tar.bz2
Test for bug in ContentAssist
-rw-r--r--tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/ContentAssistProcessorTestBuilder.java9
-rw-r--r--tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessorTest.java43
2 files changed, 33 insertions, 19 deletions
diff --git a/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/ContentAssistProcessorTestBuilder.java b/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/ContentAssistProcessorTestBuilder.java
index 861f7d6..d7df948 100644
--- a/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/ContentAssistProcessorTestBuilder.java
+++ b/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/ContentAssistProcessorTestBuilder.java
@@ -109,11 +109,16 @@ public class ContentAssistProcessorTestBuilder {
return assertTextAtCursorPosition(this.cursorPosition, expectedText);
}
- public ContentAssistProcessorTestBuilder assertTextAtCursorPosition(String cursorPosition, String... expectedText)
- throws Exception {
+ public ContentAssistProcessorTestBuilder assertTextAtCursorPosition(
+ String cursorPosition, String... expectedText) throws Exception {
return assertTextAtCursorPosition(getModel().indexOf(cursorPosition), expectedText);
}
+ public ContentAssistProcessorTestBuilder assertTextAtCursorPosition(
+ String cursorPosition, int offset, String... expectedText) throws Exception {
+ return assertTextAtCursorPosition(getModel().indexOf(cursorPosition) + offset, expectedText);
+ }
+
public ContentAssistProcessorTestBuilder assertTextAtCursorPosition(int cursorPosition, String... expectedText)
throws Exception {
diff --git a/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessorTest.java b/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessorTest.java
index 7bd81a7..867f48b 100644
--- a/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessorTest.java
+++ b/tests/org.eclipse.xtext.ui.common.tests/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/DefaultContentAssistProcessorTest.java
@@ -233,22 +233,22 @@ public class DefaultContentAssistProcessorTest extends AbstractXtextTests {
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=260825
*/
public void testCompleteParserRule_01() throws Exception {
- newBuilder(getXtextGrammarSetup())
- .appendNl("grammar foo")
- .appendNl("generate foo \"foo\"")
- .appendNl("MyRule : 'foo' name=ID; ").assertText(
- "ParserRule_Name", "terminal"
- );
+ newBuilder(getXtextGrammarSetup())
+ .appendNl("grammar foo")
+ .appendNl("generate foo \"foo\"")
+ .appendNl("MyRule : 'foo' name=ID; ").assertText(
+ "ParserRule_Name", "terminal"
+ );
}
public void testCompleteParserRule_02() throws Exception {
- newBuilder(getXtextGrammarSetup())
- .appendNl("grammar foo")
- .appendNl("generate foo \"foo\"")
- .appendNl("")
- .appendNl("MyRule : 'foo' name=ID; ").
- assertTextAtCursorPosition("MyRule",
- "ParserRule_Name", "terminal");
+ newBuilder(getXtextGrammarSetup())
+ .appendNl("grammar foo")
+ .appendNl("generate foo \"foo\"")
+ .appendNl("")
+ .appendNl("MyRule : 'foo' name=ID; ")
+ .assertTextAtCursorPosition("MyRule",
+ "ParserRule_Name", "terminal");
}
public void testCompleteParserRule_03() throws Exception {
@@ -256,10 +256,20 @@ public class DefaultContentAssistProcessorTest extends AbstractXtextTests {
.appendNl("grammar foo")
.appendNl("generate foo \"foo\"")
.appendNl("")
- .appendNl(" MyRule : 'foo' name=ID; ").
- assertTextAtCursorPosition(" MyRule",
+ .appendNl(" MyRule : 'foo' name=ID; ")
+ .assertTextAtCursorPosition(" MyRule",
"ParserRule_Name", "terminal");
}
+
+ public void _testCompleteGenerateKeyword() throws Exception {
+ newBuilder(getXtextGrammarSetup())
+ .appendNl("grammar foo")
+ .appendNl("generate foo \"foo\"")
+ .appendNl("")
+ .appendNl("MyRule : 'foo' name=ID; ")
+ .assertTextAtCursorPosition("generate", 3,
+ "generate");
+ }
/**
* regression test for:
@@ -280,8 +290,7 @@ public class DefaultContentAssistProcessorTest extends AbstractXtextTests {
}
public void testKeywordWithBackslashes() throws Exception {
- newBuilder(getKeywordsLangSetup())
- .assertText("foo\\bar", "foo\\", "\\bar", "\\");
+ newBuilder(getKeywordsLangSetup()).assertText("foo\\bar", "foo\\", "\\bar", "\\");
}
public void testEnumCompletion_01() throws Exception {