Exemple #1
0
        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());
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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());
        }
Exemple #5
0
        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());
        }
Exemple #6
0
        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());
        }
Exemple #7
0
        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);
        }
Exemple #8
0
        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);
        }
Exemple #9
0
        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);
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        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);
        }
Exemple #12
0
        public void testDateTimeWithTZ()
        {
            String      statement = "'2012-10-09T15:18:17+02:00'";
            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+02:00'", literal.ToString());
            TimeSpan      offset   = new TimeSpan(2, 0, 0);
            DateTimeValue expected = new DateTimeValue(2012, 10, 9, 15, 18, 17, 0, offset);
            DateTimeValue actual   = ((DateTimeLiteral)literal).getValue();

            Assert.IsTrue(expected.Equals(actual));
        }
Exemple #13
0
        public void testSimpleListLiteral()
        {
            String      statement = "[ john, 123 ]";
            ETestParser parser    = new ETestParser(statement, false);
            IExpression literal   = parser.parse_literal_expression();

            Assert.IsNotNull(literal);
            Assert.AreEqual("[john, 123]", literal.ToString());
            Assert.IsTrue(literal is ListLiteral);
            ExpressionList list = ((ListLiteral)literal).Expressions;

            Assert.AreEqual(2, list.Count);
            Assert.IsTrue(list[0] is UnresolvedIdentifier);
            Assert.IsTrue(list[1] is IntegerLiteral);
        }
Exemple #14
0
        public void testBooleanLiteral()
        {
            String      statement = "true";
            ETestParser parser    = new ETestParser(statement, false);
            IExpression literal   = parser.parse_literal_expression();

            Assert.IsNotNull(literal);
            Assert.IsTrue(literal is BooleanLiteral);
            Assert.AreEqual("true", literal.ToString());
            Assert.AreEqual(true, ((BooleanLiteral)literal).getValue().Value);
            statement = "false";
            parser    = new ETestParser(statement, false);
            literal   = parser.parse_literal_expression();
            Assert.IsNotNull(literal);
            Assert.IsTrue(literal is BooleanLiteral);
            Assert.AreEqual("false", literal.ToString());
            Assert.AreEqual(false, ((BooleanLiteral)literal).getValue().Value);
        }