public void TestCase() { // HACK CommandLineOptions.Install(new Microsoft.Boogie.CommandLineOptions()); var path = "programs/locations.bpl"; Assert.IsTrue(File.Exists(path)); int errors = 0; Program p = null; List <String> defines = null; errors = Parser.Parse(path, defines, out p); Assert.AreEqual(0, errors); Assert.IsNotNull(p); // Resolve errors = p.Resolve(); Assert.AreEqual(0, errors); // Type check errors = p.Typecheck(); Assert.AreEqual(0, errors); // Pull out the assert command AssertCmd cmd = p.TopLevelDeclarations.OfType <Implementation>().First().Blocks.SelectMany(b => b.Cmds.OfType <AssertCmd>()).First(); var token = cmd.tok; Assert.AreEqual(Path.GetFileName(token.filename), "locations.bpl"); Assert.AreEqual(token.line, 3); // This is nasty. Triggering a ToString() // mucks up the Tokens in a buggy version // of Boogie! cmd.ToString(); token = cmd.tok; Assert.AreEqual(Path.GetFileName(token.filename), "locations.bpl"); Assert.AreEqual(token.line, 3); }
public Implementation instrumentAssertion(Implementation impl, string label, Cmd typedCmd, AssertCmd assertion) { Implementation new_impl = new Duplicator().VisitImplementation(impl); this.target_label = label; this.target_typedCmd = typedCmd; this.target_assertion = assertion; if (this.target_assertion.Attributes != null) { this.target_assertion.Attributes.AddLast(new QKeyValue(Token.NoToken, "source_assert", new List <object> (), null)); } else { this.target_assertion.Attributes = new QKeyValue(Token.NoToken, "source_assert", new List <object> (), null); } this.target_acquired = false; this.Visit(new_impl); //this step performs the instrumentation Utils.Assert(target_acquired, "Unable to instrument assertion: " + assertion.ToString() + " at label " + label); return(new_impl); }