public void ParseRepeatBlock() { JSProgram program = new JSProgram(); program.AddInputBlock("k", 10); program.AddOutputDeclarationBlock("z"); string conditionalBlock = program.AddConstantBlock(3); program.AddScope("a"); program.SetScope("a"); string guardedBlock = program.AddOutputSegment("k", "z", 1, false); program.SetScope(JSProgram.DEFAULT_SCOPE_NAME); program.AddRepeatSegment(conditionalBlock, guardedBlock); program.Finish(); TestTools.ExecuteJS(program); string xml = TestTools.GetWorkspaceString(); (CDFG cdfg, var _) = XmlParser.Parse(xml); Assert.AreEqual(2, cdfg.Nodes.Count); DFG <Block> firstDFG = cdfg.StartDFG; Assert.AreEqual(5, firstDFG.Nodes.Count); (var _, DFG <Block> lastDFG) = cdfg.Nodes.Where(x => x.dfg != firstDFG).Single(); Assert.AreEqual(1, lastDFG.Nodes.Count); }
public void ParseOutputBlock() { JSProgram program = new JSProgram(); program.AddOutputSegment("a", "z", 1249, false); TestTools.ExecuteJS(program); XmlNode node = TestTools.GetWorkspace(); ParserInfo parserInfo = new ParserInfo(); parserInfo.EnterDFG(); parserInfo.AddVariable("", VariableType.FLUID, "a"); parserInfo.AddVariable("", VariableType.OUTPUT, "z"); Block input = XmlParser.ParseBlock(node, new DFG <Block>(), parserInfo); Assert.AreEqual(0, parserInfo.ParseExceptions.Count, parserInfo.ParseExceptions.FirstOrDefault()?.Message); Assert.IsTrue(input is OutputUsage); }