예제 #1
0
        public void LoopStatementProducesLoopWithAllTheBellsAndWhistlesThroughProperties()
        {
            var a = JS.Id("a");
            var initialization = JS.Var(a.AssignWith(0));
            var condition = a.IsLessThan(10);
            var iteration = a.PostIncrement();
            var alert = JS.Alert(a);
            var statement = new LoopStatement();
            statement.Initialization = initialization;
            statement.Condition = condition;
            statement.Iteration = iteration;
            statement.Statement = alert;

            Assert.AreEqual("for(var a=0;a<10;a++)alert(a);", statement.ToString());
        }
        public void LoopStatementProducesLoopWithAllTheBellsAndWhistles()
        {
            var a = JS.Id("a");
            var initialization = JS.Var(a.AssignWith(0));
            var condition      = a.IsLessThan(10);
            var iteration      = a.PostIncrement();
            var alert          = JS.Alert(a);
            var statement      = new LoopStatement(initialization, condition, iteration, alert);

            Assert.AreEqual("var a=0;", statement.Initialization.ToString());
            Assert.AreEqual("a++;", statement.Iteration.ToString());
            Assert.AreEqual("a<10;", statement.Condition.ToString());
            Assert.AreEqual("alert(a);", statement.Statement.ToString());
            Assert.AreEqual("for(var a=0;a<10;a++)alert(a);", statement.ToString());
        }
예제 #3
0
        public void LoopStatementRequiresStatement()
        {
            var statement = new LoopStatement();

            Expect.Throw<InvalidOperationException>(() => statement.ToString());
        }
예제 #4
0
        public void LoopStatementProducesInfiniteLoop()
        {
            var statement = new LoopStatement(null, null, null, JS.Empty());

            Assert.AreEqual("for(;;);", statement.ToString());
        }
        public void LoopStatementProducesInfiniteLoop()
        {
            var statement = new LoopStatement(null, null, null, JS.Empty());

            Assert.AreEqual("for(;;);", statement.ToString());
        }
        public void LoopStatementRequiresStatement()
        {
            var statement = new LoopStatement();

            Expect.Throw <InvalidOperationException>(() => statement.ToString());
        }