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); }
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); }
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]); }
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]); }
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]); }
public void Assignment() { StringReader programString = new StringReader("number a = 5"); DefaultSprakRunner program = new DefaultSprakRunner(programString); program.run(); Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count); }
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]); }
public void CalculateSimple() { StringReader programString = new StringReader("5 + 3"); DefaultSprakRunner program = new DefaultSprakRunner(programString); program.run(); Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count); }
public void ProgramThatShouldWorkButDoesnt() { TextReader programString = File.OpenText("code40.txt"); DefaultSprakRunner program = new DefaultSprakRunner(programString); program.run(); Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count); }
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); }
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); }
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); }
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); }
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]); }
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); }
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); }
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); }
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]); }
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]); }
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); }
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); }
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); }
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); }
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); }
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]); }
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); }
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); }
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]); }
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]); }
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); }
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]); }
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]); }
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]); }
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); }
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]); }
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); }
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]); }
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); }
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); }