public void TestScope2() { MemoryStream ms = Content.GenerateContent2(); MiniZincLexer scnr = new MiniZincLexer(ms); MiniZincParser pars = new MiniZincParser(scnr); pars.Parse(); ZincModel model = pars.Result; Assert.IsNotNull(model); model.CloseScope(null); ZincIdentNameRegister zinr = model.NameRegister; List <IZincIdent> iz = zinr.Elements().ToList(); List <string> result = iz.Select(x => x.Name).ToList(); List <string> expected = new List <string> (new string[] { "size", "d", "total", "end" }); Assert.AreEqual(expected.Count, result.Count); foreach (string si in expected) { Assert.Contains(si, result); } Assert.AreEqual(6, model.Items.Count()); Assert.AreEqual(5, model.Items.OfType <ZincVarDeclItem> ().Count()); Assert.AreEqual(1, model.Items.OfType <ZincSolveItem> ().Count()); List <ZincVarDeclItem> zvd = new List <ZincVarDeclItem> (); foreach (string si in expected) { ZincVarDeclItem zvdi = model.Items.OfType <ZincVarDeclItem> ().Where(x => x.DeclaredIdentifier.Name == si).FirstOrDefault(); Assert.NotNull(zvdi); Assert.Contains(zvdi.DeclaredIdentifier, iz); zvd.Add(zvdi); } }
public void TestScope0() { MemoryStream ms = Content.GenerateContent0(); MiniZincLexer scnr = new MiniZincLexer(ms); MiniZincParser pars = new MiniZincParser(scnr); pars.Parse(); ZincModel model = pars.Result; Assert.IsNotNull(model); model.CloseScope(null); //TODO: finish test }