Пример #1
0
        public void ExplicitConversions()
        {
            TextReader         programString = File.OpenText("code64.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();
            program.getCompileTimeErrorHandler().printErrorsToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #2
0
        public void CallingFunctionThatDoesNotExist()
        {
            TextReader         programString = File.OpenText("code69.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();
            program.getCompileTimeErrorHandler().printErrorsToConsole();

            Assert.AreEqual(1, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #3
0
        public void ConcatenatingArrays()
        {
            TextReader         programString = File.OpenText("code63.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();
            program.getCompileTimeErrorHandler().printErrorsToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("a: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]", program.Output[0]);
        }
Пример #4
0
        public void NonStaticArrayAssignment()
        {
            TextReader         programString = File.OpenText("code65.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();
            program.getCompileTimeErrorHandler().printErrorsToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("[5, 6]", program.Output[0]);
        }
Пример #5
0
        public void MakingSomeListFunctions()
        {
            TextReader         programString = File.OpenText("code66.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();
            program.getCompileTimeErrorHandler().printErrorsToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("johannes", program.Output[0]);
            Assert.AreEqual("heather", program.Output[1]);
            Assert.AreEqual("fredag", program.Output[2]);
        }
Пример #6
0
 public void Assignment()
 {
     StringReader programString = new StringReader("number a = 5");
     DefaultSprakRunner program = new DefaultSprakRunner(programString);
     program.run();
     Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
 }
Пример #7
0
        public void AllowWhitespaceAsCommaInFunctionCall()
        {
            TextReader programString = File.OpenText("code83.txt");
            DefaultSprakRunner program = new DefaultSprakRunner(programString);

            program.run();

            program.printOutputToConsole();
            program.getCompileTimeErrorHandler().printErrorsToConsole();

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

            Assert.AreEqual(1, program.Output.Count);
            Assert.AreEqual("500", program.Output[0]);
        }
Пример #8
0
        public void CalculateSimple()
        {
            StringReader       programString = new StringReader("5 + 3");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #9
0
        public void Assignment()
        {
            StringReader       programString = new StringReader("number a = 5");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #10
0
        public void ProgramThatShouldWorkButDoesnt()
        {
            TextReader         programString = File.OpenText("code40.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #11
0
        public void FunctionDefinition()
        {
            StringReader       programString = new StringReader("number apa(string a, string b) \n end");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #12
0
        public void CallUserdefinedFunction()
        {
            StringReader       programString = new StringReader("Foo()\nvoid Foo()\nend\nFoo()");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #13
0
        public void SingleVariableAssignment()
        {
            TextReader         programString = File.OpenText("code20.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            Assert.AreEqual("5", program.Output[0]);
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #14
0
        public void TryingToBreakOutOfProgram()
        {
            TextReader         programString = File.OpenText("code52.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual(0, program.Output.Count);
        }
Пример #15
0
        public void BasicArrayCreation()
        {
            TextReader programString = File.OpenText("code55.txt");
            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();
            program.printOutputToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("[3, 4, 5, 6]", program.Output[0]);
        }
Пример #16
0
        public void CallAnExternalFunctionWithArguments()
        {
            StringReader       programString = new StringReader("print(\"test!\")");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();
            Assert.AreEqual("test!", program.Output[0]);
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #17
0
        public void NegativeNumbersInExpression()
        {
            TextReader         programString = File.OpenText("code23.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();

            Assert.AreEqual("-13.5", program.Output[0]);
            Assert.AreEqual("-6", program.Output[1]);
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #18
0
        public void MathProblem()
        {
            StringReader programString = new StringReader("print(5 * 2 + 3 * 4)");

            DefaultSprakRunner program = new DefaultSprakRunner(programString);

            program.run();

            Assert.AreEqual("22", program.Output[0]);
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #19
0
        public void GetSingleElementOutOfArray()
        {
            TextReader         programString = File.OpenText("code61.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("hello", program.Output[0]);
        }
Пример #20
0
        public void Bools()
        {
            TextReader programString = File.OpenText("code48.txt");
            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();
            program.printOutputToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("true", program.Output[0]);
            Assert.AreEqual("false", program.Output[1]);
        }
Пример #21
0
        public void BasicArrayCreation()
        {
            TextReader         programString = File.OpenText("code55.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("[3, 4, 5, 6]", program.Output[0]);
        }
Пример #22
0
        public void ReturnFromMain()
        {
            TextReader         programString = File.OpenText("code51.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual(0, program.Output.Count);
        }
Пример #23
0
        public void FunctionCallWithParameters()
        {
            TextReader         programString = File.OpenText("code27.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();

            Assert.AreEqual("3", program.Output[0]);
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #24
0
        public void InTheMiddleOfFromToStatement()
        {
            TextReader         programString = File.OpenText("code70.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();
            program.getCompileTimeErrorHandler().printErrorsToConsole();

            //Assert.AreEqual(1, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #25
0
        public void SimpleConditional()
        {
            TextReader programString = File.OpenText("code36.txt");

            DefaultSprakRunner program = new DefaultSprakRunner(programString);

            program.run();

            Assert.AreEqual("15", program.Output[0]);
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #26
0
        public void HelloWorld()
        {
            StringReader programString = new StringReader("print(\"Hello World!\")");

            DefaultSprakRunner program = new DefaultSprakRunner(programString);

            program.run();

            Assert.AreEqual("Hello World!", program.Output[0]);
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #27
0
        public void PlusplusAndMinusminus()
        {
            TextReader         programString = File.OpenText("code47.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("11", program.Output[0]);
            Assert.AreEqual("9", program.Output[1]);
        }
Пример #28
0
        public void Bools()
        {
            TextReader         programString = File.OpenText("code48.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("true", program.Output[0]);
            Assert.AreEqual("false", program.Output[1]);
        }
Пример #29
0
        public void AllowMissingTypesInArgumentDeclaration()
        {
            StringReader programString = new StringReader(
                @"
            void f(x)

            end
            "
                );

            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();

            program.printOutputToConsole ();
            program.getCompileTimeErrorHandler().printErrorsToConsole ();
            program.getRuntimeErrorHandler().printErrorsToConsole ();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual(0, program.getRuntimeErrorHandler().getErrors().Count);
            Assert.AreEqual(0, program.Output.Count);
        }
Пример #30
0
        public void ChangingVariableValueInSubscope()
        {
            TextReader         programString = File.OpenText("code24.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();

            Assert.AreEqual("10", program.Output[0]);
            Assert.AreEqual("20", program.Output[1]);
            Assert.AreEqual("0", program.Output[2]);
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #31
0
        public void LoopThroughArray()
        {
            TextReader         programString = File.OpenText("code54.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("1", program.Output[0]);
            Assert.AreEqual("2", program.Output[1]);
            Assert.AreEqual("3", program.Output[2]);
        }
Пример #32
0
        public void AllowPlusSignBeforeNumbers()
        {
            StringReader programString = new StringReader(
                @"
            var a = +10
            var b = -2
            print(a + b)
            "
                );

            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();

            program.printOutputToConsole ();
            program.getCompileTimeErrorHandler ().printErrorsToConsole ();
            program.getRuntimeErrorHandler ().printErrorsToConsole ();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual(0, program.getRuntimeErrorHandler().getErrors().Count);
            Assert.AreEqual(1, program.Output.Count);
            Assert.AreEqual("8", program.Output[0]);
        }
Пример #33
0
        public void MathFunctions()
        {
            TextReader         programString = File.OpenText("code29.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();

            Assert.AreEqual("5", program.Output[0]);
            Assert.AreEqual("0.25", program.Output[1]);
            Assert.AreEqual("35", program.Output[2]);
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #34
0
        public void CreateArrayOfNames()
        {
            TextReader         programString = File.OpenText("code60.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("erik", program.Output[0]);
            Assert.AreEqual("heather", program.Output[1]);
            Assert.AreEqual("johannes", program.Output[2]);
            Assert.AreEqual("niklas", program.Output[3]);
        }
Пример #35
0
        public void AssigningToArray()
        {
            TextReader programString = File.OpenText("code62.txt");
            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();
            program.printOutputToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("abc", program.Output[0]);
            Assert.AreEqual("true", program.Output[1]);
            Assert.AreEqual("false", program.Output[2]);
            Assert.AreEqual("1", program.Output[3]);
            Assert.AreEqual("[1, 2, 3]", program.Output[4]);
        }
Пример #36
0
        public void ConcatenateStringAndStuff()
        {
            TextReader         programString = File.OpenText("code49.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("Evil: false", program.Output[0]);
            Assert.AreEqual("Age: 42", program.Output[1]);
            Assert.AreEqual("Name: unknown", program.Output[2]);
            Assert.AreEqual("abc6def", program.Output[3]);
        }
Пример #37
0
        public void AssigningToArray()
        {
            TextReader         programString = File.OpenText("code62.txt");
            DefaultSprakRunner program       = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("abc", program.Output[0]);
            Assert.AreEqual("true", program.Output[1]);
            Assert.AreEqual("false", program.Output[2]);
            Assert.AreEqual("1", program.Output[3]);
            Assert.AreEqual("[1, 2, 3]", program.Output[4]);
        }
Пример #38
0
        public void ReturnFromMain()
        {
            TextReader programString = File.OpenText("code51.txt");
            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();
            program.printOutputToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual(0, program.Output.Count);
        }
Пример #39
0
        public void SimpleConditional()
        {
            TextReader programString = File.OpenText("code36.txt");

            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();

            Assert.AreEqual("15", program.Output[0]);
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #40
0
        public void PrintingMathExpressions()
        {
            TextReader programString = File.OpenText("code19.txt");

            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();

            Assert.AreEqual("20", program.Output[0]);
            Assert.AreEqual("-4", program.Output[1]);
            Assert.AreEqual("11", program.Output[2]);
            Assert.AreEqual("-20", program.Output[3]);
            Assert.AreEqual("-1", program.Output[4]);
            Assert.AreEqual("0.5", program.Output[5]);
            Assert.AreEqual("-0.5", program.Output[6]);
            Assert.AreEqual("100.1", program.Output[7]);

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #41
0
 public void ProgramThatShouldWorkButDoesnt()
 {
     TextReader programString = File.OpenText("code40.txt");
     DefaultSprakRunner program = new DefaultSprakRunner(programString);
     program.run();
     Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
 }
Пример #42
0
        public void TryingToBreakOutOfProgram()
        {
            TextReader programString = File.OpenText("code52.txt");
            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual(0, program.Output.Count);
        }
Пример #43
0
        public void LengthOfArray()
        {
            TextReader programString = File.OpenText("code59.txt");
            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();
            program.printOutputToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("5", program.Output[0]);
        }
Пример #44
0
 public void FunctionDefinition()
 {
     StringReader programString = new StringReader("number apa(string a, string b) \n end");
     DefaultSprakRunner program = new DefaultSprakRunner(programString);
     program.run();
     Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
 }
Пример #45
0
        public void SimpleVariableUsage()
        {
            TextReader programString = File.OpenText("code21.txt");

            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();

            Assert.AreEqual(4, program.Output.Count);
            Assert.AreEqual("10", program.Output[0]);
            Assert.AreEqual("20", program.Output[1]);
            Assert.AreEqual("30", program.Output[2]);
            Assert.AreEqual("40", program.Output[3]);

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #46
0
        public void MakingSomeListFunctions()
        {
            TextReader programString = File.OpenText("code66.txt");
            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();
            program.printOutputToConsole();
            program.getCompileTimeErrorHandler().printErrorsToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("johannes", program.Output[0]);
            Assert.AreEqual("heather", program.Output[1]);
            Assert.AreEqual("fredag", program.Output[2]);
        }
Пример #47
0
 public void CalculateSimple()
 {
     StringReader programString = new StringReader("5 + 3");
     DefaultSprakRunner program = new DefaultSprakRunner(programString);
     program.run();
     Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
 }
Пример #48
0
        public void HelloWorld()
        {
            StringReader programString = new StringReader("print(\"Hello World!\")");

            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();

            Assert.AreEqual("Hello World!", program.Output[0]);
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #49
0
        public void LoopThroughArray2()
        {
            TextReader programString = File.OpenText("code58.txt");
            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();
            program.printOutputToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("10", program.Output[0]);
            Assert.AreEqual("11", program.Output[1]);
            Assert.AreEqual("12", program.Output[2]);
            Assert.AreEqual("13", program.Output[3]);
        }
Пример #50
0
        public void LoopBasics()
        {
            TextReader programString = File.OpenText("code28.txt");
            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();
            program.printOutputToConsole();

            Assert.AreEqual(10, program.Output.Count);
            for (int i = 0; i < 10; i++)
            {
                Assert.AreEqual(i, Convert.ToInt32(program.Output[i]));
            }
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #51
0
        public void SimpleFunctionCallInProgram()
        {
            TextReader programString = File.OpenText("code25.txt");
            DefaultSprakRunner program = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();

            Assert.AreEqual("42", program.Output[0]);
            Assert.AreEqual(1, program.Output.Count);
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #52
0
        public void NegativeNumbersInExpression()
        {
            TextReader programString = File.OpenText("code23.txt");
            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();

            Assert.AreEqual("-13.5", program.Output[0]);
            Assert.AreEqual("-6", program.Output[1]);
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #53
0
        public void ExplicitConversions()
        {
            TextReader programString = File.OpenText("code64.txt");
            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();
            program.printOutputToConsole();
            program.getCompileTimeErrorHandler().printErrorsToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #54
0
        public void NonStaticArrayAssignment()
        {
            TextReader programString = File.OpenText("code65.txt");
            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();
            program.printOutputToConsole();
            program.getCompileTimeErrorHandler().printErrorsToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("[5, 6]", program.Output[0]);
        }
Пример #55
0
 public void SingleVariableAssignment()
 {
     TextReader programString = File.OpenText("code20.txt");
     DefaultSprakRunner program = new DefaultSprakRunner(programString);
     program.run();
     Assert.AreEqual("5", program.Output[0]);
     Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
 }
Пример #56
0
        public void PlusplusAndMinusminus()
        {
            TextReader programString = File.OpenText("code47.txt");
            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();
            program.printOutputToConsole();

            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
            Assert.AreEqual("11", program.Output[0]);
            Assert.AreEqual("9", program.Output[1]);
        }
Пример #57
0
        public void MathFunctions()
        {
            TextReader programString = File.OpenText("code29.txt");
            DefaultSprakRunner program = new DefaultSprakRunner(programString);

            program.run();
            program.printOutputToConsole();

            Assert.AreEqual("5", program.Output[0]);
            Assert.AreEqual("0.25", program.Output[1]);
            Assert.AreEqual("35", program.Output[2]);
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #58
0
        public void InTheMiddleOfFromToStatement()
        {
            TextReader programString = File.OpenText("code70.txt");
            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();
            program.printOutputToConsole();
            program.getCompileTimeErrorHandler().printErrorsToConsole();

            //Assert.AreEqual(1, program.getCompileTimeErrorHandler().getErrors().Count);
        }
Пример #59
0
 public void CallAnExternalFunctionWithArguments()
 {
     StringReader programString = new StringReader("print(\"test!\")");
     DefaultSprakRunner program = new DefaultSprakRunner(programString);
     program.run();
     program.printOutputToConsole();
     Assert.AreEqual("test!", program.Output[0]);
     Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
 }
Пример #60
0
        public void MathProblem()
        {
            StringReader programString = new StringReader("print(5 * 2 + 3 * 4)");

            DefaultSprakRunner program = new DefaultSprakRunner(programString);
            program.run();

            Assert.AreEqual("22", program.Output[0]);
            Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
        }