summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhbehrens2009-04-28 06:00:13 (EDT)
committer sefftinge2009-04-28 06:00:13 (EDT)
commita12d99dc3ad3941f285c2e121df2a1c0102d22ee (patch)
treedd88c50833d7fe0e6d4eaa051762682b33a9f09c
parentc25ec25ad773992fe78b08b00edab3058b333bbe (diff)
downloadorg.eclipse.xtext-a12d99dc3ad3941f285c2e121df2a1c0102d22ee.zip
org.eclipse.xtext-a12d99dc3ad3941f285c2e121df2a1c0102d22ee.tar.gz
org.eclipse.xtext-a12d99dc3ad3941f285c2e121df2a1c0102d22ee.tar.bz2
* feature: Check that refuses enum with explicit empty literals ("")
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextValidationTest.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextValidationTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextValidationTest.java
index 8986fba..9554a02 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextValidationTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextValidationTest.java
@@ -106,4 +106,19 @@ public class XtextValidationTest extends AbstractGeneratorTest {
assertEquals("diag.isWarning", diag.getSeverity(), Diagnostic.WARNING);
}
+ public void testEnumWithEmptyLiteral() throws Exception {
+ XtextResource resource = getResourceFromString(
+ "grammar org.foo.Bar with org.eclipse.xtext.common.Terminals\n" +
+ "generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/validation/literal/2'\n" +
+ "Model: enumValue=GeneratedEnum;\n" +
+ "enum GeneratedEnum: NoLiteral | ValidLiteral='literal' | EmptyLiteral='';");
+ assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
+ assertTrue(resource.getWarnings().toString(), resource.getWarnings().isEmpty());
+
+ Diagnostic diag = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
+ assertNotNull("diag", diag);
+ assertEquals(diag.getChildren().toString(), 1, diag.getChildren().size());
+ assertEquals("diag.isError", diag.getSeverity(), Diagnostic.ERROR);
+ }
+
}