summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsefftinge2008-03-07 03:30:30 (EST)
committersefftinge2008-03-07 03:30:30 (EST)
commit6b54c985b74143f6e8c7d2361496a867052d8409 (patch)
tree7ba72028bdad3b8a0b94905f1c57b3415b38ea81
parent15cb5f175a3d1bb140aaf9a04ea83d5ee6b2f8ca (diff)
downloadorg.eclipse.xpand-6b54c985b74143f6e8c7d2361496a867052d8409.zip
org.eclipse.xpand-6b54c985b74143f6e8c7d2361496a867052d8409.tar.gz
org.eclipse.xpand-6b54c985b74143f6e8c7d2361496a867052d8409.tar.bz2
*** empty log message ***
-rw-r--r--tests/org.eclipse.xpand3.tests/META-INF/MANIFEST.MF3
-rw-r--r--tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/AbstractXpand3NodeParserTest.java147
-rw-r--r--tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/StatementParserTest.java248
-rw-r--r--tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/SyntaxUtil.java6
-rw-r--r--tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/Xpand3MigratedNodeParserTest.java195
-rw-r--r--tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/Xpand3NodeParserTest.java61
-rw-r--r--tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/Xpand3ScannerTest.java59
-rw-r--r--tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/XpandLexerTest.java31
8 files changed, 2 insertions, 748 deletions
diff --git a/tests/org.eclipse.xpand3.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.xpand3.tests/META-INF/MANIFEST.MF
index fcbaa6b..d53e0f1 100644
--- a/tests/org.eclipse.xpand3.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.xpand3.tests/META-INF/MANIFEST.MF
@@ -7,4 +7,5 @@ Bundle-Vendor: www.eclipse.org
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.junit,
org.eclipse.xpand3;bundle-version="0.9",
- org.antlr.patched;bundle-version="3.0.0"
+ org.antlr.patched;bundle-version="3.0.0",
+ org.eclipse.tmf.common.runtime;bundle-version="1.0.0"
diff --git a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/AbstractXpand3NodeParserTest.java b/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/AbstractXpand3NodeParserTest.java
deleted file mode 100644
index d532098..0000000
--- a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/AbstractXpand3NodeParserTest.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package org.eclipse.xpand3.parser;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.xpand3.node.CompositeNode;
-import org.eclipse.xpand3.node.LeafNode;
-import org.eclipse.xpand3.node.LexedToken;
-import org.eclipse.xpand3.node.Node;
-
-public abstract class AbstractXpand3NodeParserTest extends TestCase {
-
- public static final char LG = '\u00AB';
- public static final char RG = '\u00BB';
-
- public static final String LGS = String.valueOf(LG);
- public static final String RGS = String.valueOf(RG);
-
- public AbstractXpand3NodeParserTest() {
- super();
- }
-
- public AbstractXpand3NodeParserTest(String name) {
- super(name);
- }
-
- protected CompositeNode checkIsRule(Node node, String ruleName,
- int numChildren) {
- assertTrue(node instanceof CompositeNode);
- assertEquals(ruleName, ((CompositeNode) node).getRule());
- assertEquals(numChildren, ((CompositeNode) node).getChildren().size());
- return (CompositeNode) node;
- }
-
- private LeafNode checkIsToken(Node node, String tokenText) {
- assertTrue(node instanceof LeafNode);
- LexedToken token = ((LeafNode) node).getToken();
- assertNotNull(token);
- assertEquals(tokenText, token.getText());
- return (LeafNode) node;
- }
-
- private Node getChild(Node parent, int index) {
- assertNotNull(parent);
- assertTrue(parent instanceof CompositeNode);
- List<Node> children = ((CompositeNode) parent).getChildren();
- assertTrue(children.size() > index);
- Node child = children.get(index);
- return child;
- }
-
- protected CompositeNode checkChildIsRule(Node parent, int index,
- String ruleName, int numChildren) {
- return checkIsRule(getChild(parent, index), ruleName, numChildren);
- }
-
- protected CompositeNode checkChildIsSimpleType(Node parent, int index,
- String identifierName) {
- CompositeNode simpleType = checkChildIsRule(parent, index,
- "r_simpleType", 1);
- checkChildIsIdentifier(simpleType, 0, identifierName);
- return simpleType;
- }
-
- protected CompositeNode checkChildIsCollectionType(Node parent, int index,
- String identifierName) {
- CompositeNode collectionType = checkChildIsRule(parent, index,
- "r_collectionType", 1);
- checkChildIsToken(collectionType, 0, identifierName);
- return collectionType;
- }
-
- protected CompositeNode checkChildIsIdentifier(Node parent, int index,
- String identifierName) {
- CompositeNode identifier = checkChildIsRule(parent, index,
- "r_identifier", 1);
- checkChildIsToken(identifier, 0, identifierName);
- return identifier;
- }
-
- protected CompositeNode checkChildIsScopedType(Node parent, int index,
- String... scopeName) {
- CompositeNode scopedType = checkChildIsRule(parent, index,
- "r_simpleType", 2 * scopeName.length - 1);
- checkChildIsIdentifier(scopedType, 0, scopeName[0]);
- for (int i = 1; i < scopeName.length; i++) {
- checkChildIsToken(scopedType, 2 * i - 1, "::");
- checkChildIsIdentifier(scopedType, 2 * i, scopeName[i]);
- }
- return scopedType;
- }
-
- protected CompositeNode checkChildIsNumberLiteral(Node parent, int index,
- String value) {
- CompositeNode numberLiteral = checkChildIsRule(parent, index,
- "r_numberLiteral", 1);
- checkChildIsToken(numberLiteral, 0, value);
- return numberLiteral;
- }
-
- protected CompositeNode checkChildIsStringLiteral(Node parent, int index,
- String value) {
- CompositeNode stringLiteral = checkChildIsRule(parent, index,
- "r_stringLiteral", 1);
- checkChildIsToken(stringLiteral, 0, value);
- return stringLiteral;
- }
-
- protected CompositeNode checkChildIsTrueLiteral(Node parent, int index) {
- CompositeNode booleanLiteral = checkChildIsRule(parent, index,
- "r_booleanLiteral", 1);
- checkChildIsToken(booleanLiteral, 0, "true");
- return booleanLiteral;
- }
-
- protected CompositeNode checkChildIsFalseLiteral(Node parent, int index) {
- CompositeNode booleanLiteral = checkChildIsRule(parent, index,
- "r_booleanLiteral", 1);
- checkChildIsToken(booleanLiteral, 0, "false");
- return booleanLiteral;
- }
-
- protected LeafNode checkChildIsToken(Node parent, int index,
- String tokenText) {
- return checkIsToken(getChild(parent, index), tokenText);
- }
-
- protected String tag(final String str) {
- return LG + str + RG;
- }
-
- protected CompositeNode checkChildIsSequenceText(Node parent, int index,
- String textWithoutGuillemots, int numChildren) {
- CompositeNode sequence = checkChildIsRule(parent, index, "r_sequence",
- numChildren);
- return checkChildIsText(sequence, 0, textWithoutGuillemots);
- }
-
- protected CompositeNode checkChildIsText(CompositeNode sequence, int index,
- String textWithoutGuillemots) {
- CompositeNode text = checkChildIsRule(sequence, index, "r_text", 1);
- checkChildIsToken(text, 0, RGS + textWithoutGuillemots + LGS);
- return sequence;
- }
-
-} \ No newline at end of file
diff --git a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/StatementParserTest.java b/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/StatementParserTest.java
deleted file mode 100644
index 3876123..0000000
--- a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/StatementParserTest.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 committers of openArchitectureWare and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * committers of openArchitectureWare - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.xpand3.parser;
-
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.CommonTokenStream;
-import org.eclipse.xpand3.node.CompositeNode;
-import org.eclipse.xpand3.node.Node;
-import org.eclipse.xpand3.node.NodeUtil;
-
-/**
- * @author Jan Kšhnlein
- */
-public class StatementParserTest extends AbstractXpand3NodeParserTest {
- private CompositeNode parse(String s) throws Exception {
- System.out.println(s);
- ANTLRStringStream stream = new ANTLRStringStream(s);
- Xpand3Lexer lexer = new Xpand3Lexer(stream);
- CommonTokenStream tokenStream = new CommonTokenStream(lexer);
- AbstractXpand3NodeParser xpand3NodeParser = new Xpand3NodeParser(
- tokenStream);
- xpand3NodeParser.r_file();
- Node rootNode = xpand3NodeParser.getRootNode();
- if (rootNode == null) {
- System.out.println("Nothing parsed.");
- } else {
- System.out.println(NodeUtil.toString(rootNode));
- }
- return (CompositeNode) rootNode;
- }
-
- public final void testEmptyTemplate() throws Exception {
- Node expr = parse("");
- assertNull(expr);
- }
-
- public final void testSimpleDefine() throws Exception {
- Node expr = parse(tag("DEFINE test FOR ecore::EClass")
- + tag("ENDDEFINE"));
- checkIsRule(expr, "r_definition", 8);
- checkChildIsToken(expr, 0, LGS);
- checkChildIsToken(expr, 1, "DEFINE");
- checkChildIsIdentifier(expr, 2, "test");
- checkChildIsToken(expr, 3, "FOR");
- checkChildIsScopedType(expr, 4, "ecore", "EClass");
- checkChildIsSequenceText(expr, 5, "", 1);
- checkChildIsToken(expr, 6, "ENDDEFINE");
- checkChildIsToken(expr, 7, RGS);
-
- }
-
- public final void testDoubleDefine() throws Exception {
- Node file = parse(tag("DEFINE test FOR ecore::EClass")
- + tag("ENDDEFINE")
- + tag("DEFINE test2(String txt) FOR ecore::EClass")
- + tag("ENDDEFINE"));
- checkIsRule(file, "r_file", 2);
- CompositeNode expr = checkChildIsRule(file, 0, "r_definition", 8);
- checkChildIsToken(expr, 0, LGS);
- checkChildIsToken(expr, 1, "DEFINE");
- checkChildIsIdentifier(expr, 2, "test");
- checkChildIsToken(expr, 3, "FOR");
- checkChildIsScopedType(expr, 4, "ecore", "EClass");
- checkChildIsSequenceText(expr, 5, "", 1);
- checkChildIsToken(expr, 6, "ENDDEFINE");
- checkChildIsToken(expr, 7, RGS);
-
- CompositeNode expr1 = checkChildIsRule(file, 1, "r_definition", 11);
- checkChildIsToken(expr1, 0, LGS);
- checkChildIsToken(expr1, 1, "DEFINE");
- checkChildIsIdentifier(expr1, 2, "test2");
- checkChildIsToken(expr1, 3, "(");
- CompositeNode dpl = checkChildIsRule(expr1, 4,
- "r_declaredParameterList", 1);
- CompositeNode dp = checkChildIsRule(dpl, 0, "r_declaredParameter", 2);
- checkChildIsSimpleType(dp, 0, "String");
- checkChildIsIdentifier(dp, 1, "txt");
- checkChildIsToken(expr1, 5, ")");
- checkChildIsToken(expr1, 6, "FOR");
- checkChildIsScopedType(expr1, 7, "ecore", "EClass");
- checkChildIsSequenceText(expr1, 8, "", 1);
- checkChildIsToken(expr1, 9, "ENDDEFINE");
- checkChildIsToken(expr1, 10, RGS);
-
- }
-
- public final void testMoreComplexDefine() throws Exception {
- Node expr = parse(tag("DEFINE test(ecore::EPackage a,String b) FOR ecore::EClass")
- + tag("FILE name+\".txt\"")
- + "Text und so "
- + tag("name")
- + tag("FOREACH eAllAttributes AS attr")
- + "Attribute : "
- + tag("attr.name")
- + tag("ENDFOREACH")
- + tag("ENDFILE")
- + tag("ENDDEFINE"));
- checkIsRule(expr, "r_definition", 11);
- checkChildIsToken(expr, 0, LGS);
- checkChildIsToken(expr, 1, "DEFINE");
- checkChildIsIdentifier(expr, 2, "test");
- checkChildIsToken(expr, 3, "(");
- CompositeNode dpl = checkChildIsRule(expr, 4,
- "r_declaredParameterList", 3);
- CompositeNode dp0 = checkChildIsRule(dpl, 0, "r_declaredParameter", 2);
- checkChildIsScopedType(dp0, 0, "ecore", "EPackage");
- checkChildIsIdentifier(dp0, 1, "a");
- checkChildIsToken(dpl, 1, ",");
- CompositeNode dp = checkChildIsRule(dpl, 2, "r_declaredParameter", 2);
- checkChildIsSimpleType(dp, 0, "String");
- checkChildIsIdentifier(dp, 1, "b");
- checkChildIsToken(expr, 5, ")");
- checkChildIsToken(expr, 6, "FOR");
- checkChildIsScopedType(expr, 7, "ecore", "EClass");
- CompositeNode rs = checkChildIsSequenceText(expr, 8, "", 3);
- CompositeNode fs = checkChildIsRule(rs, 1, "r_fileStatement", 4);
- checkChildIsToken(fs, 0, "FILE");
- CompositeNode ae = checkChildIsRule(fs, 1, "r_additiveExpression", 3);
- checkChildIsSimpleType(ae, 0, "name");
- checkChildIsToken(ae, 1, "+");
- checkChildIsStringLiteral(ae, 2, "\".txt\"");
- CompositeNode s0 = checkChildIsSequenceText(fs, 2, "Text und so ", 5);
- CompositeNode es = checkChildIsRule(s0, 1, "r_expressionStmt", 1);
- checkChildIsSimpleType(es, 0, "name");
- checkChildIsText(s0, 2, "");
- CompositeNode fes = checkChildIsRule(s0, 3, "r_foreachStatement", 6);
- checkChildIsToken(fes, 0, "FOREACH");
- checkChildIsSimpleType(fes, 1, "eAllAttributes");
- checkChildIsToken(fes, 2, "AS");
- checkChildIsIdentifier(fes, 3, "attr");
- CompositeNode s1 = checkChildIsSequenceText(fes, 4, "Attribute : ", 3);
- CompositeNode es1 = checkChildIsRule(s1, 1, "r_expressionStmt", 1);
- CompositeNode ie = checkChildIsRule(es1, 0, "r_infixExpression", 3);
- checkChildIsSimpleType(ie, 0, "attr");
- checkChildIsToken(ie, 1, ".");
- checkChildIsSimpleType(ie, 2, "name");
- checkChildIsText(s1, 2, "");
- checkChildIsToken(fes, 5, "ENDFOREACH");
- checkChildIsText(s0, 4, "");
- checkChildIsToken(fs, 3, "ENDFILE");
- checkChildIsText(rs, 2, "");
- checkChildIsToken(expr, 9, "ENDDEFINE");
- checkChildIsToken(expr, 10, RGS);
- }
-
- public final void testImportDeclaration() throws Exception {
- Node expr = parse(tag("IMPORT org::eclipse::xtend")
- + tag("IMPORT org::eclipse::xtend::xpand")
- + tag("DEFINE test FOR ecore::EClass") + tag("ENDDEFINE"));
- checkIsRule(expr, "r_file", 3);
- CompositeNode i0 = checkChildIsRule(expr, 0, "r_nsImport", 4);
- checkChildIsToken(i0, 0, LGS);
- checkChildIsToken(i0, 1, "IMPORT");
- checkChildIsScopedType(i0, 2, "org", "eclipse", "xtend");
- checkChildIsToken(i0, 3, RGS);
-
- CompositeNode i1 = checkChildIsRule(expr, 1, "r_nsImport", 4);
- checkChildIsToken(i1, 0, LGS);
- checkChildIsToken(i1, 1, "IMPORT");
- checkChildIsScopedType(i1, 2, "org", "eclipse", "xtend", "xpand");
- checkChildIsToken(i1, 3, RGS);
-
- CompositeNode d = checkChildIsRule(expr, 2, "r_definition", 8);
- checkChildIsToken(d, 0, LGS);
- checkChildIsToken(d, 1, "DEFINE");
- checkChildIsIdentifier(d, 2, "test");
- checkChildIsToken(d, 6, "ENDDEFINE");
- checkChildIsToken(d, 7, RGS);
- }
-
- public final void testFileStatement() throws Exception {
- Node expr = parse(tag("DEFINE test FOR ecore::EClass")
- + tag("FILE \"test.txt\" ONCE") + tag("ENDFILE")
- + tag("ENDDEFINE"));
- checkIsRule(expr, "r_definition", 8);
- checkChildIsToken(expr, 0, LGS);
- checkChildIsToken(expr, 1, "DEFINE");
- checkChildIsIdentifier(expr, 2, "test");
- checkChildIsToken(expr, 3, "FOR");
- checkChildIsScopedType(expr, 4, "ecore", "EClass");
- CompositeNode s = checkChildIsSequenceText(expr, 5, "", 3);
- CompositeNode fs = checkChildIsRule(s, 1, "r_fileStatement", 5);
- checkChildIsToken(fs, 0, "FILE");
- checkChildIsStringLiteral(fs, 1, "\"test.txt\"");
- checkChildIsIdentifier(fs, 2, "ONCE");
- checkChildIsSequenceText(fs, 3, "", 1);
- checkChildIsToken(fs, 4, "ENDFILE");
- checkChildIsText(s, 2, "");
- checkChildIsToken(expr, 6, "ENDDEFINE");
- checkChildIsToken(expr, 7, RGS);
- }
-
- public final void testIfStatement() throws Exception {
- Node expr = parse(tag("DEFINE test FOR ecore::EClass")
- + tag("IF !true") + tag("ELSEIF false") + tag("ELSE")
- + tag("ENDIF") + tag("ENDDEFINE"));
- checkIsRule(expr, "r_definition", 8);
- checkChildIsToken(expr, 0, LGS);
- checkChildIsToken(expr, 1, "DEFINE");
- checkChildIsIdentifier(expr, 2, "test");
- checkChildIsToken(expr, 3, "FOR");
- checkChildIsScopedType(expr, 4, "ecore", "EClass");
- CompositeNode s = checkChildIsSequenceText(expr, 5, "", 3);
- CompositeNode is = checkChildIsRule(s, 1, "r_ifStatement", 6);
- checkChildIsToken(is, 0, "IF");
- CompositeNode ue = checkChildIsRule(is, 1, "r_unaryExpression", 2);
- checkChildIsToken(ue, 0, "!");
- checkChildIsTrueLiteral(ue, 1);
- checkChildIsSequenceText(is, 2, "", 1);
- CompositeNode eis = checkChildIsRule(is, 3, "r_elseIfStatement", 3);
- checkChildIsToken(eis, 0, "ELSEIF");
- checkChildIsFalseLiteral(eis, 1);
- checkChildIsSequenceText(eis, 2, "", 1);
- CompositeNode es = checkChildIsRule(is, 4, "r_elseStatement", 2);
- checkChildIsToken(es, 0, "ELSE");
- checkChildIsSequenceText(es, 1, "", 1);
- checkChildIsText(s, 2, "");
- checkChildIsToken(expr, 6, "ENDDEFINE");
- checkChildIsToken(expr, 7, RGS);
- }
-
- public void testLocation() throws Exception {
- String defineStart = tag("DEFINE test FOR ecore::EClass");
- String ifStmnt = tag("IF !true") + tag("ELSEIF false") + tag("ELSE")
- + tag("ENDIF");
- String string = defineStart + ifStmnt + tag("ENDDEFINE");
- CompositeNode expr = parse(string);
- assertEquals(0, expr.start());
- assertEquals(string.length(), expr.end());
-
- assertEquals(1, expr.getChildren().get(1).start());
- assertEquals(string.length() - 1, expr.getChildren().get(6).end());
-
- assertEquals(defineStart.length() - 1, expr.getChildren().get(5)
- .start());
- assertEquals(defineStart.length() + ifStmnt.length() + 1, expr
- .getChildren().get(5).end());
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/SyntaxUtil.java b/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/SyntaxUtil.java
deleted file mode 100644
index 645b728..0000000
--- a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/SyntaxUtil.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.eclipse.xpand3.parser;
-
-public class SyntaxUtil {
- public static final String LG = "\u00AB";
- public static final String RG = "\u00BB";
-}
diff --git a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/Xpand3MigratedNodeParserTest.java b/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/Xpand3MigratedNodeParserTest.java
deleted file mode 100644
index cd20dba..0000000
--- a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/Xpand3MigratedNodeParserTest.java
+++ /dev/null
@@ -1,195 +0,0 @@
-package org.eclipse.xpand3.parser;
-
-
-
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.CommonTokenStream;
-import org.eclipse.xpand3.node.CompositeNode;
-import org.eclipse.xpand3.node.Node;
-import org.eclipse.xpand3.node.NodeUtil;
-
-public class Xpand3MigratedNodeParserTest extends AbstractXpand3NodeParserTest {
-
- public final void testSimple() throws Exception {
- CompositeNode parse = parse("true == null");
- CompositeNode cn = checkIsRule(parse, "r_relationalExpression", 3);
- checkChildIsTrueLiteral(cn, 0);
- checkChildIsToken(cn, 1, "==");
- CompositeNode nl = checkChildIsRule(cn, 2, "r_nullLiteral", 1);
- checkChildIsToken(nl, 0, "null");
- }
-
- public final void testSimple2() throws Exception {
- CompositeNode ie = checkIsRule(
- parse("String.feature.test(true,{\"test\",\"hallo\"})"),
- "r_infixExpression", 5);
- checkChildIsSimpleType(ie, 0, "String");
- checkChildIsToken(ie, 1, ".");
- checkChildIsSimpleType(ie, 2, "feature");
- checkChildIsToken(ie, 3, ".");
- CompositeNode fc = checkChildIsRule(ie, 4, "r_featureCall", 4);
- checkChildIsIdentifier(fc, 0, "test");
- checkChildIsToken(fc, 1, "(");
- CompositeNode pl = checkChildIsRule(fc, 2, "r_parameterList", 3);
- checkChildIsTrueLiteral(pl, 0);
- checkChildIsToken(pl, 1, ",");
- CompositeNode ll = checkChildIsRule(pl, 2, "r_listLiteral", 5);
- checkChildIsToken(ll, 0, "{");
- checkChildIsStringLiteral(ll, 1, "\"test\"");
- checkChildIsToken(ll, 2, ",");
- checkChildIsStringLiteral(ll, 3, "\"hallo\"");
- checkChildIsToken(ll, 4, "}");
- checkChildIsToken(fc, 3, ")");
- }
-
- public final void testIfExpression() throws Exception {
- CompositeNode expr = parse("(client.sIdent1 != null) ? client.sIdent1 : \"XXXXXXXX\"");
- CompositeNode ie = checkIsRule(expr, "r_ifExpression", 5);
- CompositeNode pe = checkChildIsRule(ie, 0, "r_paranthesizedExpression",
- 3);
- checkChildIsToken(pe, 0, "(");
- CompositeNode re = checkChildIsRule(pe, 1, "r_relationalExpression", 3);
- CompositeNode ie0 = checkChildIsRule(re, 0, "r_infixExpression", 3);
- checkChildIsSimpleType(ie0, 0, "client");
- checkChildIsToken(ie0, 1, ".");
- checkChildIsSimpleType(ie0, 2, "sIdent1");
- checkChildIsToken(re, 1, "!=");
- CompositeNode nl = checkChildIsRule(re, 2, "r_nullLiteral", 1);
- checkChildIsToken(nl, 0, "null");
- checkChildIsToken(pe, 2, ")");
- checkChildIsToken(ie, 1, "?");
- CompositeNode ie1 = checkChildIsRule(ie, 2, "r_infixExpression", 3);
- checkChildIsSimpleType(ie1, 0, "client");
- checkChildIsToken(ie1, 1, ".");
- checkChildIsSimpleType(ie1, 2, "sIdent1");
- checkChildIsToken(ie, 3, ":");
- checkChildIsStringLiteral(ie, 4, "\"XXXXXXXX\"");
- }
-
- public void testIfExpression2() throws Exception {
- Node expr = parse("if true then true else false");
- checkIsRule(expr, "r_ifExpression", 6);
- checkChildIsToken(expr, 0, "if");
- checkChildIsTrueLiteral(expr, 1);
- checkChildIsToken(expr, 2, "then");
- checkChildIsTrueLiteral(expr, 3);
- checkChildIsToken(expr, 4, "else");
- checkChildIsFalseLiteral(expr, 5);
- }
-
- public final void testEscaped() throws Exception {
- Node expr = parse("\"\\\"\"");
- checkIsRule(expr, "r_stringLiteral", 1);
- checkChildIsToken(expr, 0, "\"\\\"\"");
- }
-
- public final void testNot() throws Exception {
- Node expr = parse("! ts.checked");
- checkIsRule(expr, "r_unaryExpression", 2);
- checkChildIsToken(expr, 0, "!");
- }
-
- public final void testCast() throws Exception {
- Node expr = parse("(List[InnerType]) anExpr");
- checkIsRule(expr, "r_castedExpression", 4);
- checkChildIsToken(expr, 0, "(");
- CompositeNode ct = checkChildIsRule(expr, 1, "r_collectionType", 4);
- checkChildIsToken(ct, 0, "List");
- checkChildIsToken(ct, 1, "[");
- checkChildIsSimpleType(ct, 2, "InnerType");
- checkChildIsToken(ct, 3, "]");
- checkChildIsToken(expr, 2, ")");
- checkChildIsSimpleType(expr, 3, "anExpr");
- }
-
- public final void testSwitch() throws Exception {
- Node expr = parse("switch { default : true }");
- checkIsRule(expr, "r_switchExpression", 6);
- checkChildIsToken(expr, 0, "switch");
- checkChildIsToken(expr, 1, "{");
- checkChildIsToken(expr, 2, "default");
- checkChildIsToken(expr, 3, ":");
- checkChildIsTrueLiteral(expr, 4);
- checkChildIsToken(expr, 5, "}");
-
- }
-
- public final void testChainExpression() throws Exception {
- Node expr = parse("1 -> 2 -> 3 -> 4");
- checkIsRule(expr, "r_chainExpression", 7);
- checkChildIsNumberLiteral(expr, 0, "1");
- checkChildIsToken(expr, 1, "->");
- checkChildIsNumberLiteral(expr, 2, "2");
- checkChildIsToken(expr, 3, "->");
- checkChildIsNumberLiteral(expr, 4, "3");
- checkChildIsToken(expr, 5, "->");
- checkChildIsNumberLiteral(expr, 6, "4");
- }
-
- public final void testPositionInfo() throws Exception {
- Node expr = parse("\n\n\n1");
- assertEquals(4, expr.line());
- assertEquals(3, expr.start());
- assertEquals(4, expr.end());
- }
-
- public final void testPositionInfo2() throws Exception {
- Node exp = parse("/*\n\n\n*/1");
- assertEquals(4, exp.line());
- assertEquals(7, exp.start());
- assertEquals(8, exp.end());
- }
-
- public final void testPositionInfo3() throws Exception {
- Node expr = parse("'/*\n\n\n*/'+1");
- assertEquals(1, expr.line());
- assertEquals(0, expr.start());
- assertEquals(11, expr.end());
- checkIsRule(expr, "r_additiveExpression", 3);
- CompositeNode sl = checkChildIsStringLiteral(expr, 0, "'/*\n\n\n*/'");
- assertEquals(1, sl.line());
- assertEquals(0, sl.start());
- assertEquals(9, sl.end());
- checkChildIsToken(expr, 1, "+");
- CompositeNode il = checkChildIsNumberLiteral(expr, 2, "1");
- assertEquals(4, il.line());
- assertEquals(10, il.start());
- assertEquals(11, il.end());
- }
-
- public final void testTypeLiterals() throws Exception {
- Node expr = parse("{" + " Object,\n" + " String,\n" + "Collection,\n"
- + " Set,\n" + " List,\n" + " oaw::Type,\n" + " oaw::Feature,\n"
- + " oaw::Property\n}");
- checkIsRule(expr, "r_listLiteral", 17);
- checkChildIsToken(expr, 0, "{");
- checkChildIsSimpleType(expr, 1, "Object");
- checkChildIsToken(expr, 2, ",");
- checkChildIsSimpleType(expr, 3, "String");
- checkChildIsToken(expr, 4, ",");
- checkChildIsCollectionType(expr, 5, "Collection");
- checkChildIsToken(expr, 6, ",");
- checkChildIsCollectionType(expr, 7, "Set");
- checkChildIsToken(expr, 8, ",");
- checkChildIsCollectionType(expr, 9, "List");
- checkChildIsToken(expr, 10, ",");
- checkChildIsScopedType(expr, 11, "oaw", "Type");
- checkChildIsToken(expr, 12, ",");
- checkChildIsScopedType(expr, 13, "oaw", "Feature");
- checkChildIsToken(expr, 14, ",");
- checkChildIsScopedType(expr, 15, "oaw", "Property");
- checkChildIsToken(expr, 16, "}");
- }
-
- private CompositeNode parse(String s) throws Exception {
- ANTLRStringStream stream = new ANTLRStringStream(s);
- Xpand3Lexer lexer = new Xpand3Lexer(stream);
- CommonTokenStream tokenStream = new CommonTokenStream(lexer);
- AbstractXpand3NodeParser xpand3NodeParser = new Xpand3NodeParser(
- tokenStream);
- xpand3NodeParser.test_expression();
- Node rootNode = xpand3NodeParser.getRootNode();
- System.out.println(NodeUtil.toString(rootNode));
- return (CompositeNode) rootNode;
- }
-}
diff --git a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/Xpand3NodeParserTest.java b/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/Xpand3NodeParserTest.java
deleted file mode 100644
index 43d0895..0000000
--- a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/Xpand3NodeParserTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.eclipse.xpand3.parser;
-
-import junit.framework.TestCase;
-
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.CommonTokenStream;
-import org.eclipse.xpand3.node.Node;
-import org.eclipse.xpand3.node.NodeUtil;
-import static org.eclipse.xpand3.parser.SyntaxUtil.*;
-
-public class Xpand3NodeParserTest extends TestCase {
-
- private Node parse(String s) throws Exception {
- Xpand3NodeParser parser = createParser(s);
- parser.r_file();
- return parser.getRootNode();
- }
-
- public void testname() throws Exception {
- Node x = parse(LG + "IMPORT foo" + RG
- + "import foo; myFunction(String this) : doStuff('holla');"
- + LG + "DEFINE foo FOR Entity" + RG + "bla" + LG + "ENDDEFINE"
- + RG);
- System.out.println(NodeUtil.toString(x));
- }
-
- public void testFoo() throws Exception {
- Node node = parse("import foo; myFunction(String this) : doStuff('holla');");
- System.out.println(NodeUtil.toString(node));
- System.out.println(NodeUtil.serialize(node));
- }
-
- public void testXpandXtendCheckMixedUp1() throws Exception {
- Node node = parse(LG + "IMPORT foo" + RG
- + "import foo; myFunction(String this) : doStuff('holla');"
- + LG + "DEFINE foo FOR Entity" + RG + "bla" + LG + "ENDDEFINE"
- + RG);
- System.out.println(NodeUtil.toString(node));
- System.out.println(NodeUtil.serialize(node));
- }
-//
- public void testPerf() throws Exception {
- String s = "foo.bar.honolulu('lola',{true,false,45}).collect(e|2.minor + 34 / (x - 2))";
- for (int i = 0; i<10;i++) {
- s = s+" -> "+s;
- }
- Xpand3Parser parser = createParser(s);
- long n = System.currentTimeMillis();
- parser.r_expression();
- long after = System.currentTimeMillis();
- System.out.println("Time : "+(after-n)/1000.+" Expressionlength was : "+s.length());
- }
-
- private Xpand3NodeParser createParser(String s) {
- ANTLRStringStream stream = new ANTLRStringStream(s);
- Xpand3Lexer lexer = new Xpand3Lexer(stream);
- CommonTokenStream tokenStream = new CommonTokenStream(lexer);
- Xpand3NodeParser parser = new Xpand3NodeParser(tokenStream);
- return parser;
- }
-}
diff --git a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/Xpand3ScannerTest.java b/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/Xpand3ScannerTest.java
deleted file mode 100644
index f16d83e..0000000
--- a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/Xpand3ScannerTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 committers of openArchitectureWare and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * committers of openArchitectureWare - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.xpand3.parser;
-
-import junit.framework.TestCase;
-
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.RecognitionException;
-
-/**
- * @author Sven Efftinge (http://www.efftinge.de)
- * @author Arno Haase
- */
-public class Xpand3ScannerTest extends TestCase {
-
- public Xpand3Lexer scan(final String txt) {
- return new Xpand3Lexer(new ANTLRStringStream(txt)) {
- @Override
- public void reportError(RecognitionException e) {
- throw new RuntimeException(e);
- }
- };
- }
-
- public final void testString() throws Exception {
- test("\"test\"");
- test("\"test\"");
- test("\"te\nst\"");
- test("\"te\\nst\"");
- test("'test'");
- test("'test'");
- test("'te\nst'");
- test("'te\\nst'");
- try {
- test("'unterminated");
- fail();
- } catch (final Exception e) {
- // expected
- }
- }
-
- public void testIdentifier() throws Exception {
- System.out.println(scan("sortBy").nextToken().getType());
- System.out.println(scan("^sortBy").nextToken().getType());
- }
-
- private void test(final String txt) throws Exception {
- assertEquals(txt, scan(txt).nextToken().getText());
- }
-}
diff --git a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/XpandLexerTest.java b/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/XpandLexerTest.java
deleted file mode 100644
index 9b884f2..0000000
--- a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/parser/XpandLexerTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 committers of openArchitectureWare and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * committers of openArchitectureWare - initial API and implementation
- *******************************************************************************/
-package org.eclipse.xpand3.parser;
-
-import java.util.List;
-
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.CommonToken;
-import org.antlr.runtime.CommonTokenStream;
-
-public class XpandLexerTest extends AbstractXpand3NodeParserTest {
-
- public void testComments() throws Exception {
- String toScan = tag("REM") + "foo" + tag("DEFINE") + "'//" + LG
- + "ENDRE" + tag("ENDREM");
- System.out.println(toScan);
- Xpand3Lexer l = new Xpand3Lexer(new ANTLRStringStream(toScan));
- CommonTokenStream stream = new CommonTokenStream(l);
- List<CommonToken> tokens = stream.getTokens();
- assertEquals(1, tokens.size());
- assertEquals(Xpand3Lexer.REM_COMMENT_OUT, tokens.get(0).getType());
- }
-}