示例#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);
        }