Skip to content
Browse files

add simple parser test runner

  • Loading branch information...
1 parent 25510bd commit 2714dd3385d507ba3f140c9b9092f4c608978fa9 @tj tj committed
Showing with 37 additions and 13 deletions.
  1. +5 −2 Makefile
  2. +18 −0 test/parser.sh
  3. +7 −0 test/parser/assign.chain.luna
  4. +1 −0 test/parser/assign.chain.out
  5. +5 −0 test/parser/assign.luna
  6. +1 −0 test/parser/assign.out
  7. +0 −11 test/test.c
View
7 Makefile
@@ -24,9 +24,12 @@ luna: $(OBJ)
@$(CC) -c $(CFLAGS) $< -o $@
@printf "\e[36mCC\e[90m %s\e[0m\n" $@
-test: test_runner
+test: test_runner test-parser
@./$<
+test-parser:
+ @sh test/parser.sh
+
test_runner: $(TEST_OBJ)
$(CC) $^ -o $@
@@ -39,4 +42,4 @@ uninstall:
clean:
rm -f luna test_runner $(OBJ) $(TEST_OBJ)
-.PHONY: clean test install uninstall
+.PHONY: clean test test-parser install uninstall
View
18 test/parser.sh
@@ -0,0 +1,18 @@
+
+for file in test/parser/*.luna; do
+ out=${file/luna/out}
+ ast=$(./luna --ast $file)
+ expected=$(cat $out)
+ if [[ "$ast" != "$expected" ]]; then
+ echo
+ echo " $file failed:"
+ echo
+ echo " expected:"
+ echo " '$expected''"
+ echo
+ echo " got:"
+ echo " '$ast'"
+ echo
+ exit 1
+ fi
+done
View
7 test/parser/assign.chain.luna
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+foo = bar = baz
View
1 test/parser/assign.chain.out
@@ -0,0 +1 @@
+(= (id foo) (= (id bar) (id baz)))
View
5 test/parser/assign.luna
@@ -0,0 +1,5 @@
+
+
+# wtf whitespace...
+foo = bar
+
View
1 test/parser/assign.out
@@ -0,0 +1 @@
+(= (id foo) (id bar))
View
11 test/test.c
@@ -295,17 +295,6 @@ test_string() {
}
/*
- * Test object mixins.
- */
-
-static void
-test_object_mixins() {
- luna_object_t *num = luna_int_new(11);
- assert(LUNA_TYPE_INT == num->type);
- assert(11 == num->value.as_int);
-}
-
-/*
* Test the given `fn`.
*/

0 comments on commit 2714dd3

Please sign in to comment.
Something went wrong with that request. Please try again.