本文整理汇总了C#中DefaultSprakRunner.getRuntimeErrorHandler方法的典型用法代码示例。如果您正苦于以下问题:C# DefaultSprakRunner.getRuntimeErrorHandler方法的具体用法?C# DefaultSprakRunner.getRuntimeErrorHandler怎么用?C# DefaultSprakRunner.getRuntimeErrorHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DefaultSprakRunner
的用法示例。
在下文中一共展示了DefaultSprakRunner.getRuntimeErrorHandler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AllowMissingTypesInArgumentDeclaration
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);
}
示例2: AllowPlusSignBeforeNumbers
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]);
}
示例3: AllowWhitespaceAsCommaInFunctionCall
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]);
}
示例4: CrashbugWithElseifWithoutEnd
public void CrashbugWithElseifWithoutEnd()
{
TextReader programString = File.OpenText("code80.txt");
DefaultSprakRunner program = new DefaultSprakRunner(programString);
program.run();
program.printOutputToConsole();
program.getCompileTimeErrorHandler().printErrorsToConsole();
Assert.AreEqual(1, program.getCompileTimeErrorHandler().getErrors().Count);
Assert.AreEqual(0, program.getRuntimeErrorHandler().getErrors().Count);
}
示例5: ConcatenatingArrays
public void ConcatenatingArrays()
{
TextReader programString = File.OpenText("code63.txt");
DefaultSprakRunner program = new DefaultSprakRunner(programString);
program.run();
program.printOutputToConsole();
program.getCompileTimeErrorHandler().printErrorsToConsole();
program.getRuntimeErrorHandler().printErrorsToConsole();
Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
Assert.AreEqual("a: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]", program.Output[0]);
}
示例6: NamedLoopVariableWithRange
public void NamedLoopVariableWithRange()
{
StringReader programString = new StringReader(
@"loop a from 10 to 13
print(a)
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(4, program.Output.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]);
}
示例7: ForgettingReturn
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);
}
示例8: InfiniteLoop
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);
}
示例9: PlusEqualsInArray
public void PlusEqualsInArray()
{
StringReader programString = new StringReader(
@"
array a = [10,20,30]
a[1] += 5
print(a)
"
);
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("[10, 25, 30]", program.Output[0]);
}
示例10: EbbesArrayTrouble
public void EbbesArrayTrouble()
{
StringReader programString = new StringReader(
@"
array a
loop i from 0 to 9
a[i] = ['hej', 'svej']
end
print('count: ' + Count(a))
var a0 = a[0]
print(a0[0])
print(a0[1])
"
);
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(3, program.Output.Count);
Assert.AreEqual("count: 10", program.Output[0]);
Assert.AreEqual("hej", program.Output[1]);
Assert.AreEqual("svej", program.Output[2]);
}
示例11: UseRangeTypeInLoop
public void UseRangeTypeInLoop()
{
StringReader programString = new StringReader(
@"number sum = 0
loop from 1 to 100
sum += @
end
print(sum)
print([1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9])
"
);
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("5050", program.Output[0]);
}
示例12: SimpleArrayPrint
public void SimpleArrayPrint()
{
StringReader programString = new StringReader(
@"var l = [10, 20, 30]
print(l)"
);
DefaultSprakRunner program = new DefaultSprakRunner(programString);
program.run();
program.printOutputToConsole ();
Assert.AreEqual("[10, 20, 30]", program.Output[0]);
Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
Assert.AreEqual(0, program.getRuntimeErrorHandler().getErrors().Count);
}
示例13: SimpleAndStatements
public void SimpleAndStatements()
{
TextReader programString = File.OpenText("code81.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("yep", program.Output[0]);
}
示例14: SetIndexInRange
public void SetIndexInRange()
{
StringReader programString = new StringReader(
@"var r = from 1 to 100
print(r)
r[0] = 100
"
);
DefaultSprakRunner program = new DefaultSprakRunner(programString);
program.run();
program.printOutputToConsole ();
program.getCompileTimeErrorHandler ().printErrorsToConsole ();
program.getRuntimeErrorHandler ().printErrorsToConsole ();
Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
Assert.AreEqual(1, program.getRuntimeErrorHandler().getErrors().Count);
}
示例15: RootAprox
public void RootAprox()
{
TextReader programString = File.OpenText("code43.txt");
DefaultSprakRunner program = new DefaultSprakRunner(programString);
program.run();
program.printOutputToConsole();
program.getRuntimeErrorHandler ().printErrorsToConsole ();
Assert.AreEqual(0, program.getCompileTimeErrorHandler().getErrors().Count);
Assert.AreEqual("3", program.Output[0]);
Assert.AreEqual("4", program.Output[1]);
}