public void testConstructor2AttributesAnd() { String statement = "Company with 1 as id and \"IBM\" as name"; ETestParser parser = new ETestParser(statement, false); ConstructorExpression c = parser.parse_constructor_expression(); Assert.IsNotNull(c); ArgumentList l = c.getArguments(); Assert.IsNotNull(l); Assert.AreEqual(2, l.Count); Argument a = l[0]; Assert.IsNotNull(a); Assert.AreEqual("id", a.GetName()); IExpression e = a.getExpression(); Assert.IsNotNull(e); Assert.IsTrue(e is IntegerLiteral); a = l[1]; Assert.IsNotNull(a); Assert.AreEqual("name", a.GetName()); e = a.getExpression(); Assert.IsNotNull(e); Assert.IsTrue(e is TextLiteral); }
public void testMethodCallExpression() { String statement = "print \"person\" + p.name"; ETestParser parser = new ETestParser(statement, false); UnresolvedCall ac = parser.parse_method_call(); Assert.IsNotNull(ac); }
public void testConstructorFrom1Attribute() { String statement = "Company from entity with 1 as id"; ETestParser parser = new ETestParser(statement, false); ConstructorExpression c = parser.parse_constructor_expression(); Assert.IsNotNull(c); }
public void testNativeJava() { String statement = "Java: System.out.println(value);"; ETestParser parser = new ETestParser(statement, false); NativeCall call = parser.parse_native_statement(); Assert.IsNotNull(call); Assert.IsTrue(call is NativeCall); }
public void testAssignmentConstructor() { String statement = "c = Company from x with 1 as id and \"IBM\" as name"; ETestParser parser = new ETestParser(statement, false); AssignInstanceStatement a = parser.parse_assign_instance_statement(); Assert.IsNotNull(a); Assert.IsTrue(a.getExpression() is ConstructorExpression); }
public void testMethodWith() { String statement = "print \"a\" with \"1\" as value"; ETestParser parser = new ETestParser(statement, false); IStatement stmt = parser.parse_statement(); Assert.IsNotNull(stmt); Assert.AreEqual(statement, generate(stmt)); }
public void testList2ArgumentsAnd() { String statement = "Person p and Employee e"; ETestParser parser = new ETestParser(statement, false); ParameterList l = parser.parse_argument_list(); Assert.IsNotNull(l); Assert.AreEqual(2, l.Count); }
public void testNativeCSharp() { String statement = "C#: Console.println(value);"; ETestParser parser = new ETestParser(statement, false); NativeCall call = parser.parse_native_statement(); Assert.IsNotNull(call); Assert.IsTrue(call is NativeCall); }
public void testArrayAttribute() { String statement = "define id as Integer[] attribute"; ETestParser parser = new ETestParser(statement, false); AttributeDeclaration ad = parser.parse_attribute_declaration(); Assert.IsNotNull(ad); Assert.AreEqual("id", ad.GetName()); Assert.AreEqual("Integer[]", ad.getIType().GetTypeName()); }
public void testNativeSymbol() { String statement = "ENTITY_1 with \"1\" as value"; ETestParser parser = new ETestParser(statement, false); IExpression symbol = parser.parse_native_symbol(); Assert.IsNotNull(symbol); Assert.IsTrue(symbol is NativeSymbol); Assert.AreEqual(statement, generate(symbol)); }
public void testEmptyDictLiteral() { String statement = "<:>"; ETestParser parser = new ETestParser(statement, false); IExpression literal = parser.parse_literal_expression(); Assert.IsNotNull(literal); Assert.IsTrue(literal is DictLiteral); Assert.AreEqual("<:>", literal.ToString()); }
public void testSimpleDictLiteral() { String statement = "< \"john\" : 1234, eric : 5678 >"; ETestParser parser = new ETestParser(statement, false); IExpression literal = parser.parse_literal_expression(); Assert.IsNotNull(literal); Assert.IsTrue(literal is DictLiteral); Assert.AreEqual("<\"john\":1234, eric:5678>", generate(literal)); }
public void testArgument() { String statement = "Person p"; ETestParser parser = new ETestParser(statement, false); ITypedParameter a = parser.parse_typed_argument(); Assert.IsNotNull(a); Assert.AreEqual("Person", a.getType().GetTypeName()); Assert.AreEqual("p", a.GetName()); }
public void testRange() { String statement = "[1..100]"; ETestParser parser = new ETestParser(statement, false); RangeLiteral rl = parser.parse_range_literal(); Assert.IsNotNull(rl); Assert.AreEqual("1", rl.getFirst().ToString()); Assert.AreEqual("100", rl.getLast().ToString()); Assert.AreEqual("[1..100]", generate(rl)); }
public void testPeriod() { String statement = "'P3Y'"; ETestParser parser = new ETestParser(statement, false); IExpression literal = parser.parse_literal_expression(); Assert.IsNotNull(literal); Assert.IsTrue(literal is PeriodLiteral); Assert.AreEqual("'P3Y'", generate(literal)); Assert.AreEqual(3, ((PeriodLiteral)literal).getValue().Years); }
public void testDateTimeWithMillis() { String statement = "'2012-10-09T15:18:17.487Z'"; ETestParser parser = new ETestParser(statement, false); IExpression literal = parser.parse_literal_expression(); Assert.IsNotNull(literal); Assert.IsTrue(literal is DateTimeLiteral); Assert.AreEqual("'2012-10-09T15:18:17.487Z'", literal.ToString()); Assert.AreEqual(new DateTimeValue(2012, 10, 9, 15, 18, 17, 487), ((DateTimeLiteral)literal).getValue()); }
public void testStringLiteral() { String statement = "\"hello\""; ETestParser parser = new ETestParser(statement, false); IExpression literal = parser.parse_literal_expression(); Assert.IsNotNull(literal); Assert.IsTrue(literal is TextLiteral); Assert.AreEqual("\"hello\"", generate(literal)); Assert.AreEqual("hello", ((TextLiteral)literal).getValue().Value); }
public void testSimpleDate() { String statement = "'2012-10-09'"; ETestParser parser = new ETestParser(statement, false); IExpression literal = parser.parse_literal_expression(); Assert.IsNotNull(literal); Assert.IsTrue(literal is DateLiteral); Assert.AreEqual("'2012-10-09'", generate(literal)); Assert.AreEqual(new DateValue(2012, 10, 9), ((DateLiteral)literal).getValue()); }
public void testSimpleTime() { String statement = "'15:03:10'"; ETestParser parser = new ETestParser(statement, false); IExpression literal = parser.parse_literal_expression(); Assert.IsNotNull(literal); Assert.IsTrue(literal is TimeLiteral); Assert.AreEqual("'15:03:10'", literal.ToString()); Assert.AreEqual(new TimeValue(15, 03, 10, 0), ((TimeLiteral)literal).getValue()); }
public void testEmptyListLiteral() { String statement = "[]"; ETestParser parser = new ETestParser(statement, false); IExpression literal = parser.parse_literal_expression(); Assert.IsNotNull(literal); Assert.IsTrue(literal is ListLiteral); Assert.AreEqual("[]", literal.ToString()); Assert.AreEqual(0, ((ListLiteral)literal).getValue().Count); }
public void testDecimalLiteral() { String statement = "1234.13"; ETestParser parser = new ETestParser(statement, false); IExpression literal = parser.parse_literal_expression(); Assert.IsNotNull(literal); Assert.IsTrue(literal is DecimalLiteral); Assert.AreEqual("1234.13", generate(literal)); Assert.AreEqual(1234.13, ((DecimalLiteral)literal).getValue().DoubleValue, 0.0000001); }
public void testHexaLiteral() { String statement = "0x0A11"; ETestParser parser = new ETestParser(statement, false); IExpression literal = parser.parse_literal_expression(); Assert.IsNotNull(literal); Assert.IsTrue(literal is HexaLiteral); Assert.AreEqual("0x0A11", generate(literal)); Assert.AreEqual(0x0A11, ((HexaLiteral)literal).getValue().LongValue); }
public void testIntegerLiteral() { String statement = "1234"; ETestParser parser = new ETestParser(statement, false); IExpression literal = parser.parse_literal_expression(); Assert.IsNotNull(literal); Assert.IsTrue(literal is IntegerLiteral); Assert.AreEqual("1234", literal.ToString()); Assert.AreEqual(1234, ((IntegerLiteral)literal).getValue().LongValue); }
public void testSimpleArgumentAssignment() { String statement = "p.name as value"; ETestParser parser = new ETestParser(statement, false); Argument ars = parser.parse_argument_assignment(); Assert.AreEqual("value", ars.GetName()); IExpression exp = ars.getExpression(); Assert.IsNotNull(exp); Assert.AreEqual("p.name as value", generate(ars)); }
public void testComplexArgumentAssignment() { String statement = "\"person\" + p.name as value"; ETestParser parser = new ETestParser(statement, false); Argument ars = parser.parse_argument_assignment(); Assert.AreEqual("value", ars.GetName()); IExpression exp = ars.getExpression(); Assert.IsTrue(exp is PlusExpression); Assert.AreEqual("\"person\" + p.name as value", generate(ars)); }
public void testNativeMethod() { String statement = "define print as native method receiving String value doing:\r\n" + "\tJava: System.str.println(value); \r\n" + "\tC#: Console.println(value); "; ETestParser parser = new ETestParser(statement, false); NativeMethodDeclaration method = parser.parse_native_method_declaration(); Assert.IsNotNull(method); Assert.IsTrue(method is NativeMethodDeclaration); }
public void testCategory1Attribute() { String statement = "define Person as category with attribute id "; ETestParser parser = new ETestParser(statement, false); CategoryDeclaration cd = parser.parse_category_declaration(); Assert.IsNotNull(cd); Assert.AreEqual("Person", cd.GetName()); Assert.IsNull(cd.getDerivedFrom()); Assert.IsNotNull(cd.GetLocalAttributes()); Assert.IsTrue(cd.GetLocalAttributes().Contains("id")); }
public void testCategory2DerivedNoAttribute() { String statement = "define Entrepreneur as Person and Company"; ETestParser parser = new ETestParser(statement, false); CategoryDeclaration cd = parser.parse_category_declaration(); Assert.IsNotNull(cd); Assert.AreEqual("Entrepreneur", cd.GetName()); Assert.IsNotNull(cd.getDerivedFrom()); Assert.IsTrue(cd.getDerivedFrom().Contains("Person")); Assert.IsTrue(cd.getDerivedFrom().Contains("Company")); Assert.IsNull(cd.GetLocalAttributes()); }
public void testTuple() { String statement = "(1,\"John\",'12:12:12')"; ETestParser parser = new ETestParser(statement, false); TupleLiteral literal = parser.parse_tuple_literal(); Assert.IsNotNull(literal); ExpressionList list = ((TupleLiteral)literal).Expressions; Assert.AreEqual("1", list[0].ToString()); Assert.AreEqual("\"John\"", list[1].ToString()); Assert.AreEqual("'12:12:12'", list[2].ToString()); Assert.AreEqual("1, \"John\", '12:12:12'", list.ToString()); }
public void testMethod1Parameter1Statement() { String statement = "define printName as method receiving Person p doing:\r\n" + "\tprint with \"person\" + p.name as value"; ETestParser parser = new ETestParser(statement, false); ConcreteMethodDeclaration ad = parser.parse_concrete_method_declaration(); Assert.IsNotNull(ad); Assert.AreEqual("printName", ad.GetName()); Assert.IsNotNull(ad.getParameters()); Assert.IsTrue(ad.getParameters().Contains(new CategoryParameter(new CategoryType("Person"), "p"))); Assert.IsNotNull(ad.getStatements()); Assert.AreEqual("print with \"person\" + p.name as value", generate(ad.getStatements()[0])); }