Example #1
0
        public void IteratorSupportsDeclaration()
        {
            var id         = JS.Id("a");
            var collection = JS.Array();
            var iterator   = new IteratorStatement(JS.Var(id), collection, JS.Empty());

            Assert.AreEqual("for(var a in []);", iterator.ToString());
        }
Example #2
0
        public void IteratorHelpersRequiresIterator()
        {
            IteratorStatement iterator = null;

            Expect.Throw <ArgumentNullException>(() => iterator.In(null));
            Expect.Throw <ArgumentNullException>(() => iterator.Do());
            Expect.Throw <ArgumentNullException>(() => iterator.Do(new List <Statement>()));
        }
        public void IteratorSupportsDeclaration()
        {
            var id = JS.Id("a");
            var collection = JS.Array();
            var iterator = new IteratorStatement(JS.Var(id), collection, JS.Empty());

            Assert.AreEqual("for(var a in []);", iterator.ToString());
        }
        public void IteratorRequiresVariable()
        {
            var iterator = new IteratorStatement();
            iterator.Collection = JS.Id("b");
            iterator.Statement = JS.Empty();

            Expect.Throw<InvalidOperationException>(() => iterator.ToString());
        }
Example #5
0
        public void IteratorRequiresStatement()
        {
            var iterator = new IteratorStatement();

            iterator.Variable   = JS.Id("a");
            iterator.Collection = JS.Id("b");

            Expect.Throw <InvalidOperationException>(() => iterator.ToString());
        }
Example #6
0
        public void IteratorProducesForIn()
        {
            var id         = JS.Id("a");
            var collection = JS.Array();
            var iterator   = new IteratorStatement(id, collection, JS.Empty());

            Assert.AreEqual("a;", iterator.Variable.ToString());
            Assert.AreEqual("[];", iterator.Collection.ToString());
            Assert.AreEqual(";", iterator.Statement.ToString());
            Assert.AreEqual("for(a in []);", iterator.ToString());
        }
        public void IteratorProducesForIn()
        {
            var id = JS.Id("a");
            var collection = JS.Array();
            var iterator = new IteratorStatement(id, collection, JS.Empty());

            Assert.AreEqual("a;", iterator.Variable.ToString());
            Assert.AreEqual("[];", iterator.Collection.ToString());
            Assert.AreEqual(";", iterator.Statement.ToString());
            Assert.AreEqual("for(a in []);", iterator.ToString());
        }