use of org.eclipse.xtext.example.arithmetics.arithmetics.Statement in project xtext-eclipse by eclipse.
the class CalculatorTest method check.
protected void check(final double expected, final String expression) throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("module test ");
_builder.append(expression);
final org.eclipse.xtext.example.arithmetics.arithmetics.Module module = this.parseHelper.parse(_builder);
BigDecimal result = this.calculator.evaluate(IterableExtensions.<Expression>head(Iterables.<Expression>filter(IterableExtensions.<Statement>head(module.getStatements()).eContents(), Expression.class)));
Assert.assertEquals(expected, result.doubleValue(), 0.0001);
}
use of org.eclipse.xtext.example.arithmetics.arithmetics.Statement in project xtext-eclipse by eclipse.
the class CalculatorTest method evaluatesTo.
private void evaluatesTo(CharSequence content, double expected) throws Exception {
Module module = parseHelper.parse("module test " + content);
Statement firstStatement = module.getStatements().get(0);
Iterable<Expression> expressions = Iterables.filter(firstStatement.eContents(), Expression.class);
Expression expression = Iterables.getFirst(expressions, null);
BigDecimal result = calculator.evaluate(expression);
Assert.assertEquals(expected, result.doubleValue(), 0.0001);
}
Aggregations