aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-07-20 03:23:40 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-07-20 04:19:03 +0200
commitf4c7b0224f8d17149633dd826f6e506f796b6999 (patch)
tree7b4d21dd7711303edb57dc0026439f26e2bd6463
parentBunch of work on cpp. (diff)
downloadcalp-f4c7b0224f8d17149633dd826f6e506f796b6999.tar.gz
calp-f4c7b0224f8d17149633dd826f6e506f796b6999.tar.xz
Add preliminary tests for cpp.
-rw-r--r--tests/cpp.scm36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/cpp.scm b/tests/cpp.scm
new file mode 100644
index 00000000..1d4e62f3
--- /dev/null
+++ b/tests/cpp.scm
@@ -0,0 +1,36 @@
+(define run (compose parse-lexeme-tree lex))
+
+(test-equal
+ '(+ (post-increment (dereference C)) 3)
+ (run "(*C)++ + 3"))
+
+
+(test-equal
+ '(+ (post-increment (dereference C)) 3)
+ (run "*C++ + 3"))
+
+(test-equal
+ '(post-increment (dereference C))
+ (run "*C++"))
+
+(test-equal
+ '(+ (post-increment C) (post-increment C))
+ (run "C++ + C++"))
+
+(test-equal
+ '(+ (pre-increment C) (pre-increment C))
+ (run "++C + ++C"))
+
+
+(test-equal
+ '(+ 2 (* 2 2))
+ (run "2 + 2 * 2"))
+
+(test-equal
+ '(+ (* 2 2) 2)
+ (run "2 * 2 + 2"))
+
+(test-equal
+ '(+ 2 2 2)
+ (run "2+2+2"))
+