예제 #1
0
 public void RunCSharpTests()
 {
     SVM.Run(System.Reflection.Assembly.Load("VSharp.CSharpUtils"));
 }
예제 #2
0
        public void RunCSharpTests()
        {
            Trace.Listeners.Add(new DumpStackTraceListener());

            CultureInfo ci = new CultureInfo("en-GB");

            ci.NumberFormat.PositiveInfinitySymbol = "Infinity";
            ci.NumberFormat.NegativeInfinitySymbol = "-Infinity";
            Thread.CurrentThread.CurrentCulture    = ci;

            var ignoredLibs = new List <string>
            {
                //"VSharp.CSharpUtils.dll",
                "ChessDotNet.dll"
            };
            var ignoredTypes = new List <string>
            {
                "Calculator"
                , "AnonymousType"
//                , "Arithmetics"
//                , "Logics"
//                , "Conditional"
//                , "Fibonacci"
//                , "GCD"
//                , "Lambdas"
//                , "ClassesSimple"
//                , "StaticClass"
//                , "StaticMembers"
//                , "TryCatch"
//                , "Lists"
//                , "Typecast"
                , "Tree"
                , "IKeeper"
                , "Bag"
                , "Generic"
                , "Celsius"
                , "Fahrenheit"
                , "INormalize"
                , "Coord"
                , "Piece"
                , "Pawn"
                , "IPromotion"
                , "Employee"
                , "Helper"
            };

            var    failReason  = new StringBuilder();
            string pathToTests = Path.Combine(Path.GetFullPath("."), "..", "..", TestsDirectoryName);

            string[] tests = Directory.GetDirectories(pathToTests);
            foreach (string testDir in tests)
            {
                string[] libEntries = Directory.GetFiles(testDir);
                foreach (string lib in libEntries)
                {
                    if (!lib.EndsWith(".dll", StringComparison.Ordinal) || ignoredLibs.Exists(i => lib.EndsWith(i)))
                    {
                        continue;
                    }

                    _currentTestDirectory = testDir;
                    AppDomain currentDomain = AppDomain.CurrentDomain;
                    currentDomain.AssemblyResolve += LoadFromTestFolder;

                    IDictionary <MethodInfo, string> got = SVM.Run(Assembly.LoadFile(lib), ignoredTypes);

                    IEnumerable <IDictionary <string, string> > expected = ReadAllIdealValues(testDir, failReason);
                    if (expected.Count() == 0)
                    {
                        Assert.Fail($"Could not find or parse ideal values for {lib}");
                        break;
                    }

                    foreach (KeyValuePair <MethodInfo, string> keyValuePair in got)
                    {
                        string method        = MethodInfoToString(keyValuePair.Key);
                        string gotValue      = keyValuePair.Value;
                        string expectedValue = "";
                        if (expected.All(dict =>
                        {
                            if (dict.TryGetValue(method, out expectedValue))
                            {
                                return(!string.Equals(expectedValue, gotValue));
                            }

                            failReason.AppendFormat("Gold file does not contain ideal values for {0}!\n", method);
                            return(true);
                        }))
                        {
                            failReason.AppendFormat("{0}{1}\nEXPECTED: {2}\nGOT:      {3}\n\n", MethodSeparator, method, expectedValue, gotValue);
                        }
                    }
                }
            }

            string fail = failReason.ToString();

            if (!string.IsNullOrEmpty(fail))
            {
                Assert.Fail(fail);
            }
        }
예제 #3
0
 public static void SetUpSVM(SVM svm)
 {
     _svm = svm;
 }