public void SimpleIFTest() { TextReader programString = File.OpenText("code42.txt"); DefaultSprakRunner program = new DefaultSprakRunner(programString); program.run(); program.printOutputToConsole(); }
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 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 ForgettingReturn() { TextReader programString = File.OpenText("code57.txt"); DefaultSprakRunner program = new DefaultSprakRunner(programString); program.run(); program.printOutputToConsole(); program.getRuntimeErrorHandler().printErrorsToConsole(); Assert.AreEqual(1, program.getRuntimeErrorHandler().getErrors().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 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 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 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 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 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 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 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 TooLateVariableDefinition() { TextReader programString = File.OpenText("code67.txt"); DefaultSprakRunner program = new DefaultSprakRunner(programString); program.run(); program.printOutputToConsole(); program.getRuntimeErrorHandler().printErrorsToConsole(); Assert.AreNotEqual(0, program.getRuntimeErrorHandler().getErrors().Count); Assert.AreEqual("hello", program.Output[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); }
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 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 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 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 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 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 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 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 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 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 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 LispyLookingStatement() { TextReader programString = File.OpenText("code71.txt"); DefaultSprakRunner program = new DefaultSprakRunner(programString); program.run(); program.printOutputToConsole(); program.getCompileTimeErrorHandler().printErrorsToConsole(); }
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); }
public void ListWithStringKeys() { StringReader programString = new StringReader( @"array stuff = [] stuff['apa'] = 100 stuff['kossa'] = 200 stuff['fisk'] = 300 stuff[0] = 500 stuff[10] = 400 print(stuff[10]) print(stuff['apa']) print(stuff) " ); 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("400", program.Output[0]); Assert.AreEqual("100", program.Output[1]); }
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 InfiniteLoop() { StringReader programString = new StringReader( @" loop end " ); DefaultSprakRunner sprakRunner = new DefaultSprakRunner(programString); sprakRunner.run(30); GC.Collect(); GC.WaitForPendingFinalizers(); sprakRunner.printOutputToConsole (); sprakRunner.getCompileTimeErrorHandler().printErrorsToConsole (); sprakRunner.getRuntimeErrorHandler().printErrorsToConsole (); Assert.AreEqual(0, sprakRunner.getCompileTimeErrorHandler().getErrors().Count); Assert.AreEqual(0, sprakRunner.getRuntimeErrorHandler().getErrors().Count); Console.WriteLine("MemorySpace.nrOfMemorySpacesInMemory = " + MemorySpace.nrOfMemorySpacesInMemory); Console.WriteLine("InterpreterTwo.nrOfScopes = " + InterpreterTwo.nrOfScopes); //Assert.AreEqual(1, InterpreterTwo.nrOfScopes); }
public void HugeLoop() { StringReader programString = new StringReader( @"loop from 1 to 2000 print(@) 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(2000, program.Output.Count); }