summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorSven Amann2013-01-09 18:25:18 (EST)
committer Marcel Bruch2013-01-09 18:32:01 (EST)
commit49df256b0722d583471eadd7cbcf3446dd5782b2 (patch)
tree9af9be425244147d352cab45645b70dbd68a9338
parent3e976110ee1a211a0d5bd2eb7a9b9b81d58e190d (diff)
downloadorg.eclipse.recommenders-49df256b0722d583471eadd7cbcf3446dd5782b2.zip
org.eclipse.recommenders-49df256b0722d583471eadd7cbcf3446dd5782b2.tar.gz
org.eclipse.recommenders-49df256b0722d583471eadd7cbcf3446dd5782b2.tar.bz2
[tests] Added smoke tests for supertype/interface type completionrefs/changes/82/9482/7
If completion is triggered behind extends or implements, there is no prefix typed so far, and enclosing types supertypes and/or interfaces are retrieved from the completion context, a bug is triggered in the JDT which causes an IllegalArgumentException to be thrown. Change-Id: Iee34db8217b10ec15b3cbad45447b622d9df09c8
-rw-r--r--tests/org.eclipse.recommenders.tests/src/org/eclipse/recommenders/tests/CodeBuilder.xtend10
-rw-r--r--tests/org.eclipse.recommenders.tests/src/org/eclipse/recommenders/tests/SmokeTestScenarios.xtend25
-rw-r--r--tests/org.eclipse.recommenders.tests/xtend-gen/org/eclipse/recommenders/tests/CodeBuilder.java19
-rw-r--r--tests/org.eclipse.recommenders.tests/xtend-gen/org/eclipse/recommenders/tests/SmokeTestScenarios.java82
4 files changed, 95 insertions, 41 deletions
diff --git a/tests/org.eclipse.recommenders.tests/src/org/eclipse/recommenders/tests/CodeBuilder.xtend b/tests/org.eclipse.recommenders.tests/src/org/eclipse/recommenders/tests/CodeBuilder.xtend
index a9e6e0a..b700f69 100644
--- a/tests/org.eclipse.recommenders.tests/src/org/eclipse/recommenders/tests/CodeBuilder.xtend
+++ b/tests/org.eclipse.recommenders.tests/src/org/eclipse/recommenders/tests/CodeBuilder.xtend
@@ -1,14 +1,16 @@
-package org.eclipse.recommenders.tests
-
+package org.eclipse.recommenders.tests
+
import java.util.concurrent.atomic.AtomicInteger
class CodeBuilder {
- public static CharSequence someClass = '''public class C {}'''
private static AtomicInteger classCounter = new AtomicInteger()
+ def static classname(){
+ "TestClass"+ classCounter.addAndGet(1)
+ }
def static classbody(CharSequence classbody){
- classbody("Class"+ classCounter.addAndGet(1), classbody);
+ classbody(classname, classbody);
}
def static classbody(CharSequence classname, CharSequence classbody){
diff --git a/tests/org.eclipse.recommenders.tests/src/org/eclipse/recommenders/tests/SmokeTestScenarios.xtend b/tests/org.eclipse.recommenders.tests/src/org/eclipse/recommenders/tests/SmokeTestScenarios.xtend
index c6c5deb..9929503 100644
--- a/tests/org.eclipse.recommenders.tests/src/org/eclipse/recommenders/tests/SmokeTestScenarios.xtend
+++ b/tests/org.eclipse.recommenders.tests/src/org/eclipse/recommenders/tests/SmokeTestScenarios.xtend
@@ -10,6 +10,7 @@ class SmokeTestScenarios {
Arrays::asList(
IMPORT_01, IMPORT_02,
PACKAGE_01, PACKAGE_02, PACKAGE_03,
+ EXTENDS_01, EXTENDS_02, IMPLEMENTS_01,
CLASSBODY_01, CLASSBODY_02, CLASSBODY_03, CLASSBODY_04, CLASSBODY_05,
METHOD_STMT_01, METHOD_STMT_02, METHOD_STMT_03, METHOD_STMT_04, METHOD_STMT_05,METHOD_STMT_06,
METHOD_STMT_07, METHOD_STMT_08, METHOD_STMT_09, METHOD_STMT_10, METHOD_STMT_11, METHOD_STMT_12,
@@ -18,45 +19,49 @@ class SmokeTestScenarios {
}
- public static CharSequence someClass = '''public class C {}'''
-
public static CharSequence IMPORT_01='''
$i$mport$ $java$.$uti$l.$
- «someClass»
+ public class «classname» {}
'''
public static CharSequence IMPORT_02='''
import $stat$ic$ $java$.$uti$l.Collection.$
- «someClass»
+ public class «classname» {}
'''
public static CharSequence IMPORT_03='''
$
- «someClass»
+ public class «classname» {}
'''
public static CharSequence PACKAGE_01='''
$
- «someClass»
+ public class «classname» {}
'''
public static CharSequence PACKAGE_02='''
pack$age $
- «someClass»
+ public class «classname» {}
'''
public static CharSequence PACKAGE_03='''
package org.$
- «someClass»
+ public class «classname» {}
'''
+
+ public static CharSequence EXTENDS_01 = '''interface «classname» extends $Clo$sable {}'''
+
+ public static CharSequence EXTENDS_02 = '''class «classname» extends $Your$Class {}'''
+
+ public static CharSequence IMPLEMENTS_01 = '''class «classname» implements $Closab$le {}'''
public static CharSequence CLASSBODY_01 = classDeclaration(
- '''class ExtendingClass1 extends UnknownType''',
+ '''class «classname» extends UnknownType''',
'''$'''
)
public static CharSequence CLASSBODY_02 = classDeclaration(
- '''class ExtendingClass2 extends UnknownType''',
+ '''class «classname» extends UnknownType''',
'''siz$'''
)
diff --git a/tests/org.eclipse.recommenders.tests/xtend-gen/org/eclipse/recommenders/tests/CodeBuilder.java b/tests/org.eclipse.recommenders.tests/xtend-gen/org/eclipse/recommenders/tests/CodeBuilder.java
index a3249ff..0b34db7 100644
--- a/tests/org.eclipse.recommenders.tests/xtend-gen/org/eclipse/recommenders/tests/CodeBuilder.java
+++ b/tests/org.eclipse.recommenders.tests/xtend-gen/org/eclipse/recommenders/tests/CodeBuilder.java
@@ -6,14 +6,6 @@ import org.eclipse.xtext.xbase.lib.Functions.Function0;
@SuppressWarnings("all")
public class CodeBuilder {
- public static CharSequence someClass = new Function0<CharSequence>() {
- public CharSequence apply() {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("public class C {}");
- return _builder;
- }
- }.apply();
-
private static AtomicInteger classCounter = new Function0<AtomicInteger>() {
public AtomicInteger apply() {
AtomicInteger _atomicInteger = new AtomicInteger();
@@ -21,10 +13,15 @@ public class CodeBuilder {
}
}.apply();
- public static CharSequence classbody(final CharSequence classbody) {
+ public static String classname() {
int _addAndGet = CodeBuilder.classCounter.addAndGet(1);
- String _plus = ("Class" + Integer.valueOf(_addAndGet));
- CharSequence _classbody = CodeBuilder.classbody(_plus, classbody);
+ String _plus = ("TestClass" + Integer.valueOf(_addAndGet));
+ return _plus;
+ }
+
+ public static CharSequence classbody(final CharSequence classbody) {
+ String _classname = CodeBuilder.classname();
+ CharSequence _classbody = CodeBuilder.classbody(_classname, classbody);
return _classbody;
}
diff --git a/tests/org.eclipse.recommenders.tests/xtend-gen/org/eclipse/recommenders/tests/SmokeTestScenarios.java b/tests/org.eclipse.recommenders.tests/xtend-gen/org/eclipse/recommenders/tests/SmokeTestScenarios.java
index 67aaea1..3fa4ca7 100644
--- a/tests/org.eclipse.recommenders.tests/xtend-gen/org/eclipse/recommenders/tests/SmokeTestScenarios.java
+++ b/tests/org.eclipse.recommenders.tests/xtend-gen/org/eclipse/recommenders/tests/SmokeTestScenarios.java
@@ -12,6 +12,7 @@ public class SmokeTestScenarios {
List<CharSequence> _asList = Arrays.<CharSequence>asList(
SmokeTestScenarios.IMPORT_01, SmokeTestScenarios.IMPORT_02,
SmokeTestScenarios.PACKAGE_01, SmokeTestScenarios.PACKAGE_02, SmokeTestScenarios.PACKAGE_03,
+ SmokeTestScenarios.EXTENDS_01, SmokeTestScenarios.EXTENDS_02, SmokeTestScenarios.IMPLEMENTS_01,
SmokeTestScenarios.CLASSBODY_01, SmokeTestScenarios.CLASSBODY_02, SmokeTestScenarios.CLASSBODY_03, SmokeTestScenarios.CLASSBODY_04, SmokeTestScenarios.CLASSBODY_05,
SmokeTestScenarios.METHOD_STMT_01, SmokeTestScenarios.METHOD_STMT_02, SmokeTestScenarios.METHOD_STMT_03, SmokeTestScenarios.METHOD_STMT_04, SmokeTestScenarios.METHOD_STMT_05, SmokeTestScenarios.METHOD_STMT_06,
SmokeTestScenarios.METHOD_STMT_07, SmokeTestScenarios.METHOD_STMT_08, SmokeTestScenarios.METHOD_STMT_09, SmokeTestScenarios.METHOD_STMT_10, SmokeTestScenarios.METHOD_STMT_11, SmokeTestScenarios.METHOD_STMT_12,
@@ -19,20 +20,15 @@ public class SmokeTestScenarios {
return _asList;
}
- public static CharSequence someClass = new Function0<CharSequence>() {
- public CharSequence apply() {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("public class C {}");
- return _builder;
- }
- }.apply();
-
public static CharSequence IMPORT_01 = new Function0<CharSequence>() {
public CharSequence apply() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("$i$mport$ $java$.$uti$l.$");
_builder.newLine();
- _builder.append(CodeBuilder.someClass, "");
+ _builder.append("public class ");
+ String _classname = CodeBuilder.classname();
+ _builder.append(_classname, "");
+ _builder.append(" {}");
_builder.newLineIfNotEmpty();
return _builder;
}
@@ -43,7 +39,10 @@ public class SmokeTestScenarios {
StringConcatenation _builder = new StringConcatenation();
_builder.append("import $stat$ic$ $java$.$uti$l.Collection.$");
_builder.newLine();
- _builder.append(CodeBuilder.someClass, "");
+ _builder.append("public class ");
+ String _classname = CodeBuilder.classname();
+ _builder.append(_classname, "");
+ _builder.append(" {}");
_builder.newLineIfNotEmpty();
return _builder;
}
@@ -54,7 +53,10 @@ public class SmokeTestScenarios {
StringConcatenation _builder = new StringConcatenation();
_builder.append("$");
_builder.newLine();
- _builder.append(CodeBuilder.someClass, "");
+ _builder.append("public class ");
+ String _classname = CodeBuilder.classname();
+ _builder.append(_classname, "");
+ _builder.append(" {}");
_builder.newLineIfNotEmpty();
return _builder;
}
@@ -65,7 +67,10 @@ public class SmokeTestScenarios {
StringConcatenation _builder = new StringConcatenation();
_builder.append("$");
_builder.newLine();
- _builder.append(CodeBuilder.someClass, "");
+ _builder.append("public class ");
+ String _classname = CodeBuilder.classname();
+ _builder.append(_classname, "");
+ _builder.append(" {}");
_builder.newLineIfNotEmpty();
return _builder;
}
@@ -76,7 +81,10 @@ public class SmokeTestScenarios {
StringConcatenation _builder = new StringConcatenation();
_builder.append("pack$age $");
_builder.newLine();
- _builder.append(CodeBuilder.someClass, "");
+ _builder.append("public class ");
+ String _classname = CodeBuilder.classname();
+ _builder.append(_classname, "");
+ _builder.append(" {}");
_builder.newLineIfNotEmpty();
return _builder;
}
@@ -87,16 +95,55 @@ public class SmokeTestScenarios {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package org.$");
_builder.newLine();
- _builder.append(CodeBuilder.someClass, "");
+ _builder.append("public class ");
+ String _classname = CodeBuilder.classname();
+ _builder.append(_classname, "");
+ _builder.append(" {}");
_builder.newLineIfNotEmpty();
return _builder;
}
}.apply();
+ public static CharSequence EXTENDS_01 = new Function0<CharSequence>() {
+ public CharSequence apply() {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("interface ");
+ String _classname = CodeBuilder.classname();
+ _builder.append(_classname, "");
+ _builder.append(" extends $Clo$sable {}");
+ return _builder;
+ }
+ }.apply();
+
+ public static CharSequence EXTENDS_02 = new Function0<CharSequence>() {
+ public CharSequence apply() {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("class ");
+ String _classname = CodeBuilder.classname();
+ _builder.append(_classname, "");
+ _builder.append(" extends $Your$Class {}");
+ return _builder;
+ }
+ }.apply();
+
+ public static CharSequence IMPLEMENTS_01 = new Function0<CharSequence>() {
+ public CharSequence apply() {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("class ");
+ String _classname = CodeBuilder.classname();
+ _builder.append(_classname, "");
+ _builder.append(" implements $Closab$le {}");
+ return _builder;
+ }
+ }.apply();
+
public static CharSequence CLASSBODY_01 = new Function0<CharSequence>() {
public CharSequence apply() {
StringConcatenation _builder = new StringConcatenation();
- _builder.append("class ExtendingClass1 extends UnknownType");
+ _builder.append("class ");
+ String _classname = CodeBuilder.classname();
+ _builder.append(_classname, "");
+ _builder.append(" extends UnknownType");
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("$");
CharSequence _classDeclaration = CodeBuilder.classDeclaration(_builder, _builder_1);
@@ -107,7 +154,10 @@ public class SmokeTestScenarios {
public static CharSequence CLASSBODY_02 = new Function0<CharSequence>() {
public CharSequence apply() {
StringConcatenation _builder = new StringConcatenation();
- _builder.append("class ExtendingClass2 extends UnknownType");
+ _builder.append("class ");
+ String _classname = CodeBuilder.classname();
+ _builder.append(_classname, "");
+ _builder.append(" extends UnknownType");
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("siz$");
CharSequence _classDeclaration = CodeBuilder.classDeclaration(_builder, _builder_1);