aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormeysholdt2009-03-03 11:29:47 (EST)
committersefftinge2009-03-03 11:29:47 (EST)
commit978ac7a604caaf01f1062b66b06eb42cb806ca33 (patch)
tree9846e132b29799e9e9787239b76406b4ef28377b
parent031cb6e1da2f0462f3de08050e64ecac15b1cebb (diff)
downloadorg.eclipse.xtext-978ac7a604caaf01f1062b66b06eb42cb806ca33.zip
org.eclipse.xtext-978ac7a604caaf01f1062b66b06eb42cb806ca33.tar.gz
org.eclipse.xtext-978ac7a604caaf01f1062b66b06eb42cb806ca33.tar.bz2
added tests for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=266879
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/DefaultScopeProviderTest.java50
1 files changed, 49 insertions, 1 deletions
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/DefaultScopeProviderTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/DefaultScopeProviderTest.java
index 12cb3b1..bcc35ba 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/DefaultScopeProviderTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/DefaultScopeProviderTest.java
@@ -43,7 +43,41 @@ public class DefaultScopeProviderTest extends AbstractGeneratorTest {
assertWithXtend("'bar'", "types.first().extends.name", resource.getContents().get(0));
}
- public void testScope() throws Exception {
+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=266879
+ public void testRelativeScope() throws Exception {
+ TestURIConverter models = new TestURIConverter();
+ ResourceSetImpl rs = new ResourceSetImpl();
+ rs.setURIConverter(models);
+
+ models.addModel("testfile://my/folder/foo.importuritestlanguage", "import 'bar.importuritestlanguage' type foo extends bar type bar extends bar2");
+ models.addModel("testfile://my/folder/bar.importuritestlanguage", "type bar type bar2 extends bar");
+
+ Resource resource = rs.getResource(URI.createURI("testfile://my/folder/foo.importuritestlanguage"), true);
+
+ assertWithXtend("'bar'", "types.first().extends.name", resource.getContents().get(0));
+ assertWithXtend("'bar2'", "types.first().extends.extends.name", resource.getContents().get(0));
+ assertWithXtend("'bar'", "types.first().extends.extends.extends.name", resource.getContents().get(0));
+ assertWithXtend("null", "types.first().extends.extends.extends.extends", resource.getContents().get(0));
+ }
+
+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=266879
+ public void testRelativeScopeWithPath() throws Exception {
+ TestURIConverter models = new TestURIConverter();
+ ResourceSetImpl rs = new ResourceSetImpl();
+ rs.setURIConverter(models);
+ models.addModel("testfile://my/folder/foo.importuritestlanguage", "import './../folder/bar.importuritestlanguage' type foo extends bar type bar extends bar2");
+
+ models.addModel("testfile://my/folder/bar.importuritestlanguage", "type bar type bar2 extends bar");
+
+ Resource resource = rs.getResource(URI.createURI("testfile://my/folder/foo.importuritestlanguage"), true);
+
+ assertWithXtend("'bar'", "types.first().extends.name", resource.getContents().get(0));
+ assertWithXtend("'bar2'", "types.first().extends.extends.name", resource.getContents().get(0));
+ assertWithXtend("'bar'", "types.first().extends.extends.extends.name", resource.getContents().get(0));
+ assertWithXtend("null", "types.first().extends.extends.extends.extends", resource.getContents().get(0));
+ }
+
+ public void testScopeFileName() throws Exception {
TestURIConverter models = new TestURIConverter();
ResourceSetImpl rs = new ResourceSetImpl();
rs.setURIConverter(models);
@@ -59,6 +93,20 @@ public class DefaultScopeProviderTest extends AbstractGeneratorTest {
assertWithXtend("null", "types.first().extends.extends.extends.extends", resource.getContents().get(0));
}
+ // TODO: report a meaningful error to the user when resolving of an import fails
+
+ /*
+ public void testUnresolvableImport() throws Exception {
+ TestURIConverter models = new TestURIConverter();
+ ResourceSetImpl rs = new ResourceSetImpl();
+ rs.setURIConverter(models);
+
+ models.addModel("testfile://my/folder/foo.importuritestlanguage", "import <unknownfile.importuritestlanguage> type foo extends bar type bar extends bar2");
+
+ Resource resource = rs.getResource(URI.createURI("testfile://my/folder/foo.importuritestlanguage"), true);
+ }
+ */
+
public void testCircularImport() throws Exception {
TestURIConverter models = new TestURIConverter();
ResourceSetImpl rs = new ResourceSetImpl();