示例#1
0
 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"));
     }
 }
示例#2
0
 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"));
     }
 }
示例#3
0
 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");
     }
 }
示例#4
0
 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));
     }
 }
示例#5
0
 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 !"));
     }
 }
示例#6
0
 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));
     }
 }
示例#7
0
 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"));
     }
 }
示例#8
0
 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"));
     }
 }
示例#9
0
 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="));
     }
 }
示例#10
0
 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="));
     }
 }
示例#11
0
 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"));
     }
 }
示例#12
0
 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)"));
     }
 }
示例#13
0
 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"));
     }
 }
示例#14
0
 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 ="));
     }
 }
示例#15
0
 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"));
     }
 }
示例#16
0
 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"));
     }
 }
示例#17
0
 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"));
     }
 }
示例#18
0
 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."));
     }
 }
示例#19
0
 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"));
     }
 }
示例#20
0
 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"));
     }
 }
示例#21
0
 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)"));
     }
 }
示例#22
0
 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)"));
     }
 }
示例#23
0
 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"));
     }
 }
示例#24
0
 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"));
     }
 }
示例#25
0
 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"));
     }
 }
示例#26
0
 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)"));
     }
 }
示例#27
0
 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"));
     }
 }
示例#28
0
 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"));
     }
 }
示例#29
0
 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"));
     }
 }
示例#30
0
 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(@"-------------------------------"));
     }
 }