run() public méthode

public run ( ) : void
Résultat void
        public void ArrayAsArgumentListTest()
        {
            DemoClassThree dc3 = new DemoClassThree();
            FunctionDefinition[] defs = FunctionDefinitionCreator.CreateDefinitions(dc3, typeof(DemoClassThree));
            Assert.AreEqual(1, defs.Length);

            List<FunctionDefinition> moreFunctionDefinitions = new List<FunctionDefinition> {
                GetPrintFunction ()
            };

            moreFunctionDefinitions.AddRange (defs);

            TextReader programString = File.OpenText("code75.txt");
            SprakRunner program = new SprakRunner(programString, moreFunctionDefinitions.ToArray());

            program.run();

            foreach(var e in program.getRuntimeErrorHandler().getErrors()) {
                Console.WriteLine(e);
            }

            foreach(var e in program.getCompileTimeErrorHandler().getErrors()) {
                Console.WriteLine(e);
            }

            Assert.AreEqual (0, program.getRuntimeErrorHandler().getErrors().Count);
            Assert.AreEqual (0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
        static void Main(string[] args)
        {
            string filename = ""; //"../Program1";

            if (args.Length > 0) {
                filename = args [0];
            } else {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine ("No program file given");
                return;
            }

            TextReader tr = File.OpenText(filename);
            //StringReader programString = new StringReader("g()\nfloat g() {\n	print(42)\n }");

            FunctionDefinition[] functionDefinitions = new FunctionDefinition[] {
                new FunctionDefinition("void", "print", new string[] { "string" }, new string[] { "text" }, print, FunctionDocumentation.Default())
            };

            SprakRunner runner = new SprakRunner(tr, functionDefinitions);
            runner.run (int.MaxValue);
        }
        public void CallingFunctionWithWrongArgumentType_MANUAL_FUNCTION_DEFINITION()
        {
            TextReader programString = File.OpenText("code72.txt");

            FunctionDefinition[] functionDefinitions = new FunctionDefinition[] {
                new FunctionDefinition(
                    "number", "ThisFunctionTakesANumber",
                    new string[] { "number" }, new string[] { "x" },
                ThisFunctionTakesANumber, FunctionDocumentation.Default()),

                GetPrintFunction()
            };

            SprakRunner program = new SprakRunner(programString, functionDefinitions);
            program.run();

            Assert.AreEqual (0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
        public void CallingFunctionWithWrongArgumentType_USING_FUNCTION_DEFINITION_CREATOR()
        {
            TextReader programString = File.OpenText("code73.txt");

            ClassWithFunction c = new ClassWithFunction ();
            FunctionDefinition[] funcDefs = FunctionDefinitionCreator.CreateDefinitions (c, typeof(ClassWithFunction));

            List<FunctionDefinition> moreFunctionDefinitions = new List<FunctionDefinition> {
                GetPrintFunction ()
            };

            moreFunctionDefinitions.AddRange (funcDefs);

            SprakRunner program = new SprakRunner(programString, moreFunctionDefinitions.ToArray());
            program.run();

            Assert.AreEqual (0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
        public void CallFunctionThatThrowsException()
        {
            DemoClassFour dc3 = new DemoClassFour();
            FunctionDefinition[] defs = FunctionDefinitionCreator.CreateDefinitions(dc3, typeof(DemoClassFour));
            Assert.AreEqual(1, defs.Length);

            List<FunctionDefinition> moreFunctionDefinitions = new List<FunctionDefinition> {
                GetPrintFunction ()
            };

            moreFunctionDefinitions.AddRange (defs);

            TextReader programString = File.OpenText("code77.txt");
            SprakRunner program = new SprakRunner(programString, moreFunctionDefinitions.ToArray());

            program.run();

            Assert.AreEqual (0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual (1, program.getRuntimeErrorHandler().getErrors().Count);

            program.getRuntimeErrorHandler().printErrorsToConsole();
        }