This commit is contained in:
sefftinge 2008-09-25 17:31:34 +00:00 committed by sefftinge
parent 5bd40ce160
commit eefbddaed2
2 changed files with 44 additions and 61 deletions

View file

@ -19,60 +19,59 @@ import org.eclipse.xtext.util.EmfFormater;
import org.eclipse.xtext.xtext2ecore.EcoreModelComparator;
public class ComplexReconstrTest extends AbstractGeneratorTest {
@Override
protected void setUp() throws Exception {
super.setUp();
with(ComplexReconstrTestStandaloneSetup.class);
}
public void testPrintGrammar() {
ResourceSet rs = new XtextResourceSet();
URI u = URI.createURI("classpath:/org/eclipse/xtext/parsetree/reconstr/ComplexReconstrTest.xmi");
URI u = URI
.createURI("classpath:/org/eclipse/xtext/parsetree/reconstr/ComplexReconstrTest.xmi");
EObject o = rs.getResource(u, true).getContents().get(0);
for(Object x : o.eContents()) if(x instanceof ParserRule) {
ParserRule pr = (ParserRule) x;
if(pr.getName().toLowerCase().contains("tricky")){
System.out.println(EmfFormater.objToStr(pr, ""));
for (Object x : o.eContents())
if (x instanceof ParserRule) {
ParserRule pr = (ParserRule) x;
if (pr.getName().toLowerCase().contains("tricky")) {
System.out.println(EmfFormater.objToStr(pr, ""));
}
}
}
}
// FIXME: Make this test work again
// public void testSimple() throws Exception {
// String model = "( a + b - c ) !";
// assertEquals(model,parseAndSerialize(model));
// }
// FIXME: Make this test work again
// public void testComplex() throws Exception {
// String model = "( ( a + b ) ! - c + d + e + f - ( x + s ) - ( ( a + b ) ! - c ) ! ) !";
// assertEquals(model,parseAndSerialize(model));
// }
public void testSimple() throws Exception {
String model = "( a + b - c ) !";
assertEquals(model, parseAndSerialize(model));
}
public void testComplex() throws Exception {
String model = "( ( a + b ) ! - c + d + e + f - ( ^x + s ) - ( ( a + b ) ! - c ) ! ) !";
assertEquals(model, parseAndSerialize(model));
}
private String parseAndSerialize(String model) throws Exception {
EObject result = (EObject) getModel(model);
System.out.println(EmfFormater.objToStr(result, ""));
IParseTreeConstructor con = getParseTreeConstructor();
WhitespacePreservingCallback callback = new WhitespacePreservingCallback(getValueConverterService());
con.update(result,callback);
WhitespacePreservingCallback callback = new WhitespacePreservingCallback(
getValueConverterService());
con.update(result, callback);
return callback.toString();
}
// FIXME: Make this test work again
// public void testNormalizableCompositeNodesIncluded() throws Exception {
// reconstructAndCompare("a");
// reconstructAndCompare("a + b");
// }
private void reconstructAndCompare(String mymodel) throws Exception, InterruptedException {
public void testNormalizableCompositeNodesIncluded() throws Exception {
reconstructAndCompare("a");
reconstructAndCompare("a + b");
}
private void reconstructAndCompare(String mymodel) throws Exception,
InterruptedException {
EObject model = getModel(mymodel);
EObject model2 = getModel(parseAndSerialize(mymodel));
EcoreModelComparator ecoreModelComparator = new EcoreModelComparator();
assertFalse(ecoreModelComparator.modelsDiffer(model, model2));
}
}

View file

@ -25,14 +25,15 @@ public class SimpleReconstrTest extends AbstractGeneratorTest {
String model = "( a b ) !";
assertEquals(model, parseAndSerialize(model));
}
// FIXME: Make this test work again
// FIXME: make this work again
// public void testFollowingHiddenTokens() throws Exception {
// String model = "a ";
// assertEquals(model, parseAndSerialize(model));
// }
// FIXME: Make this test work again
// FIXME: make this work again
// public void testComplex() throws Exception {
// String model = "( ( a b ) ! c d e f ( x s ) ( \t ( a \n\rb/*ffo \n bar */ ) ! c ) ! ) //holla\n!";
@ -49,38 +50,21 @@ public class SimpleReconstrTest extends AbstractGeneratorTest {
return callback.toString();
}
public void recursionTest() {
rec(1);
public void testSimpleExpressions5() throws Exception {
with(SimpleExpressionsStandaloneSetup.class);
String model = "a + b - c * d / e";
assertEquals(model, parseAndSerialize(model));
}
private void rec(int i) {
// max1: 345957
String xxx = "lala";
xxx += "y";
System.out.println(i);
rec(i + 1);
public void testSimpleExpressions1() throws Exception {
with(SimpleExpressionsStandaloneSetup.class);
String model = "a + b - c";
assertEquals(model, parseAndSerialize(model));
}
// FIXME: Make this test work again
// public void testSimpleExpressions5() throws Exception {
// with(SimpleExpressionsStandaloneSetup.class);
// String model = "a + b - c * d / e";
// assertEquals(model, parseAndSerialize(model));
// }
// FIXME: Make this test work again
// public void testSimpleExpressions1() throws Exception {
// with(SimpleExpressionsStandaloneSetup.class);
// String model = "a + b - c";
// assertEquals(model, parseAndSerialize(model));
// }
public void testSimpleTwoNumbers() throws Exception {
String model = "2 45";
assertEquals(model, parseAndSerialize(model));
}
public void testSimpleManyStrings1() throws Exception {