Skip to content

Commit ee7c813

Browse files
committed
changed test suite
1 parent 60ff2e5 commit ee7c813

2 files changed

Lines changed: 42 additions & 15 deletions

File tree

Naggum.Runtime/Cons.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ THE SOFTWARE. */
2020

2121
using System;
2222
using System.Text;
23+
using System.Collections;
2324

2425
namespace Naggum.Runtime
2526
{
@@ -115,7 +116,8 @@ bool IEquatable<Cons>.Equals(Cons other)
115116
public static Cons List(params object[] elements)
116117
{
117118
Cons list = null;
118-
foreach (var element in (elements.Reverse()))
119+
Array.Reverse(elements);
120+
foreach (var element in elements)
119121
{
120122
var tmp = new Cons(element, list);
121123
list = tmp;

tests/test.naggum

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,60 @@
1-
(defun main (args)
2-
(System.Console.WriteLine "Naggum test suite")
1+
(defun test-funcall (test-arg)
2+
(System.Console.WriteLine test-arg))
33

4-
(System.Console.WriteLine "Conditionals")
4+
(defun test-conditionals ()
5+
(System.Console.WriteLine "Conditionals:")
56
(if 1 (System.Console.WriteLine "Reduced if: OK"))
67
(if 1
78
(System.Console.WriteLine "Full if (true branch): OK")
8-
(System.Console.WriteLine "Full if (true branch): FAILURE"))
9+
(System.Console.WriteLine "Full if (true branch): FAILURE"))
910
(if 0
1011
(System.Console.WriteLine "Full if (false branch): FAILURE")
11-
(System.Console.WriteLine "Full if (false branch): OK"))
12-
12+
(System.Console.WriteLine "Full if (false branch): OK")))
13+
14+
(defun test-let ()
1315
(System.Console.Write "Let: ")
1416
(let ((ok "OK"))
15-
(System.Console.WriteLine ok))
16-
17+
(System.Console.WriteLine ok)))
18+
19+
(defun test-quote ()
1720
(System.Console.WriteLine "Quoting:")
1821
(System.Console.Write "Symbol: ") (System.Console.WriteLine (quote OK))
19-
(System.Console.Write "List: ") (System.Console.WriteLine (quote (OK)))
22+
(System.Console.Write "List: ") (System.Console.WriteLine (quote (OK))))
2023

24+
(defun test-new ()
2125
(System.Console.Write "Object construction: ")
2226
(let ((ok-sym (new Naggum.Runtime.Symbol "OK")))
23-
(System.Console.WriteLine ok-sym))
24-
27+
(System.Console.WriteLine ok-sym)))
28+
29+
(defun test-cons ()
2530
(System.Console.WriteLine "Cons:")
2631
(let ((test-car (new Naggum.Runtime.Cons "OK" "FAILURE"))
2732
(test-cdr (new Naggum.Runtime.Cons "FAILURE" "OK")))
2833
(System.Console.Write "CAR: ") (System.Console.WriteLine (Naggum.Runtime.Cons.Car test-car))
29-
(System.Console.Write "CDR: ") (System.Console.WriteLine (Naggum.Runtime.Cons.Cdr test-cdr)))
30-
34+
(System.Console.Write "CDR: ") (System.Console.WriteLine (Naggum.Runtime.Cons.Cdr test-cdr))))
35+
36+
(defun test-math ()
3137
(System.Console.WriteLine "Math:")
38+
(System.Console.WriteLine "Integers:")
3239
(System.Console.Write "2+2=") (System.Console.WriteLine (+ 2 2))
3340
(System.Console.Write "2-2=") (System.Console.WriteLine (- 2 2))
3441
(System.Console.Write "2*3=") (System.Console.WriteLine (* 2 3))
35-
(System.Console.Write "2/2=") (System.Console.WriteLine (/ 2 2)))
42+
(System.Console.Write "2/2=") (System.Console.WriteLine (/ 2 2))
43+
44+
(System.Console.WriteLine "Floats")
45+
(System.Console.Write "2.0 + 0.5=") (System.Console.WriteLine (+ 2.0 0.5))
46+
(System.Console.Write "3.0 - 1.5=") (System.Console.WriteLine (- 3.0 1.5))
47+
(System.Console.Write "2.0 * 0.7=") (System.Console.WriteLine (* 2.0 0.7))
48+
(System.Console.Write "3.0 / 2.0=") (System.Console.WriteLine (/ 3.0 2.0)))
49+
50+
(System.Console.WriteLine "Naggum test suite")
51+
52+
(System.Console.Write "Functions: ")
53+
(test-funcall "OK")
54+
55+
(test-conditionals)
56+
(test-let)
57+
(test-quote)
58+
(test-new)
59+
(test-cons)
60+
(test-math)

0 commit comments

Comments
 (0)