PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/test/Main.cs

http://github.com/toshok/shelisp
C# | 96 lines | 77 code | 17 blank | 2 comment | 0 complexity | e423c8e237f3e9960e839fd1ae53b3af MD5 | raw file
Possible License(s): GPL-3.0
  1. using System;
  2. using System.IO;
  3. using Shelisp;
  4. using Shunit;
  5. public class Test {
  6. public static void Main (string[] args) {
  7. L.RegisterGlobalBuiltins (typeof (TestRunner).Assembly);
  8. var l = new L();
  9. #if false
  10. var list = L.make_list (1, 2, 3, "hi");
  11. Console.WriteLine (">>>>>>>> test 2");
  12. try {
  13. Console.WriteLine ("result = {0}", List.Fcar (l, L.make_list (1, 2, 3, 4, "hi")));
  14. }
  15. catch (Exception e) {
  16. Console.WriteLine ("failed {0}", e);
  17. }
  18. Console.WriteLine (">>>>>>>> test 3");
  19. try {
  20. Console.WriteLine ("result = {0}", L.make_list (L.Qcar, L.make_list (L.Qquote, list)).Eval(l));
  21. }
  22. catch (Exception e) {
  23. Console.WriteLine ("failed {0}", e);
  24. }
  25. Console.WriteLine (">>>>>>>> test 4");
  26. try {
  27. Shelisp.Object obj = Shelisp.Reader.Read ("(car '(1 2 3 \"hi\"))");
  28. Console.WriteLine ("result = {0}", obj.Eval(l));
  29. }
  30. catch (Exception e) {
  31. Console.WriteLine ("failed {0}", e);
  32. }
  33. Console.WriteLine (">>>>>>>> test 5");
  34. try {
  35. Shelisp.Object obj = Shelisp.Reader.Read ("((lambda (x) (car x)) '(1 2 3 \"hi\"))");
  36. Console.WriteLine ("result = {0}", obj.Eval(l));
  37. }
  38. catch (Exception e) {
  39. Console.WriteLine ("failed {0}", e);
  40. }
  41. Console.WriteLine (">>>>>>>> test 6");
  42. try {
  43. Shelisp.Object obj = Shelisp.Reader.Read ("(defun mycar (x) (car x))");
  44. obj.Eval(l);
  45. obj = Shelisp.Reader.Read ("(mycar '(1 2 3 \"hi\"))");
  46. Console.WriteLine ("result = {0}", obj.Eval(l));
  47. }
  48. catch (Exception e) {
  49. Console.WriteLine ("failed {0}", e);
  50. }
  51. Console.WriteLine (">>>>>>>> test 999");
  52. try {
  53. Shelisp.Object obj = Shelisp.Reader.Read (new StreamReader ("test.lisp"));
  54. obj.Eval (l);
  55. }
  56. catch (Exception e) {
  57. Console.WriteLine ("failed {0}", e);
  58. }
  59. Console.WriteLine (">>>>>>>> test 9999");
  60. try {
  61. Shelisp.Object obj = Shelisp.Reader.Read (new StreamReader ("/Users/toshok/.emacs"));
  62. obj.Eval (l);
  63. }
  64. catch (Exception e) {
  65. Console.WriteLine ("failed {0}", e);
  66. }
  67. // (car 5), throws an exception
  68. Console.WriteLine (L.make_list (L.Qcar, 5).Eval(l));
  69. #endif
  70. TestRunner.Initialize (l, true);
  71. Number number = new Number (5);
  72. Assert.That (number, Is.Numberp, "make sure constructor works");
  73. Assert.That (new List (L.intern ("symbol-value"), new List (L.Qquote, L.intern ("huuuunh"))), Signals.Error, "void-variable");
  74. /* the rest of the tests come from .el files in the current directory */
  75. l.Vload_path = new List ((Shelisp.String)Environment.CurrentDirectory, l.Vload_path);
  76. FileIO.Fload_file (l, "run-tests.el");
  77. TestRunner.GenerateReport();
  78. }
  79. }