当前位置: 首页>>代码示例>>C#>>正文


C# Tests.ComparisonTest类代码示例

本文整理汇总了C#中JSIL.Tests.ComparisonTest的典型用法代码示例。如果您正苦于以下问题:C# ComparisonTest类的具体用法?C# ComparisonTest怎么用?C# ComparisonTest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ComparisonTest类属于JSIL.Tests命名空间,在下文中一共展示了ComparisonTest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AllSimpleTests

        public void AllSimpleTests()
        {
            var defaultProvider = MakeDefaultProvider();
            var simpleTests = Directory.GetFiles(
                Path.GetFullPath(Path.Combine(ComparisonTest.TestSourceFolder, "SimpleTestCases")),
                "*.cs"
            );
            var failureList = new List<string>();

            foreach (var filename in simpleTests) {
                Console.Write("// {0} ... ", Path.GetFileName(filename));

                try {
                    // We reuse the same type info provider for all the tests in this folder so they run faster
                    using (var test = new ComparisonTest(filename, null, defaultProvider))
                        test.Run();
                } catch (Exception ex) {
                    failureList.Add(Path.GetFileNameWithoutExtension(filename));
                    if (ex.Message == "JS test failed")
                        Debug.WriteLine(ex.InnerException);
                    else
                        Debug.WriteLine(ex);
                }
            }

            Assert.AreEqual(0, failureList.Count,
                String.Format("{0} test(s) failed:\r\n{1}", failureList.Count, String.Join("\r\n", failureList.ToArray()))
            );
        }
开发者ID:robashton,项目名称:JSIL,代码行数:29,代码来源:ComparisonTests.cs

示例2: Chars

 public void Chars()
 {
     using (var test = new ComparisonTest(@"TestCases\Chars.cs"))
         test.Run();
     using (var test = new ComparisonTest(@"TestCases\CharSwitch.cs"))
         test.Run();
 }
开发者ID:robashton,项目名称:JSIL,代码行数:7,代码来源:ComparisonTests.cs

示例3: Casts

 public void Casts()
 {
     using (var test = new ComparisonTest(@"TestCases\CastToBoolean.cs"))
         test.Run();
     using (var test = new ComparisonTest(@"TestCases\CastingFromNull.cs"))
         test.Run();
 }
开发者ID:Caspeco,项目名称:JSIL,代码行数:7,代码来源:ComparisonTests.cs

示例4: CastingFromNull

 public void CastingFromNull()
 {
     using (var test = new ComparisonTest(@"TestCases\CastingFromNull.cs"))
     {
         test.Run();
     }
 }
开发者ID:robashton,项目名称:JSIL,代码行数:7,代码来源:ComparisonTests.cs

示例5: Arithmetic

 public void Arithmetic()
 {
     using (var test = new ComparisonTest(@"TestCases\IntegerArithmetic.cs"))
         test.Run();
     using (var test = new ComparisonTest(@"TestCases\TernaryArithmetic.cs"))
         test.Run();
 }
开发者ID:robashton,项目名称:JSIL,代码行数:7,代码来源:ComparisonTests.cs

示例6: BinaryTrees

 public void BinaryTrees()
 {
     using (var test = new ComparisonTest(@"TestCases\BinaryTrees.cs")) {
         test.Run();
         test.Run("8");
     }
 }
开发者ID:robashton,项目名称:JSIL,代码行数:7,代码来源:ComparisonTests.cs

示例7: Enums

 public void Enums()
 {
     using (var test = new ComparisonTest(@"TestCases\Enums.cs"))
         test.Run();
     using (var test = new ComparisonTest(@"TestCases\EnumArrayLookup.cs"))
         test.Run();
     using (var test = new ComparisonTest(@"TestCases\EnumSwitch.cs"))
         test.Run();
     using (var test = new ComparisonTest(@"TestCases\OverloadWithEnum.cs"))
         test.Run();
 }
开发者ID:rozgo,项目名称:JSIL,代码行数:11,代码来源:ComparisonTests.cs

示例8: AllFailingTests

        public void AllFailingTests()
        {
            var testPath = Path.GetFullPath(Path.Combine(ComparisonTest.TestSourceFolder, "FailingTestCases"));
            var simpleTests = Directory.GetFiles(testPath, "*.cs").Concat(Directory.GetFiles(testPath, "*.vb")).ToArray();

            int passCount = 0;

            foreach (var filename in simpleTests) {
                Console.Write("// {0} ... ", Path.GetFileName(filename));

                try {
                    using (var test = new ComparisonTest(filename))
                        test.Run();

                    passCount += 1;
                } catch (Exception ex) {
                    Console.WriteLine("{0}: {1}", ex.GetType().Name, ex.Message);
                }
            }

            Assert.AreEqual(0, passCount, "One or more tests passed that should have failed");
        }
开发者ID:Caspeco,项目名称:JSIL,代码行数:22,代码来源:FailingTests.cs

示例9: EscapesOutputFilenames

        public void EscapesOutputFilenames()
        {
            using (var test = new ComparisonTest(
                EvaluatorPool,
                new[] { @"TestCases\HelloWorld.cs" },
                Portability.NormalizeDirectorySeparators(@"MetadataTests\EscapesOutputFilenames")
            )) {
                var filenames = test.Translate((tr) => {
                    return (from file in tr.OrderedFiles select file.Filename).ToArray();
                }, () => {
                    var configuration = MakeConfiguration();
                    configuration.FilenameEscapeRegex = "[^A-Za-z0-9 _]";
                    return configuration;
                });

                Assert.AreEqual(1, filenames.Length);

                foreach (var filename in filenames) {
                    Assert.IsTrue(Regex.IsMatch(filename, @"^([A-Za-z0-9 _]*)\.js$"), "Filename '{0}' does not match regex.", filename);
                    Console.WriteLine(filename);
                }
            }
        }
开发者ID:jean80it,项目名称:JSIL,代码行数:23,代码来源:MetadataTests.cs

示例10: StaticInitializersInInheritedClasses

 public void StaticInitializersInInheritedClasses()
 {
     using (var test = new ComparisonTest(@"TestCases\StaticInitializersInInheritedClasses.cs"))
     {
         test.Run();
     }
 }
开发者ID:robashton,项目名称:JSIL,代码行数:7,代码来源:ComparisonTests.cs

示例11: StaticInitializersInGenericTypesSettingStaticFields

 public void StaticInitializersInGenericTypesSettingStaticFields()
 {
     using (var test = new ComparisonTest(@"TestCases\StaticInitializersInGenericTypesSettingStaticFields.cs"))
     {
         test.Run();
     }
 }
开发者ID:robashton,项目名称:JSIL,代码行数:7,代码来源:ComparisonTests.cs

示例12: StaticConstructors

 public void StaticConstructors()
 {
     using (var test = new ComparisonTest(@"TestCases\GenericStaticConstructorOrdering.cs"))
         test.Run();
     using (var test = new ComparisonTest(@"TestCases\StaticConstructorOrdering.cs"))
         test.Run();
     using (var test = new ComparisonTest(@"TestCases\StaticInitializersInGenericTypesSettingStaticFields.cs"))
         test.Run();
 }
开发者ID:robashton,项目名称:JSIL,代码行数:9,代码来源:ComparisonTests.cs

示例13: StaticArrays

 public void StaticArrays()
 {
     using (var test = new ComparisonTest(@"TestCases\StaticArrayInitializer.cs"))
         test.Run();
 }
开发者ID:robashton,项目名称:JSIL,代码行数:5,代码来源:ComparisonTests.cs

示例14: RunComparisonTest

        private CompileResult RunComparisonTest(
            string filename, string[] stubbedAssemblies = null, TypeInfoProvider typeInfo = null, Action<string, string> errorCheckPredicate = null,
            List<string> failureList = null, string commonFile = null, bool shouldRunJs = true, AssemblyCache asmCache = null,
            Func<Configuration> makeConfiguration = null, Action<Exception> onTranslationFailure = null,
            string compilerOptions = ""
        )
        {
            CompileResult result = null;
            Console.WriteLine("// {0} ... ", Path.GetFileName(filename));
            filename = Portability.NormalizeDirectorySeparators(filename);

            try {
                var testFilenames = new List<string>() { filename };
                if (commonFile != null)
                    testFilenames.Add(commonFile);

                using (var test = new ComparisonTest(
                    EvaluatorPool,
                    testFilenames,
                    Path.Combine(
                        ComparisonTest.TestSourceFolder,
                        ComparisonTest.MapSourceFileToTestFile(filename)
                    ),
                    stubbedAssemblies, typeInfo, asmCache,
                    compilerOptions: compilerOptions
                )) {
                    result = test.CompileResult;

                    if (shouldRunJs) {
                        test.Run(makeConfiguration: makeConfiguration, onTranslationFailure: onTranslationFailure);
                    } else {
                        string js;
                        long elapsed;
                        try {
                            var csOutput = test.RunCSharp(new string[0], out elapsed);
                            test.GenerateJavascript(new string[0], out js, out elapsed, makeConfiguration, onTranslationFailure);

                            Console.WriteLine("generated");

                            if (errorCheckPredicate != null) {
                                errorCheckPredicate(csOutput, js);
                            }
                        } catch (Exception) {
                            Console.WriteLine("error");
                            throw;
                        }
                    }
                }
            } catch (Exception ex) {
                if (ex.Message == "JS test failed")
                    Debug.WriteLine(ex.InnerException);
                else
                    Debug.WriteLine(ex);

                if (failureList != null) {
                    failureList.Add(Path.GetFileNameWithoutExtension(filename));
                } else
                    throw;
            }

            return result;
        }
开发者ID:poizan42,项目名称:JSIL,代码行数:62,代码来源:GenericTestFixture.cs

示例15: ValueTypeMethods

 public void ValueTypeMethods()
 {
     using (var test = new ComparisonTest(@"TestCases\ValueTypeMethods.cs"))
         test.Run();
 }
开发者ID:robashton,项目名称:JSIL,代码行数:5,代码来源:ComparisonTests.cs


注:本文中的JSIL.Tests.ComparisonTest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。