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 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 IteratorRequiresVariable() { var iterator = new IteratorStatement(); iterator.Collection = JS.Id("b"); iterator.Statement = JS.Empty(); Expect.Throw<InvalidOperationException>(() => iterator.ToString()); }
public void IteratorRequiresStatement() { var iterator = new IteratorStatement(); iterator.Variable = JS.Id("a"); iterator.Collection = JS.Id("b"); Expect.Throw <InvalidOperationException>(() => 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()); }