Skip to content

Commit

Permalink
Added catch2 unit testing framework
Browse files Browse the repository at this point in the history
  • Loading branch information
jfecher committed Mar 9, 2018
1 parent 1761a7a commit 9c0fe8b
Show file tree
Hide file tree
Showing 54 changed files with 13,052 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ t.an
u.an
ante
bootante
unittest
syntax.tab.c
.clang_complete
src/parser.output
Expand Down
23 changes: 20 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ OBJFILES := $(patsubst src/%.cpp,obj/%.o,$(SRCFILES))
ANSRCFILES := $(shell find $(SRCDIRS) -type f -name "*.an")
ANOBJFILES := $(patsubst src/%.an,obj/%.ao,$(ANSRCFILES))

TESTFILES := $(shell find 'tests/' -maxdepth 1 -type f -name "*.an")
TESTFILES := $(shell find 'tests/integration/' -maxdepth 1 -type f -name "*.an")

#If src/parser.cpp is still present, remove it from objfiles so as to not double-compile it
OBJFILES := $(patsubst obj/parser.o,,$(OBJFILES))
Expand All @@ -43,6 +43,11 @@ ante: obj obj/parser.o $(OBJFILES) $(ANOBJFILES)
@echo Linking...
@$(CXX) obj/parser.o $(OBJFILES) $(ANOBJFILES) $(LLVMFLAGS) -o ante


run: ante
./ante


bootante: obj obj/parser.o $(OBJFILES) $(ANOBJFILES)
@echo Bootstrapping f16.ao...
@echo Compiling argtuple.o...
Expand All @@ -66,7 +71,7 @@ stdlib: $(LIBFILES) Makefile
new: clean ante

#create the obj folder if it is not present
obj:
obj:
@mkdir -p obj

debug_parser:
Expand All @@ -91,7 +96,19 @@ obj/parser.o: src/syntax.y Makefile
@$(CXX) -DAN_LIB_DIR=$(ANLIBDIR) $(CPPFLAGS) -MMD -MP -Iinclude -c $(PARSERSRC) -o $@


test:
test: unittest integrationtest


unittest: ante tests/unit/main.cpp
@$(CXX) -DAN_LIB_DIR=$(ANLIBDIR) -DF16_BOOT $(CPPFLAGS) -MMD -MP -Iinclude -c tests/unit/main.cpp -o obj/test-main.o
@mv obj/ante.o obj/ante.o.tmp
@$(CXX) -DAN_LIB_DIR=$(ANLIBDIR) -DF16_BOOT -DTEST_MAIN $(CPPFLAGS) -MMD -MP -Iinclude -c src/ante.cpp -o obj/ante.o
@$(CXX) obj/test-main.o obj/parser.o $(OBJFILES) $(ANOBJFILES) $(LLVMFLAGS) -o unittest
@mv obj/ante.o.tmp obj/ante.o
@./unittest


integrationtest:
@ERRC=0; \
for file in $(TESTFILES); do \
./ante -check $$file; \
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions tests/integration/moduleDriver.an
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//Test basic module imports from string literal
import "tests/integration/moduleLib.an"

let tup1 = (2, 3)
let tup2 = (4, 2)

print <| tup1.dotProduct tup2

print "done!"
10 changes: 10 additions & 0 deletions tests/integration/moduleImport.an
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//test basic conversion to filename
// Vec -> STD_LIB_DIR/vec.an
import Vec

//test conversion of relative paths
// Tests.Integration.FnDecl -> ./tests/integration/fnDecl.an
import Tests.Integration.FnDecl


print Vec(1 .. fact 5)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 0 additions & 9 deletions tests/moduleDriver.an

This file was deleted.

8 changes: 0 additions & 8 deletions tests/moduleImport.an

This file was deleted.

Loading

0 comments on commit 9c0fe8b

Please sign in to comment.