Ejemplo n.º 1
0
        public void JsFormatter_AssignmentExpression()
        {
            var expr = new JsBinaryExpression(new JsAssignmentExpression(new JsIdentifierExpression("a"), new JsIdentifierExpression("c")), BinaryOperatorType.Equal, new JsIdentifierExpression("b"));

            Assert.AreEqual("(a=c)==b", expr.FormatScript());
            Assert.AreEqual("(a = c) == b", expr.FormatScript(niceMode: true));
        }
Ejemplo n.º 2
0
        public void JsFormatter_LessThanOperator()
        {
            var expr = new JsBinaryExpression(
                new JsIdentifierExpression("a"),
                BinaryOperatorType.LessOrEqual,
                new JsIdentifierExpression("b"));

            Assert.AreEqual("a<=b", expr.FormatScript());
            Assert.AreEqual("a <= b", expr.FormatScript(niceMode: true));
        }
Ejemplo n.º 3
0
        public void JsFormatter_KeywordUnaryExpression()
        {
            var expr = new JsBinaryExpression(
                new JsIdentifierExpression("a").Unary(UnaryOperatorType.TypeOf),
                BinaryOperatorType.Plus,
                new JsLiteral(0).Unary(UnaryOperatorType.Void).Unary(UnaryOperatorType.Minus));

            Assert.AreEqual("typeof a+-void 0", expr.FormatScript());
            Assert.AreEqual("typeof a + -void 0", expr.FormatScript(niceMode: true));
        }
Ejemplo n.º 4
0
        public void JsFormatter_UnaryExpression()
        {
            var expr = new JsBinaryExpression(
                new JsIdentifierExpression("a").Unary(UnaryOperatorType.Increment, isPrefix: false),
                BinaryOperatorType.Plus,
                new JsIdentifierExpression("a").Unary(UnaryOperatorType.Increment, isPrefix: true))
                       .Unary(UnaryOperatorType.LogicalNot);

            Assert.AreEqual("!(a++ + ++a)", expr.FormatScript());
            Assert.AreEqual("!(a++ + ++a)", expr.FormatScript(niceMode: true));
        }