예제 #1
0
파일: Program.cs 프로젝트: jonathanvdc/Loyc
 public static void Test_Ecs()
 {
     RunTests.Run(new EcsLexerTests());
     RunTests.Run(new EcsParserTests());
     RunTests.Run(new EcsNodePrinterTests());
     RunTests.Run(new EcsValidatorTests());
 }
예제 #2
0
        static void Tests()
        {
            Console.WriteLine("Running tests... (a small number of them are broken)");

            // Workaround for MS bug: Assert(false) will not fire in debugger
            Debug.Listeners.Clear();
            Debug.Listeners.Add(new DefaultTraceListener());

            RunTests.Run(new IntSetTests());
            //RunTests.Run(new LNodeTests());
            RunTests.Run(new LlpgParserTests());
            RunTests.Run(new LlpgGeneralTests());
            RunTests.Run(new Loyc.Syntax.Lexing.TokenTests());
            RunTests.Run(new Loyc.Syntax.Les.LesLexerTests());
            RunTests.Run(new Loyc.Syntax.Les.LesParserTests());
            RunTests.Run(new Loyc.Syntax.Les.LesPrinterTests());
            RunTests.Run(new LexerSourceTests_Calculator());
            RunTests.Run(new ParserSourceTests_Calculator());
            RunTests.Run(new LeMP.MacroProcessorTests());
            RunTests.Run(new LeMP.StandardMacroTests());
            RunTests.Run(new LlpgCoreTests());
            RunTests.Run(new LlpgAutoValueSaverVisitorTests());
            RunTests.Run(new LlpgTestLargerExamples());
            RunTests.Run(new LlpgBugsAndSlugs());
            RunTests.Run(new Loyc.Syntax.Lexing.TokensToTreeTests());
            RunTests.Run(new Loyc.Syntax.Les.LesPrinterTests());
        }
예제 #3
0
 static void Main(string[] args)
 {
     Console.WriteLine("Running VList unit tests...");
     RunTests.Run(new RWListTests());
     RunTests.Run(new WListTests());
     RunTests.Run(new RVListTests());
     RunTests.Run(new VListTests());
 }
예제 #4
0
        public static void Main(string[] args)
        {
            // Workaround for MS bug: Assert(false) will not fire in debugger
            Debug.Listeners.Clear();
            Debug.Listeners.Add(new DefaultTraceListener());

            RunEcsTests();
            RunTests.Run(new GTests());
            //RunTests.Run(new LNodeTests());
        }
예제 #5
0
 private void RunTests(bool alone, string id, string url, string[] dlls)
 {
     Deployment.Current.Dispatcher.BeginInvoke(Start);
     if (alone)
     {
         _results = _runTest.RunAlone(id, dlls).ToListJson();
     }
     else
     {
         _runTest.Run(id, url, dlls);
     }
     Deployment.Current.Dispatcher.BeginInvoke(End);
 }
예제 #6
0
        public static void Test_LLLPG()
        {
            Console.WriteLine("Running tests... (a small number of them are broken)");

            // Workaround for MS bug: Assert(false) will not fire in debugger
            Debug.Listeners.Clear();
            Debug.Listeners.Add(new DefaultTraceListener());

            RunTests.Run(new LlpgParserTests());
            RunTests.Run(new LlpgGeneralTests());
            RunTests.Run(new LlpgCoreTests());
            RunTests.Run(new LlpgAutoValueSaverVisitorTests());
            RunTests.Run(new LlpgTestLargerExamples());
            RunTests.Run(new LlpgBugsAndSlugs());
        }
예제 #7
0
파일: Program.cs 프로젝트: jonathanvdc/Loyc
        public static void Main(string[] args)
        {
            // Copied from LoycCore.Tests' Program.cs.
            // =======================================
            // Workaround for MS bug: Assert(false) will not fire in debugger
            Debug.Listeners.Clear();
            Debug.Listeners.Add(new DefaultTraceListener());

            // ========================================

            // Round-trip fuzz tests
            RunTests.Run(new RoundTripTests());
            // LES comparison benchmark
            RunTests.Run(new LesComparisonBenchmark());

            Console.WriteLine("Job's done.");
        }
예제 #8
0
        static void Main(string[] args)
        {
            // Note 1: benchmark should run first in order to measure the time it
            // takes to use GoInterface for the first time, which is the slowest.
            // Note 2: Release builds run a bit faster
            Console.WriteLine("Running GoInterface benchmark");
            Console.WriteLine();
            GoInterfaceBenchmark.DoBenchmark();

            Console.WriteLine();
            Console.WriteLine("Running GoInterface test suite");
            Console.WriteLine();
            RunTests.Run(new GoInterfaceTests());

            Console.WriteLine();
            Console.WriteLine("Press any key.");
            Console.ReadKey(true);
        }
예제 #9
0
        public static void Main(string[] args)
        {
            BMultiMap <string, string> options = new BMultiMap <string, string>();

            var argList = args.ToList();

            UG.ProcessCommandLineArguments(argList, options, "", ShortOptions, TwoArgOptions);
            if (!options.ContainsKey("nologo"))
            {
                Console.WriteLine("LeMP macro compiler (pre-alpha)");
            }

            string _;

            if (options.TryGetValue("help", out _) || options.TryGetValue("?", out _))
            {
                ShowHelp(KnownOptions.OrderBy(p => p.Key));
                return;
            }

            Severity minSeverity = Severity.Note;

                        #if DEBUG
            minSeverity = Severity.Debug;
                        #endif
            var filter = new SeverityMessageFilter(MessageSink.Console, minSeverity);

            Compiler c = ProcessArguments(argList, options, filter, typeof(Macros));
            Compiler.WarnAboutUnknownOptions(options, MessageSink.Console, KnownOptions);
            if (c != null)
            {
                c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP.Prelude"));
                using (LNode.PushPrinter(Ecs.EcsNodePrinter.PrintPlainCSharp))
                    c.Run();
            }
            else if (args.Length == 0)
            {
                Console.WriteLine("Running unit tests...");
                RunTests.Run(new Loyc.Syntax.Les.LesLexerTests());
                RunTests.Run(new Loyc.Syntax.Les.LesParserTests());
                RunLeMPTests();
                Ecs.Program.RunEcsTests();
            }
        }
예제 #10
0
        public static void Main(string[] args)
        {
            // Workaround for MS bug: Assert(false) will not fire in debugger
            Debug.Listeners.Clear();
            Debug.Listeners.Add(new DefaultTraceListener());

            Console.WriteLine("Running tests on stable code...");
            // Omitted: unit tests that throw & catch exceptions (those are below)

            // Loyc.Essentials
            RunTests.Run(new ListExtTests());
            RunTests.Run(new MathExTests());
            RunTests.Run(new UStringTests());
            RunTests.Run(new StringExtTests());
            RunTests.Run(new HashTagsTests());
            RunTests.Run(new LocalizeTests());
            RunTests.Run(new SymbolTests());
            RunTests.Run(new ThreadExTests());
            RunTests.Run(new ListTests <InternalList <int> >(false, delegate(int n) { var l = InternalList <int> .Empty; l.Resize(n); return(l); }));
            RunTests.Run(new ListRangeTests <InternalList <int> >(false, delegate() { return(InternalList <int> .Empty); }));
            RunTests.Run(new ListTests <DList <int> >(false, delegate(int n) { var l = new DList <int>(); l.Resize(n); return(l); }));
            RunTests.Run(new DequeTests <DList <int> >(delegate() { return(new DList <int>()); }));
            RunTests.Run(new ListRangeTests <DList <int> >(false, delegate() { return(new DList <int>()); }));

            // Loyc.Collections
            RunTests.Run(new CPTrieTests());
            RunTests.Run(new SimpleCacheTests());
            RunTests.Run(new InvertibleSetTests());
            // Test with small node sizes as well as the standard node size,
            // including the minimum size of 3 (the most problematic size).
            int seed = 237588399;

            RunTests.Run(new AListTests(false, seed, 8, 8));
            RunTests.Run(new BListTests(false, seed, 3, 3));
            RunTests.Run(new BDictionaryTests(false, seed, 6, 6));
            RunTests.Run(new SparseAListTests(false, seed, 10, 10));
            RunTests.Run(new DequeTests <AList <int> >(delegate() { return(new AList <int>()); }));
            RunTests.Run(new DequeTests <SparseAList <int> >(delegate() { return(new SparseAList <int>()); }));
            RunTests.Run(new DictionaryTests <BDictionary <object, object> >(true, true));
            RunTests.Run(new ListTests <AList <int> >(false, delegate(int n) { var l = new AList <int>(); l.Resize(n); return(l); }));
            RunTests.Run(new ListRangeTests <AList <int> >(false, delegate() { return(new AList <int>()); }, 12345));
            RunTests.Run(new ListTests <SparseAList <int> >(false, delegate(int n) { var l = new SparseAList <int>(); l.Resize(n); return(l); }, 12345));
            RunTests.Run(new ListRangeTests <SparseAList <int> >(false, delegate() { return(new SparseAList <int>()); }, 12345));

            // Loyc.Syntax
            RunTests.Run(new TokenTests());
            RunTests.Run(new LesLexerTests());
            RunTests.Run(new LesParserTests());
            RunTests.Run(new LesPrinterTests());
            RunTests.Run(new TokensToTreeTests());
            RunTests.Run(new StreamCharSourceTests());
            RunTests.Run(new LexerSourceTests_Calculator());
            RunTests.Run(new ParserSourceTests_Calculator());
            RunTests.Run(new IndentTokenGeneratorTests());

            // Loyc.Utilities
            RunTests.Run(new LineMathTests());
            RunTests.Run(new PointMathTests());
            RunTests.Run(new Loyc.LLParserGenerator.IntSetTests());
            RunTests.Run(new TagsInWListTests());
            RunTests.Run(new UGTests());

            for (;;)
            {
                ConsoleKeyInfo k;

                Console.WriteLine();
                Console.WriteLine("What do you want to do?");
                Console.WriteLine("1. Run unit tests that expect exceptions");
                Console.WriteLine("2. Run unit tests on unstable code");
                Console.WriteLine("9. Benchmarks");
                Console.WriteLine("Z. List encodings");
                Console.WriteLine("Press ESC or ENTER to Quit");
                Console.WriteLine((k = Console.ReadKey(true)).KeyChar);
                if (k.Key == ConsoleKey.Escape || k.Key == ConsoleKey.Enter)
                {
                    break;
                }
                else if (k.KeyChar == '1')
                {
                    // Loyc.Essentials
                    RunTests.Run(new GTests());

                    // Loyc.Utilities
                    RunTests.Run(new GoInterfaceTests());

                    // Loyc.Collections
                    RunTests.Run(new RWListTests());
                    RunTests.Run(new WListTests());
                    RunTests.Run(new RVListTests());
                    RunTests.Run(new VListTests());
                    RunTests.Run(new MapTests());
                    RunTests.Run(new SparseAListTests(true, seed, 8, 4));
                    RunTests.Run(new SparseAListTests());
                    RunTests.Run(new AListTests());
                    RunTests.Run(new BListTests());
                    RunTests.Run(new BDictionaryTests());
                    RunTests.Run(new MSetTests());                    // derived from MutableSetTests<MSet<STI>, STI>
                    RunTests.Run(new SymbolSetTests());               // derived from MutableSetTests<MSet<Symbol>, Symbol>
                    RunTests.Run(new ImmSetTests());                  // tests for Set<T>
                    RunTests.Run(new MapTests());                     // derived from DictionaryTests<MMap<object, object>>
                }
                else if (k.KeyChar == '2')
                {
                    RunTests.Run(new KeylessHashtableTests());
                }
                else if (k.KeyChar == 'z' || k.KeyChar == 'Z')
                {
                    foreach (EncodingInfo inf in Encoding.GetEncodings())
                    {
                        Console.WriteLine("{0} {1}: {2}", inf.CodePage, inf.Name, inf.DisplayName);
                    }
                }
            }
        }
예제 #11
0
        // Run all test passes.
        private static bool RunTestPasses(
            List <TestInfo> testList,
            List <TestInfo> unfilteredTestList,
            CommandLineArgs commandLineArgs,
            StreamWriter log,
            long loopCount,
            long repeat,
            bool profiling = false)
        {
            bool buildMode                = commandLineArgs.ArgAsBool("buildcheck");
            bool randomOrder              = commandLineArgs.ArgAsBool("random");
            bool demoMode                 = commandLineArgs.ArgAsBool("demo");
            bool offscreen                = commandLineArgs.ArgAsBool("offscreen");
            bool internet                 = commandLineArgs.ArgAsBool("internet");
            bool perftests                = commandLineArgs.ArgAsBool("perftests");
            bool addsmallmoleculenodes    = commandLineArgs.ArgAsBool("testsmallmolecules");       // Add the magic small molecule test node to every document?
            bool runsmallmoleculeversions = commandLineArgs.ArgAsBool("runsmallmoleculeversions"); // Run the various tests that are versions of other tests with the document completely converted to small molecules?
            bool useVendorReaders         = commandLineArgs.ArgAsBool("vendors");
            bool showStatus               = commandLineArgs.ArgAsBool("status");
            bool showFormNames            = commandLineArgs.ArgAsBool("showformnames");
            bool showMatchingPages        = commandLineArgs.ArgAsBool("showpages");
            bool qualityMode              = commandLineArgs.ArgAsBool("quality");
            bool pass0             = commandLineArgs.ArgAsBool("pass0");
            bool pass1             = commandLineArgs.ArgAsBool("pass1");
            int  timeoutMultiplier = (int)commandLineArgs.ArgAsLong("multi");
            int  pauseSeconds      = (int)commandLineArgs.ArgAsLong("pause");
            var  formList          = commandLineArgs.ArgAsString("form");
            var  pauseDialogs      = (string.IsNullOrEmpty(formList)) ? null : formList.Split(',');
            var  results           = commandLineArgs.ArgAsString("results");
            var  maxSecondsPerTest = commandLineArgs.ArgAsDouble("maxsecondspertest");

            // If we haven't been told to run perf tests, remove any from the list
            // which may have shown up by default
            if (!perftests)
            {
                for (var t = testList.Count; t-- > 0;)
                {
                    if (testList[t].IsPerfTest)
                    {
                        testList.RemoveAt(t);
                    }
                }
                for (var ut = unfilteredTestList.Count; ut-- > 0;)
                {
                    if (unfilteredTestList[ut].IsPerfTest)
                    {
                        unfilteredTestList.RemoveAt(ut);
                    }
                }
            }
            // Even if we have been told to run perftests, if none are in the list
            // then make sure we don't chat about perf tests in the log
            perftests &= testList.Any(t => t.IsPerfTest);

            if (buildMode)
            {
                randomOrder      = false;
                demoMode         = false;
                offscreen        = true;
                useVendorReaders = true;
                showStatus       = false;
                qualityMode      = false;
                pauseSeconds     = 0;
            }

            var runTests = new RunTests(
                demoMode, buildMode, offscreen, internet, showStatus, perftests, addsmallmoleculenodes,
                runsmallmoleculeversions,
                pauseDialogs, pauseSeconds, useVendorReaders, timeoutMultiplier,
                results, log);

            if (commandLineArgs.ArgAsBool("clipboardcheck"))
            {
                runTests.TestContext.Properties["ClipboardCheck"] = "TestRunner clipboard check";
                Console.WriteLine("Checking clipboard use for {0} tests...\n", testList.Count);
                loopCount   = 1;
                randomOrder = false;
            }
            else
            {
                if (!randomOrder && perftests)
                {
                    runTests.Log("Perf tests will run last, for maximum overall test coverage.\r\n");
                }
                runTests.Log("Running {0}{1} tests{2}{3}...\r\n",
                             testList.Count,
                             testList.Count < unfilteredTestList.Count ? "/" + unfilteredTestList.Count : "",
                             (loopCount <= 0) ? " forever" : (loopCount == 1) ? "" : " in " + loopCount + " loops",
                             (repeat <= 1) ? "" : ", repeated " + repeat + " times each per language");
            }

            // Get list of languages
            var languages = buildMode
                ? new[] { "en" }
                : commandLineArgs.ArgAsString("language").Split(',');

            if (showFormNames)
            {
                runTests.Skyline.Set("ShowFormNames", true);
            }
            if (showMatchingPages)
            {
                runTests.Skyline.Set("ShowMatchingPages", true);
            }

            var executingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var qualityLanguages   = new FindLanguages(executingDirectory, "en", "fr").Enumerate().ToArray();
            var removeList         = new List <TestInfo>();

            // Pass 0: Test an interesting collection of edge cases:
            //         French number format,
            //         No vendor readers,
            //         No internet access,
            //         Old reports
            if (pass0)
            {
                runTests.Log("\r\n");
                runTests.Log("# Pass 0: Run with French number format, no vendor readers, no internet access, old reports.\r\n");

                runTests.Language = new CultureInfo("fr");
                runTests.Skyline.Set("NoVendorReaders", true);
                runTests.AccessInternet        = false;
                runTests.LiveReports           = false;
                runTests.RunPerfTests          = false;
                runTests.AddSmallMoleculeNodes = false;
                runTests.CheckCrtLeaks         = CrtLeakThreshold;
                bool warnedPass0PerfTest = false;
                for (int testNumber = 0; testNumber < testList.Count; testNumber++)
                {
                    var test = testList[testNumber];
                    if (test.IsPerfTest)
                    {
                        // These are largely about vendor and/or internet performance, so not worth doing in pass 0
                        if (!warnedPass0PerfTest)
                        {
                            warnedPass0PerfTest = true;
                            runTests.Log("# Skipping perf tests for pass 0.\r\n");
                        }
                        continue;
                    }
                    if (!runTests.Run(test, 0, testNumber))
                    {
                        removeList.Add(test);
                    }
                }
                runTests.Skyline.Set("NoVendorReaders", false);
                runTests.AccessInternet        = internet;
                runTests.LiveReports           = true;
                runTests.RunPerfTests          = perftests;
                runTests.AddSmallMoleculeNodes = addsmallmoleculenodes;
                runTests.CheckCrtLeaks         = 0;

                foreach (var removeTest in removeList)
                {
                    testList.Remove(removeTest);
                }
                removeList.Clear();
            }

            // Pass 1: Look for cumulative leaks when test is run multiple times.
            if (pass1)
            {
                runTests.Log("\r\n");
                runTests.Log("# Pass 1: Run tests multiple times to detect memory leaks.\r\n");
                bool warnedPass1PerfTest = false;

                for (int testNumber = 0; testNumber < testList.Count; testNumber++)
                {
                    var  test   = testList[testNumber];
                    bool failed = false;

                    if (test.IsPerfTest)
                    {
                        // These are generally too lengthy to run multiple times, so not a good fit for pass 1
                        if (!warnedPass1PerfTest)
                        {
                            warnedPass1PerfTest = true;
                            runTests.Log("# Skipping perf tests for pass 1 leak checks.\r\n");
                        }
                        continue;
                    }

                    // Warm up memory by running the test in each language.
                    for (int i = 0; i < qualityLanguages.Length; i++)
                    {
                        runTests.Language = new CultureInfo(qualityLanguages[i]);
                        if (!runTests.Run(test, 1, testNumber))
                        {
                            failed = true;
                            removeList.Add(test);
                            break;
                        }
                    }

                    if (failed)
                    {
                        continue;
                    }

                    // Run test repeatedly until we can confidently assess the leak status.
                    double slope        = 0;
                    var    memoryPoints = new List <double> {
                        runTests.TotalMemoryBytes
                    };
                    for (int i = 0; i < LeakCheckIterations; i++)
                    {
                        // Run the test in the next language.
                        runTests.Language =
                            new CultureInfo(qualityLanguages[i % qualityLanguages.Length]);
                        if (!runTests.Run(test, 1, testNumber))
                        {
                            failed = true;
                            removeList.Add(test);
                            break;
                        }

                        // Run linear regression on memory size samples.
                        var memoryBytes = runTests.TotalMemoryBytes;
                        memoryPoints.Add(memoryBytes);
                        if (memoryPoints.Count < 8)
                        {
                            continue;
                        }

                        // Stop if the leak magnitude is below our threshold.
                        slope = CalculateSlope(memoryPoints);
                        if (slope < LeakThreshold)
                        {
                            break;
                        }
                        memoryPoints.RemoveAt(0);
                    }

                    if (failed)
                    {
                        continue;
                    }

                    if (slope >= LeakThreshold)
                    {
                        runTests.Log("!!! {0} LEAKED {1} bytes\r\n", test.TestMethod.Name, Math.Floor(slope));
                        removeList.Add(test);
                    }
                }

                foreach (var removeTest in removeList)
                {
                    testList.Remove(removeTest);
                }
                removeList.Clear();
            }

            if (qualityMode)
            {
                languages = qualityLanguages;
            }

            // Run all test passes.
            int pass    = 1;
            int passEnd = pass + (int)loopCount;

            if (pass0 || pass1)
            {
                pass++;
                passEnd++;
            }
            if (loopCount <= 0)
            {
                passEnd = int.MaxValue;
            }

            if (pass == 2 && pass < passEnd && testList.Count > 0)
            {
                runTests.Log("\r\n");
                runTests.Log("# Pass 2+: Run tests in each selected language.\r\n");
            }

            int  perfPass = pass;                                             // We'll run perf tests just once per language, and only in one language (french) if english and french (along with any others) are both enabled
            bool needsPerfTestPass2Warning = testList.Any(t => t.IsPerfTest); // No perf tests, no warning
            bool flip = true;
            var  perfTestsFrenchOnly = perftests && languages.Any(l => l.StartsWith("en")) && languages.Any(l => l.StartsWith("fr"));

            for (; pass < passEnd; pass++)
            {
                if (testList.Count == 0)
                {
                    break;
                }

                // Run each test in this test pass.
                var testPass = randomOrder ? testList.RandomOrder().ToList() : testList;
                for (int testNumber = 0; testNumber < testPass.Count; testNumber++)
                {
                    var test = testPass[testNumber];

                    // Perf Tests are generally too lengthy to run multiple times (but non-english format check is useful)
                    var languagesThisTest = (test.IsPerfTest && perfTestsFrenchOnly) ? new[] { "fr" } : languages;
                    if (perfTestsFrenchOnly && needsPerfTestPass2Warning)
                    {
                        // NB the phrase "# Perf tests" in a log is a key for SkylineNightly to post to a different URL - so don't mess with this.
                        runTests.Log("# Perf tests will be run only once, and only in French.  To run perf tests in other languages, enable all but English.\r\n");
                        needsPerfTestPass2Warning = false;
                    }

                    // Run once (or repeat times) for each language.
                    for (int i = 0; i < languagesThisTest.Length; i++)
                    {
                        runTests.Language = new CultureInfo(languagesThisTest[i]);
                        var stopWatch = new Stopwatch();
                        stopWatch.Start(); // Limit the repeats in case of very long tests
                        for (int repeatCounter = 1; repeatCounter <= repeat; repeatCounter++)
                        {
                            if (test.IsPerfTest && ((pass > perfPass) || (repeatCounter > 1)))
                            {
                                // Perf Tests are generally too lengthy to run multiple times (but per-language check is useful)
                                if (needsPerfTestPass2Warning)
                                {
                                    // NB the phrase "# Perf tests" in a log is a key for SkylineNightly to post to a different URL - so don't mess with this.
                                    runTests.Log("# Perf tests will be run only once per language.\r\n");
                                    needsPerfTestPass2Warning = false;
                                }
                                break;
                            }
                            if (!runTests.Run(test, pass, testNumber))
                            {
                                removeList.Add(test);
                                i = languages.Length - 1;   // Don't run other languages.
                                break;
                            }
                            if (maxSecondsPerTest > 0)
                            {
                                var maxSecondsPerTestPerLanguage = maxSecondsPerTest / languagesThisTest.Length; // We'd like no more than 5 minutes per test across all languages when doing stess tests
                                if (stopWatch.Elapsed.TotalSeconds > maxSecondsPerTestPerLanguage && repeatCounter <= repeat - 1)
                                {
                                    runTests.Log(string.Format("# Breaking repeat test at count {0} of requested {1} (at {2} minutes), to allow other tests and languages to run.\r\n", repeatCounter, repeat, stopWatch.Elapsed.TotalMinutes));
                                    break;
                                }
                            }
                        }
                        if (profiling)
                        {
                            break;
                        }
                    }
                }

                foreach (var removeTest in removeList)
                {
                    testList.Remove(removeTest);
                }
                removeList.Clear();
                runTests.AddSmallMoleculeNodes = addsmallmoleculenodes && (flip = !flip); // Do this in every other pass, so we get it both ways
            }

            return(runTests.FailureCount == 0);
        }
예제 #12
0
 public static void RunLeMPTests()
 {
     RunTests.Run(new MacroProcessorTests());
     RunTests.Run(new StandardMacroTests());
 }
예제 #13
0
파일: Samples.out.cs 프로젝트: murven/Loyc
 public static void Run()
 {
     RunTests.Run(new Samples());
 }
예제 #14
0
파일: Program.cs 프로젝트: bel-uwa/Loyc
        static void Tests()
        {
            Console.WriteLine("Running tests...");

            // Workaround for MS bug: Assert(false) will not fire in debugger
            Debug.Listeners.Clear();
            Debug.Listeners.Add(new DefaultTraceListener());

            RunTests.Run(new IntSetTests());
            //RunTests.Run(new LNodeTests());
            RunTests.Run(new Loyc.Syntax.Les.LesLexerTests());
            RunTests.Run(new Loyc.Syntax.Les.LesParserTests());
            RunTests.Run(new LeMP.MacroProcessorTests());
            RunTests.Run(new LeMP.StandardMacroTests());
            RunTests.Run(new LlpgCoreTests());
            RunTests.Run(new LlpgParserTests());
            RunTests.Run(new LlpgGeneralTests());

            Console.WriteLine("******************************");
            Console.WriteLine("**** Generating LES lexer ****");
            string code = new LesLexerGenerator().GenerateLexerCode().Print();

            code = string.Format(@"using System;
				using System.Collections.Generic;
				using System.Linq;
				using System.Text;
				using Loyc;
				using Loyc.LLParserGenerator;
				using Loyc.Syntax;
				using Loyc.Syntax.Lexing;

				namespace Loyc.Syntax.Les
				{{
					using TT = TokenType;

					{0}
				}}"                .Replace("\t\t\t\t", ""),
                                 code.Replace("\n", "\r\n\t"));
            File.WriteAllText("LesLexerGenerated.cs", code, Encoding.UTF8);
            Console.WriteLine("**** Done.                ****");
            Console.WriteLine("******************************");

            Console.WriteLine("******************************");
            Console.WriteLine("**** Generating LES parser ***");
            code = new LesParserGenerator().GenerateParserCode().Print();
            code = string.Format(@"using System;
				using System.Collections.Generic;
				using System.Linq;
				using System.Text;
				using Loyc;
				using Loyc.LLParserGenerator;
				using Loyc.Collections;
				using Loyc.Syntax;
				using Loyc.Syntax.Lexing;

				namespace Loyc.Syntax.Les
				{{
					using TT = TokenType;
					using S = CodeSymbols;
					using P = LesPrecedence;

					{0}
				}}"                .Replace("\t\t\t\t", ""),
                                 code.Replace("\n", "\r\n\t"));
            File.WriteAllText("LesParserGenerated.cs", code, Encoding.UTF8);
            Console.WriteLine("**** Done.                ****");
            Console.WriteLine("******************************");

            RunTests.Run(new Loyc.Syntax.Lexing.TokensToTreeTests());
            RunTests.Run(new Loyc.Syntax.Les.LesPrinterTests());
        }
예제 #15
0
 public static void RunEcsTests()
 {
     RunTests.Run(new EcsLexerTests());
     RunTests.Run(new EcsParserTests());
     RunTests.Run(new EcsNodePrinterTests());
 }
예제 #16
0
 public static int Run()
 {
     return(RunTests.Run(new Samples()));
 }
예제 #17
0
        [STAThread]         // Required by ICSharpCode.TextEditor
        public static void Main(string[] args)
        {
            BMultiMap <string, string> options = new BMultiMap <string, string>();

            var argList = args.ToList();

            UG.ProcessCommandLineArguments(argList, options, "", ShortOptions, TwoArgOptions);
            if (!options.ContainsKey("nologo"))
            {
                Console.WriteLine("LeMP macro compiler (pre-alpha)");
            }

            string _;

            if (options.TryGetValue("help", out _) || options.TryGetValue("?", out _))
            {
                ShowHelp(KnownOptions.OrderBy(p => p.Key));
                return;
            }
            if (options.ContainsKey("editor"))
            {
                Console.WriteLine("Starting editor...");
                System.Windows.Forms.Application.EnableVisualStyles();
                System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
                System.Windows.Forms.Application.Run(new TextEditor.LempDemoForm());
                return;
            }

            Severity minSeverity = Severity.Note;

                        #if DEBUG
            minSeverity = Severity.Debug;
                        #endif
            var filter = new SeverityMessageFilter(MessageSink.Console, minSeverity);

            Compiler c = ProcessArguments(options, filter, typeof(Macros), argList);
            Compiler.WarnAboutUnknownOptions(options, MessageSink.Console, KnownOptions);
            if (c != null)
            {
                c.AddMacros(typeof(global::LeMP.StandardMacros).Assembly);
                c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP.Prelude"));
                c.MacroProcessor.PreOpenedNamespaces.Add(GSymbol.Get("LeMP"));
                using (LNode.PushPrinter(Ecs.EcsNodePrinter.PrintPlainCSharp))
                    c.Run();
            }
            else if (args.Length == 0)
            {
                ShowHelp(KnownOptions.OrderBy(p => p.Key));

                Console.WriteLine();
                Console.WriteLine("LeMP started without arguments. Starting editor (--editor)");

                var thread = new ThreadEx(() => {
                    System.Windows.Forms.Application.EnableVisualStyles();
                    System.Windows.Forms.Application.Run(new TextEditor.LempDemoForm());
                });
                thread.Thread.SetApartmentState(ApartmentState.STA);
                thread.Start();

                Console.WriteLine("Press Enter to run unit tests. Using the editor? Keep the terminal open.");
                Console.ReadLine();

                RunTests.Run(new Loyc.Syntax.Lexing.TokenTests());
                RunTests.Run(new Loyc.Syntax.Les.LesLexerTests());
                RunTests.Run(new Loyc.Syntax.Les.LesParserTests());
                RunTests.Run(new Loyc.Syntax.Les.LesPrinterTests());
                RunLeMPTests();
                Ecs.Program.RunEcsTests();
            }
        }