File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -26,9 +26,22 @@ $(YACC_OUT): $(YACC_SRC)
2626clean :
2727 rm -f $(TARGET ) $(LEX_OUT ) $(YACC_OUT ) $(YACC_HEADER )
2828
29+ TEST_CASES = \
30+ expressions \
31+ variable
32+
2933test : all
3034 @echo " == Running sample tests =="
31- @./c2lua tests/expr1.txt | diff -u - tests/expr1.ast && echo " expr1 ✓" || (echo " expr1 ✗" ; exit 1)
32- @./c2lua tests/expr2.txt | diff -u - tests/expr2.ast && echo " expr2 ✓" || (echo " expr2 ✗" ; exit 1)
33- @./c2lua tests/expr3.txt | diff -u - tests/expr3.ast && echo " expr3 ✓" || (echo " expr3 ✗" ; exit 1)
35+ @for case in $( TEST_CASES) ; do \
36+ output=$$(./c2lua tests/$$case.c ) ; \
37+ expected=$$(cat tests/$$case.lua ) ; \
38+ printf ' %s' " -- $$ case... " ; \
39+ if [ " $$ output" = " $$ expected" ]; then \
40+ echo " ok" ; \
41+ else \
42+ echo " fail" ; \
43+ printf ' Expected:\n%s\n\nGot:\n%s\n' " $$ expected" " $$ output" ; \
44+ exit 1; \
45+ fi ; \
46+ done
3447 @echo " All tests passed."
You can’t perform that action at this time.
0 commit comments