getCompileTimeErrorHandler() 공개 메소드

public getCompileTimeErrorHandler ( ) : ProgrammingLanguageNr1.ErrorHandler
리턴 ProgrammingLanguageNr1.ErrorHandler
        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);
        }
        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();
        }