コード例 #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());
        }
コード例 #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>()));
        }
コード例 #3
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());
        }
コード例 #4
0
        public void IteratorRequiresVariable()
        {
            var iterator = new IteratorStatement();
            iterator.Collection = JS.Id("b");
            iterator.Statement = JS.Empty();

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

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

            Expect.Throw <InvalidOperationException>(() => iterator.ToString());
        }
コード例 #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());
        }
コード例 #7
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());
        }