public void Test_StdLibObjects() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "teststdlib.fuel" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("DictCount= 2")); Assert.IsTrue(s.Contains("NewDictCount= 0")); Assert.IsTrue(s.Contains("DirListType= List")); Assert.IsTrue(s.Contains(@"File= .\FuelCompiler.dll")); Assert.IsTrue(s.Contains(@"File= .\FuelDebugger.dll")); Assert.IsTrue(s.Contains(@"File= .\FuelInterpreter.dll")); //Assert.IsTrue(s.Contains(@"File= .\fuel.exe")); Assert.IsTrue(s.Contains(@"File= .\teststdlib.fuel")); Assert.IsTrue(s.Contains("ListCount= 4")); Assert.IsTrue(s.Contains("item= { }")); Assert.IsTrue(s.Contains("newitem= 12")); Assert.IsTrue(s.Contains("NewListCount= 0")); Assert.IsTrue(s.Contains("ArrayCount= 5")); Assert.IsTrue(s.Contains("ArrayItem1= 1")); Assert.IsTrue(s.Contains("ArrayItem2= blub")); Assert.IsTrue(s.Contains("ArrayItem3= #t")); Assert.IsTrue(s.Contains("ArrayItem4= 42")); Assert.IsTrue(s.Contains("ArrayItem5= 123")); } }
public void Test_Compile() { using (/*ConsoleRedirector cr =*/ new ConsoleRedirector()) { var args = new[] { "-c", "simple.fuel" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); Assert.IsTrue(File.Exists("simple.fuel.exe")); } }
public void Test_MainExecute() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "-e", "(print (+ 1 2))" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s == "3"); } }
public void Test_MainVersion() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "-v" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.StartsWith(Lisp.ProgramName + " " + Lisp.Version + " from " + Lisp.Date)); } }
public void Test_MainFile() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "simple.fuel" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.StartsWith("hello world !")); } }
public void Test_Main() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new string[0]; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.StartsWith(Lisp.Name)); } }
public void Test_MainFileWithWrongCommandLineOption() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "--blub" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.StartsWith("Error: unknown option(s) --blub")); } }
public void Test_MainTestFunctionNotFound() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "-e", "(unknown-fcn (+ 1 2))" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("Function \"unknown-fcn\" not found --> line=1 start=1 stop=12")); } }
public void Test_MainTestParserBracketsOutOfBalance() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "-e", "(print ( (+ 1 2))" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("Brackets out of balance --> line=2 start=17 stop=18 module=")); } }
public void Test_MainTestParserUnexpectedToken() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "-e", "dummy (print (+ 1 2))" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("List expected in do --> line=1 start=0 stop=5 module=")); } }
public void Test_MainTestListExpectedInDo() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "-e", "(do (print 3) 5)" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("List expected in do --> line=1 start=13 stop=15")); } }
public void Test_CompileOutput() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "-s", "simple.fuel" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("public static void Main(string[] args)")); } }
public void Test_MainTestBadArgumentCount() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "-e", "(do (print 3) (defn x))" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("Bad argument count in def, has 1 expected 3 --> line=1 start=15 stop=19")); } }
public void Test_Profile() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "-m", "simple.fuel" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("Execution time =")); } }
public void Test_MainFileWithMoreThanOneLibraryOption() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "-l=.", "-l=some/path" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.StartsWith("Error: only one library path is supported")); } }
public void Test_MainTestNoList() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "-e", "(do (print 3) (map (lambda (x) (print x)) 3))" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("No list in map --> line=1 start=40 stop=40")); } }
public void Test_MainTestNoFunction() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "-e", "(do (print 3) (map 3 '(1 2 3)))" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("No function in map --> line=1 start=15 stop=18")); } }
public void Test_MultiPrintLn() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "multiprintln.fuel" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("hello\nworld\ndone.")); } }
public void Test_MainTestSymbolExpected() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "-e", "(do (print 3) (def 4 \"test\"))" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("Symbol expected --> line=1 start=15 stop=18")); } }
public void Test_MainTestSymbolNotFound() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "-e", "(setf a 5)" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("Symbol a not found --> line=1 start=1 stop=5")); } }
public void Test_DebugSetBreakpoints() { using (ConsoleRedirector cr = new ConsoleRedirector("b \"module name\":4 (== a 4)\nlist")) { var args = new[] { "-d", "simple.fuel" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("#1 line=4 module=module name condition=(== a 4)")); } }
public void Test_Documentation() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "--doc" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("lambda")); Assert.IsTrue(s.Contains("Syntax: (lambda (arguments) block)")); } }
public void Test_MainExecuteAutoBlockDecorate() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "-e", "(println \"hello world\") (println \"done.\")" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("hello world")); Assert.IsTrue(s.Contains("done")); } }
public void Test_Trace() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "-t", "simple.fuel" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("--> do")); Assert.IsTrue(s.Contains("--> print")); } }
public void Test_MainInteractiveImport() { using (ConsoleRedirector cr = new ConsoleRedirector("(import fuellib)\nmacros\nmodules\nfuncs\n")) { var args = new[] { "-i" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains(@".\Library\fuellib.fuel")); Assert.IsTrue(s.Contains(@"Dict-Remove --> function (Dict-Remove obj p0) : Function : module=.\Library\fuellib.fuel")); } }
public void Test_MainInteractiveSearchDoc() { using (ConsoleRedirector cr = new ConsoleRedirector("searchdoc arg")) { var args = new[] { "-i" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains(@"Syntax: (argscount)")); Assert.IsTrue(s.Contains(@"Syntax: (args)")); Assert.IsTrue(s.Contains(@"Syntax: (arg number)")); } }
public void Test_WriteAndReadFile() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "writereadfile.fuel" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("exists file = #t")); Assert.IsTrue(s.Contains("test non existing file = #f")); Assert.IsTrue(s.Contains("is equal = #t")); } }
public void Test_MainFileError() { using (ConsoleRedirector cr = new ConsoleRedirector()) { var args = new[] { "error.fuel" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains("Error executing script")); Assert.IsTrue(s.Contains("printx")); Assert.IsTrue(s.Contains("not found")); } }
public void Test_Compile2() { // test offline with: // fuel -s controlflow.fuel >controlflow.cs // C:\Windows\Microsoft.NET\Framework\v3.5\csc controlflow.cs /reference:cslispinterpreter.dll using (/*ConsoleRedirector cr =*/ new ConsoleRedirector()) { var args = new[] { "-c", "controlflow.fuel" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); Assert.IsTrue(File.Exists("controlflow.fuel.exe")); } }
public void Test_MainInteractiveDoc() { using (ConsoleRedirector cr = new ConsoleRedirector("doc\ndoc if")) { var args = new[] { "-i" }; LispMainHelper.MainExtended(args, Console.Out, Console.In); string s = cr.ToString().Trim(); Assert.IsTrue(s.Contains(@"doc --> (doc functionname ...)")); Assert.IsTrue(s.Contains(@"Returns and shows the documentation of all builtin functions or for the given function name(s).")); Assert.IsTrue(s.Contains(@"-------------------------------")); } }