Exemple #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"));
     }
 }
Exemple #2
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));
     }
 }
Exemple #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");
     }
 }
Exemple #4
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 !"));
     }
 }
Exemple #5
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)"));
     }
 }
Exemple #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));
     }
 }
Exemple #7
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"));
     }
 }
Exemple #8
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"));
     }
 }
Exemple #9
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 ="));
     }
 }
Exemple #10
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"));
     }
 }
Exemple #11
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"));
     }
 }
Exemple #12
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"));
     }
 }
Exemple #13
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."));
     }
 }
Exemple #14
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"));
     }
 }
Exemple #15
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"));
     }
 }
Exemple #16
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)"));
     }
 }
Exemple #17
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"));
     }
 }
Exemple #18
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"));
     }
 }
Exemple #19
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="));
     }
 }
Exemple #20
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="));
     }
 }
Exemple #21
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"));
     }
 }
Exemple #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)"));
     }
 }
Exemple #23
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"));
     }
 }
Exemple #24
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"));
     }
 }
Exemple #25
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(@"-------------------------------"));
     }
 }
Exemple #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)"));
     }
 }
Exemple #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"));
     }
 }
Exemple #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"));
     }
 }
Exemple #29
0
 public void Test_DebugModule()
 {
     using (ConsoleRedirector cr = new ConsoleRedirector("b .\\testmodule.fuel:4\nlist\nr\nk\nl"))
     {
         var args = new[] { "-d", "test.fuel", "-l=." };
         LispMainHelper.MainExtended(args, Console.Out, Console.In);
         string s = cr.ToString().Trim();
         Assert.IsTrue(s.Contains("FUEL(isp)-DBG> Breakpoints:"));
         Assert.IsTrue(s.Contains("#1   line=4     module=.\\testmodule.fuel         condition="));
         Assert.IsTrue(s.Contains("       1 name=<main>                              lineno=4    module=test.fuel"));
         Assert.IsTrue(s.Contains("-->    2 name=blub                                lineno=4    module=.\\testmodule.fuel"));
         Assert.IsTrue(s.Contains("x --> 8                                        : Int"));
     }
 }
Exemple #30
0
        public void Test_MainInteractive()
        {
            using (var cr = new ConsoleRedirector("help\nfuncs\nbuiltins\nq\n"))
            {
                var args = new[] { "-i" };
                LispMainHelper.MainExtended(args, Console.Out, Console.In);

                string result = cr.ToString();
                TestContext.WriteLine("Result=" + result);
                string s = result;
                Assert.IsTrue(s.Contains("DBG>"));
                Assert.IsTrue(s.Contains("Type \"help\" for informations."));
                Assert.IsTrue(s.Contains("help for interactive loop:")); // help
                Assert.IsTrue(s.Contains("equal --> function (equal expr1 expr2)             : Function"));
                Assert.IsTrue(s.Contains("define-macro --> function (define-macro name (arguments) statement) : Function  : module=<builtin>"));
            }
        }