]> code.bitgloo.com Git - clyne/interpreter.git/commitdiff
tests to folder
authorClyne Sullivan <tullivan99@gmail.com>
Tue, 24 Apr 2018 18:13:29 +0000 (14:13 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Tue, 24 Apr 2018 18:13:29 +0000 (14:13 -0400)
tests/test1 [new file with mode: 0644]
tests/test10 [new file with mode: 0644]
tests/test2 [new file with mode: 0644]
tests/test3 [new file with mode: 0644]
tests/test4 [new file with mode: 0644]
tests/test5 [new file with mode: 0644]
tests/test6 [new file with mode: 0644]
tests/test7 [new file with mode: 0644]
tests/test8 [new file with mode: 0644]
tests/test9 [new file with mode: 0644]

diff --git a/tests/test1 b/tests/test1
new file mode 100644 (file)
index 0000000..cc04423
--- /dev/null
@@ -0,0 +1,18 @@
+# test1
+# arithmetic tests
+# looking for proper basic function, respect for order of ops,
+# and respect for parentheses
+
+print(2 + 5)
+print(14 - 9)
+print(3 * 8 + 3)
+print(9 - 3 / 2)
+print(3 * (8 + 3))
+print((9 - 3) / 2)
+print((4 + 5) * ((9 - 1) + 3))
+print(5 - 3 + 4)
+print("")
+print(-4)
+print(-4 + -3)
+print(-8+13)
+print(4- -9)
diff --git a/tests/test10 b/tests/test10
new file mode 100644 (file)
index 0000000..9b18c4f
--- /dev/null
@@ -0,0 +1,3 @@
+a = "a"
+append(append(append(a, "llo"), " mate!"), 37)
+print(a)
diff --git a/tests/test2 b/tests/test2
new file mode 100644 (file)
index 0000000..3a03b15
--- /dev/null
@@ -0,0 +1,17 @@
+# test2
+# variable and function tests
+# show variable recognition and proper c-function handling
+
+print(a * 1)
+print(3 + b)
+
+print(a = 5)
+print(a * 1)
+
+print(c = 4)
+print(a / c)
+
+print(b = 2)
+print(d = 8)
+
+print(d + (e = 4))
diff --git a/tests/test3 b/tests/test3
new file mode 100644 (file)
index 0000000..6bf6064
--- /dev/null
@@ -0,0 +1,25 @@
+# test3
+# verify builtin functions, conditionals and such
+
+a = 5
+
+func(checka) {
+       if (a == 5) {
+               print("a == 5")
+       } else {
+               print("a != 5")
+       }
+}
+
+checka()
+
+print("Increment a...")
+a = a + 1
+checka()
+
+d = 0
+while (d < 20) {
+       print(d)
+       d = d + 1
+}
+
diff --git a/tests/test4 b/tests/test4
new file mode 100644 (file)
index 0000000..b44dae1
--- /dev/null
@@ -0,0 +1,13 @@
+# test4
+# find memory leaks
+
+#x = 4
+#y = solve("x-2")
+#print(y)
+#print("")
+
+#y = solve("3*x")
+#print(y)
+
+y = solve("-")
+#y = solve("x*x*x*x*x")
diff --git a/tests/test5 b/tests/test5
new file mode 100644 (file)
index 0000000..74ce439
--- /dev/null
@@ -0,0 +1,10 @@
+# test5
+# solver test
+
+while (1) {
+       input = gets
+       if (input == "exit") {
+               exit
+       }
+       print(solve(input))
+}
diff --git a/tests/test6 b/tests/test6
new file mode 100644 (file)
index 0000000..bc17de2
--- /dev/null
@@ -0,0 +1,10 @@
+# test6
+# used to fix memory leak in setting defined strings
+
+test = "hello"
+test = "fail"
+a = test
+test = "acd"
+
+print(a)
+print(test)
diff --git a/tests/test7 b/tests/test7
new file mode 100644 (file)
index 0000000..dd4defb
--- /dev/null
@@ -0,0 +1,14 @@
+j = 6
+
+func(test) {
+       i = 0
+       while (i < 10) {
+               i = i + 1
+       }
+
+       j = 15
+}
+
+print(i)
+print(" ")
+print(j)
diff --git a/tests/test8 b/tests/test8
new file mode 100644 (file)
index 0000000..36e5b9c
--- /dev/null
@@ -0,0 +1,23 @@
+array(a, 10)
+
+i = 0
+while (i < 10) {
+       a.i = i * 2
+       i = i + 1
+}
+
+i = 0
+while (i < 10) {
+       print(a.i)
+       i = i + 1
+}
+
+a.20 = 143
+print(a.20)
+print(a.19)
+
+print("Strings:")
+str = "Hello!"
+print(str.0)
+print(str.2)
+print(str.4)
diff --git a/tests/test9 b/tests/test9
new file mode 100644 (file)
index 0000000..66a9cfb
--- /dev/null
@@ -0,0 +1,16 @@
+x = 9
+print(3x)
+print(2x + 5)
+print(x - 9x)
+print(5 + (3x))
+print((x - 4 * 5)2)
+y = 8
+# 2*x*y = 144
+print(x2y)
+print(2xy)
+print(2x*y)
+
+A = 5
+B = 9
+print("")
+print(2AB)