Ejemplo n.º 1
0
        public PerformanceAnalysisData(ComparisonTest test, Func <Configuration> makeConfiguration = null)
        {
            string trailingOutput;
            string stderr;
            string tempS;
            long   tempL;

            Output = test.RunJavascript(
                null, out tempS, out tempL, out tempL, out stderr, out trailingOutput,
                makeConfiguration: makeConfiguration
                );

            var singletonTypeIDs = new HashSet <UInt32>();

            TaggedObjectTypesByID = ParseTaggedObjectTypes(stderr, trailingOutput, singletonTypeIDs);
            TypeInformationByID   = ParseTypeInformation(trailingOutput, TaggedObjectTypesByID, singletonTypeIDs);

            TaggedObjectTypeIDsByName = new Dictionary <string, uint>(TaggedObjectTypesByID.Count);
            foreach (var kvp in TaggedObjectTypesByID)
            {
                if (!TaggedObjectTypeIDsByName.ContainsKey(kvp.Value))
                {
                    TaggedObjectTypeIDsByName.Add(kvp.Value, kvp.Key);
                }
            }

            RawStdErr          = stderr;
            RawTypeInformation = trailingOutput;
        }
Ejemplo n.º 2
0
        protected string GenericTest(
            string fileName, string csharpOutput,
            string javascriptOutput, string[] stubbedAssemblies = null,
            TypeInfoProvider typeInfo = null
            )
        {
            long   elapsed, temp;
            string generatedJs = null;

            using (var test = new ComparisonTest(EvaluatorPool, Portability.NormalizeDirectorySeparators(fileName), stubbedAssemblies, typeInfo)) {
                var csOutput = test.RunCSharp(new string[0], out elapsed);

                try {
                    var jsOutput = test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed, MakeConfiguration);

                    Assert.AreEqual(Portability.NormalizeNewLines(csharpOutput), csOutput.Trim(), "Did not get expected output from C# test");
                    Assert.AreEqual(Portability.NormalizeNewLines(javascriptOutput), jsOutput.Trim(), "Did not get expected output from JavaScript test");
                } catch {
                    Console.Error.WriteLine("// Generated JS: \r\n{0}", generatedJs);
                    throw;
                }
            }

            return(generatedJs);
        }
Ejemplo n.º 3
0
        protected string GenericIgnoreTest(string fileName, string workingOutput, string jsErrorSubstring, string[] stubbedAssemblies = null)
        {
            long   elapsed, temp;
            string generatedJs = null, jsOutput = null;

            using (var test = new ComparisonTest(EvaluatorPool, fileName, stubbedAssemblies)) {
                var csOutput = test.RunCSharp(new string[0], out elapsed);
                Assert.AreEqual(workingOutput, csOutput.Trim());

                try {
                    jsOutput = test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed, MakeConfiguration);
                    Assert.Fail("Expected javascript to throw an exception containing the string \"" + jsErrorSubstring + "\".");
                } catch (JavaScriptException jse) {
                    if (!jse.ErrorText.Contains(jsErrorSubstring))
                    {
                        Console.Error.WriteLine("// Generated JS: \r\n{0}", generatedJs);
                        if (jsOutput != null)
                        {
                            Console.Error.WriteLine("// JS output: \r\n{0}", jsOutput);
                        }
                        throw;
                    }
                } catch {
                    Console.Error.WriteLine("// Generated JS: \r\n{0}", generatedJs);
                    if (jsOutput != null)
                    {
                        Console.Error.WriteLine("// JS output: \r\n{0}", jsOutput);
                    }
                    throw;
                }
            }

            return(generatedJs);
        }
Ejemplo n.º 4
0
        protected string GenericIgnoreTest(string fileName, string workingOutput, string jsErrorSubstring, string[] stubbedAssemblies = null)
        {
            long          elapsed, temp;
            Func <string> generateJs = null;
            string        jsOutput   = null;

            using (var test = new ComparisonTest(EvaluatorPool, Portability.NormalizeDirectorySeparators(fileName), stubbedAssemblies)) {
                var csOutput = test.RunCSharp(new string[0], out elapsed);
                Assert.AreEqual(Portability.NormalizeNewLines(workingOutput), csOutput.Trim());

                try {
                    jsOutput = test.RunJavascript(new string[0], out generateJs, out temp, out elapsed, MakeConfiguration);
                    Assert.Fail("Expected javascript to throw an exception containing the string \"" + jsErrorSubstring + "\".");
                } catch (JavaScriptEvaluatorException jse) {
                    bool foundMatch = false;

                    foreach (var exc in jse.Exceptions)
                    {
                        if (exc.Message.Contains(jsErrorSubstring))
                        {
                            foundMatch = true;
                            break;
                        }
                    }

                    if (!foundMatch)
                    {
                        Console.Error.WriteLine("// Was looking for a JS exception containing the string '{0}' but didn't find it.", jsErrorSubstring);
                        Console.Error.WriteLine("// Generated JS: \r\n{0}", generateJs != null ? generateJs() : string.Empty);
                        if (jsOutput != null)
                        {
                            Console.Error.WriteLine("// JS output: \r\n{0}", jsOutput);
                        }
                        throw;
                    }
                } catch {
                    Console.Error.WriteLine("// Generated JS: \r\n{0}", generateJs != null ? generateJs() : string.Empty);
                    if (jsOutput != null)
                    {
                        Console.Error.WriteLine("// JS output: \r\n{0}", jsOutput);
                    }
                    throw;
                }
            }

            return(generateJs());
        }
Ejemplo n.º 5
0
        protected string GenericTest(
            string fileName, string csharpOutput,
            string javascriptOutput, string[] stubbedAssemblies = null,
            TypeInfoProvider typeInfo = null
        )
        {
            long elapsed, temp;
            string generatedJs = null;

            using (var test = new ComparisonTest(EvaluatorPool, Portability.NormalizeDirectorySeparators(fileName), stubbedAssemblies, typeInfo)) {
                var csOutput = test.RunCSharp(new string[0], out elapsed);

                try {
                    var jsOutput = test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed, MakeConfiguration);

                    Assert.AreEqual(Portability.NormalizeNewLines(csharpOutput), csOutput.Trim(), "Did not get expected output from C# test");
                    Assert.AreEqual(Portability.NormalizeNewLines(javascriptOutput), jsOutput.Trim(), "Did not get expected output from JavaScript test");
                } catch {
                    Console.Error.WriteLine("// Generated JS: \r\n{0}", generatedJs);
                    throw;
                }
            }

            return generatedJs;
        }
Ejemplo n.º 6
0
        protected string GenericIgnoreTest(string fileName, string workingOutput, string jsErrorSubstring, string[] stubbedAssemblies = null)
        {
            long elapsed, temp;
            string generatedJs = null, jsOutput = null;

            using (var test = new ComparisonTest(EvaluatorPool, Portability.NormalizeDirectorySeparators(fileName), stubbedAssemblies)) {
                var csOutput = test.RunCSharp(new string[0], out elapsed);
                Assert.AreEqual(workingOutput, csOutput.Trim());

                try {
                    jsOutput = test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed, MakeConfiguration);
                    Assert.Fail("Expected javascript to throw an exception containing the string \"" + jsErrorSubstring + "\".");
                } catch (JavaScriptEvaluatorException jse) {
                    bool foundMatch = false;

                    foreach (var exc in jse.Exceptions) {
                        if (exc.Message.Contains(jsErrorSubstring)) {
                            foundMatch = true;
                            break;
                        }
                    }

                    if (!foundMatch) {
                        Console.Error.WriteLine("// Was looking for a JS exception containing the string '{0}' but didn't find it.", jsErrorSubstring);
                        Console.Error.WriteLine("// Generated JS: \r\n{0}", generatedJs);
                        if (jsOutput != null)
                            Console.Error.WriteLine("// JS output: \r\n{0}", jsOutput);
                        throw;
                    }
                } catch {
                    Console.Error.WriteLine("// Generated JS: \r\n{0}", generatedJs);
                    if (jsOutput != null)
                        Console.Error.WriteLine("// JS output: \r\n{0}", jsOutput);
                    throw;
                }

            }

            return generatedJs;
        }
Ejemplo n.º 7
0
        protected string GetJavascript(string fileName, string expectedText = null)
        {
            long elapsed, temp;
            string generatedJs;

            using (var test = new ComparisonTest(fileName)) {
                var output = test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed);

                if (expectedText != null)
                    Assert.AreEqual(expectedText, output.Trim());
            }

            return generatedJs;
        }
Ejemplo n.º 8
0
        protected string GenericTest(string fileName, string csharpOutput, string javascriptOutput, Regex[] stubbedAssemblies = null)
        {
            long elapsed, temp;
            string generatedJs;

            using (var test = new ComparisonTest(fileName, stubbedAssemblies)) {
                var csOutput = test.RunCSharp(new string[0], out elapsed);
                var jsOutput = test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed);

                Assert.AreEqual(csharpOutput, csOutput.Trim(), "Did not get expected output from C# test");
                Assert.AreEqual(javascriptOutput, jsOutput.Trim(), "Did not get expected output from JavaScript test");
            }

            return generatedJs;
        }
Ejemplo n.º 9
0
        protected string GenericIgnoreTest(string fileName, string workingOutput, string jsErrorSubstring, Regex[] stubbedAssemblies = null)
        {
            long elapsed, temp;
            string generatedJs = null;

            using (var test = new ComparisonTest(fileName, stubbedAssemblies)) {
                var csOutput = test.RunCSharp(new string[0], out elapsed);
                Assert.AreEqual(workingOutput, csOutput.Trim());

                try {
                    test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed);
                    Assert.Fail("Expected javascript to throw an exception containing the string \"" + jsErrorSubstring + "\".");
                } catch (JavaScriptException jse) {
                    if (!jse.ErrorText.Contains(jsErrorSubstring))
                        throw;
                }

            }

            return generatedJs;
        }
Ejemplo n.º 10
0
Archivo: Util.cs Proyecto: Caspeco/JSIL
        protected string GetJavascript(string fileName, string expectedText = null)
        {
            long elapsed, temp;
            string generatedJs = null, output;

            using (var test = new ComparisonTest(fileName)) {
                try {
                    output = test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed);
                } catch {
                    Console.Error.WriteLine("// Generated JS: \r\n{0}", generatedJs);
                    throw;
                }

                if (expectedText != null)
                    Assert.AreEqual(expectedText, output.Trim());
            }

            return generatedJs;
        }
Ejemplo n.º 11
0
Archivo: Util.cs Proyecto: Caspeco/JSIL
        protected string GenericTest(string fileName, string csharpOutput, string javascriptOutput, string[] stubbedAssemblies = null)
        {
            long elapsed, temp;
            string generatedJs = null;

            using (var test = new ComparisonTest(fileName, stubbedAssemblies)) {
                var csOutput = test.RunCSharp(new string[0], out elapsed);

                try {
                    var jsOutput = test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed);

                    Assert.AreEqual(csharpOutput, csOutput.Trim(), "Did not get expected output from C# test");
                    Assert.AreEqual(javascriptOutput, jsOutput.Trim(), "Did not get expected output from JavaScript test");
                } catch {
                    Console.Error.WriteLine("// Generated JS: \r\n{0}", generatedJs);
                    throw;
                }
            }

            return generatedJs;
        }
Ejemplo n.º 12
0
        protected string GenericIgnoreTest(string fileName, string workingOutput, string jsErrorSubstring, string[] stubbedAssemblies = null)
        {
            long elapsed, temp;
            string generatedJs = null, jsOutput = null;

            using (var test = new ComparisonTest(EvaluatorPool, fileName, stubbedAssemblies)) {
                var csOutput = test.RunCSharp(new string[0], out elapsed);
                Assert.AreEqual(workingOutput, csOutput.Trim());

                try {
                    jsOutput = test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed);
                    Assert.Fail("Expected javascript to throw an exception containing the string \"" + jsErrorSubstring + "\".");
                } catch (JavaScriptException jse) {
                    if (!jse.ErrorText.Contains(jsErrorSubstring)) {
                        Console.Error.WriteLine("// Generated JS: \r\n{0}", generatedJs);
                        if (jsOutput != null)
                            Console.Error.WriteLine("// JS output: \r\n{0}", jsOutput);
                        throw;
                    }
                } catch {
                    Console.Error.WriteLine("// Generated JS: \r\n{0}", generatedJs);
                    if (jsOutput != null)
                        Console.Error.WriteLine("// JS output: \r\n{0}", jsOutput);
                    throw;
                }

            }

            return generatedJs;
        }
Ejemplo n.º 13
0
        public PerformanceAnalysisData (ComparisonTest test, Func<Configuration> makeConfiguration = null) {
            string trailingOutput;
            string stderr;
            string tempS;
            long tempL;

            Output = test.RunJavascript(
                null, out tempS, out tempL, out tempL, out stderr, out trailingOutput,
                makeConfiguration: makeConfiguration
            );

            var singletonTypeIDs = new HashSet<UInt32>();
            TaggedObjectTypesByID = ParseTaggedObjectTypes(stderr, trailingOutput, singletonTypeIDs);
            TypeInformationByID = ParseTypeInformation(trailingOutput, TaggedObjectTypesByID, singletonTypeIDs);

            TaggedObjectTypeIDsByName = new Dictionary<string, uint>(TaggedObjectTypesByID.Count);
            foreach (var kvp in TaggedObjectTypesByID) {
                if (!TaggedObjectTypeIDsByName.ContainsKey(kvp.Value))
                    TaggedObjectTypeIDsByName.Add(kvp.Value, kvp.Key);
            }

            RawStdErr = stderr;
            RawTypeInformation = trailingOutput;
        }