protected void AssertSuccessByILComparison() { if (BodyCodeBlock == null) { BodyCodeBlock = new CodeBlockNode() { Nodes = new List <IParserNode>() }; } methodEmitter.ParseTree(BodyCodeBlock); methodEmitter.SetAsEntryPoint(); Assert.IsTrue(assemblyEmitter.Save()); var il = Disassembler.DisassembleAssembly(assemblyEmitter.OutputPath); var expectedILPath = Path.Combine("..", "..", "CodegenTests", "MethodBodyTests", "Expected", ExpectedILFilePath); var expectedIL = File.ReadAllText(expectedILPath, Encoding.UTF8); try { Assert.AreEqual(expectedIL.Trim(), il.Trim()); PEVerifyRunner.Run(assemblyEmitter.OutputPath); } finally { File.Delete(assemblyEmitter.OutputPath); File.Delete(Path.ChangeExtension(assemblyEmitter.OutputPath, ".pdb")); } }
private void AssertSuccessByExecutionForSingleTest() { Assert.IsNotNull(BodyCodeBlock); methodEmitter.ParseTree(BodyCodeBlock); methodEmitter.SetAsEntryPoint(); Assert.IsTrue(assemblyEmitter.Save()); PEVerifyRunner.Run(assemblyEmitter.OutputPath); var stdout = ManagedCodeRunner.CreateProcessAndRun(assemblyEmitter.OutputPath, new string[0] { }); Assert.AreEqual(ExpectedOutput.Trim(), stdout.Trim()); }
protected void Test(IntegrationTestInfo testInfo) { var filePath = Path.Combine(TestBase.GetTestDirectory(), "TestExecutable"); var exePath = filePath + ".exe"; var pdbPath = filePath + ".pdb"; var files = testInfo.SourceFiles.Select(file => Path.Combine(IntegrationTestsPath, "SourceFiles", file)); var references = testInfo.AdditionalReferences.Select(reference => string.Format("/ref:{0}", reference)); Build(files, references, exePath); PEVerifyRunner.Run(exePath); Run(exePath, testInfo); }