24 rm -f */deflist */*.gm.dat */*.qcc.dat */output
29 obj/%.gm.dat: %/main.qc obj
30 @echo "Testing:" $(subst obj/,,$(subst .gm.dat,,$@))
31 @$(QCC) -std=gmqcc -o $@ $< > $@.out 2> $@.err
33 obj/%.qcc.dat: %/main.qc obj
34 @echo "Testing:" $(subst obj/,,$(subst .qcc.dat,,$@))
35 @$(QCC) -std=qcc -o $@ $< > $@.out 2> $@.err
37 #######################################################################
39 # Macro which causes something to be compiled either with -std=qcc or without...
40 # this may at some point be extended to also store information about the progs.dat
41 # somewhere but for now we only need to build the object.
43 $(eval $dat = obj/${1}.${2}.dat)
47 #######################################################################
49 globaldefs: obj/globaldefs.gm.dat
50 @$(VM) -printdefs $< > $@/deflist
51 @diff $@/deflist $@/deflist.expected
53 $(eval $(call maketest,fielddefs,gm))
55 @$(VM) -printfields $< > $@/deflist
56 @diff $@/deflist $@/deflist.expected
58 $(eval $(call maketest,builtins,qcc))
60 @$(VM) -string "Hello 1" $< > $@/output
61 @test "`wc -l $@/output | awk '{ print $$1 }'`" = "1"
62 @grep -qE '^Hello 1$$' $@/output
63 @$(VM) -string "A test message Yeah" $< > $@/output
64 @test "`wc -l $@/output | awk '{ print $$1 }'`" = "1"
65 @grep -qE '^A test message Yeah$$' $@/output
67 $(eval $(call maketest,variadic,qcc))
69 @$(VM) -string "Hello 1" $< > $@/output
70 @test "`wc -l $@/output | awk '{ print $$1 }'`" = "1"
71 @grep -qE '^Hello 1$$' $@/output
72 @$(VM) -string "A test message Yeah" $< > $@/output
73 @test "`wc -l $@/output | awk '{ print $$1 }'`" = "1"
74 @grep -qE '^A test message Yeah$$' $@/output
76 $(eval $(call maketest,calls,qcc))
78 @$(VM) -float 1 -float 100 -float 10000 $< > $@/output
79 @grep -qE '^70907$$' $@/output
80 @$(VM) -float 3 -float 201 -float 90127 $< > $@/output
81 @grep -qE '^632719$$' $@/output
83 $(eval $(call maketest,if1,qcc))
85 @$(VM) -float 1 -float 100 -float 10000 $< > $@/output
86 @grep -qE '^One$$' $@/output
87 @$(VM) -float 2 -float 100 -float 10000 $< > $@/output
88 @grep -qE '^Two$$' $@/output
89 @$(VM) -float 3 -float 100 -float 10000 $< > $@/output
90 @grep -qE '^Three$$' $@/output
91 @$(VM) -float 4 -float 100 -float 10000 $< > $@/output
92 @grep -qE '^Else$$' $@/output
94 $(eval $(call maketest,loops1,qcc))
96 @$(VM) -float 0 $< > $@/output
97 @diff $@/output $@/0.expected
98 @$(VM) -float 1 $< > $@/output
99 @diff $@/output $@/1.expected
100 @$(VM) -float 4 $< > $@/output
101 @diff $@/output $@/4.expected
102 @$(VM) -float 10 $< > $@/output
103 @diff $@/output $@/10.expected
105 $(eval $(call maketest,maths1,qcc))
107 @$(VM) -float 0 -float 3 $< > $@/output
108 @diff $@/output $@/0.3.expected
109 @$(VM) -float 3 -float 6 $< > $@/output
110 @diff $@/output $@/3.6.expected
111 @$(VM) -float 0 -float 0 $< > $@/output
112 @diff $@/output $@/0.0.expected
114 $(eval $(call maketest,maths2,qcc))
116 @$(VM) -vector '1 2 3' -vector '4 5 6' $< > $@/output
117 @grep -qE '^dot = 32$$' $@/output
118 @$(VM) -vector '-5 12 5.5' -vector '4 -5 1' $< > $@/output
119 @grep -qE '^dot = -74.5$$' $@/output
120 @$(VM) -vector '-5 12 5.5' -vector '0 0 0' $< > $@/output
121 @grep -qE '^dot = 0$$' $@/output
123 $(eval $(call maketest,equality,qcc))
125 @$(VM) -float 1 -float 1 $< > $@/output
126 @diff $@/output $@/1.1.expected
127 @$(VM) -float 1 -float 0 $< > $@/output
128 @diff $@/output $@/1.0.expected
129 @$(VM) -float 0 -float 1 $< > $@/output
130 @diff $@/output $@/0.1.expected
132 $(eval $(call maketest,fields1,qcc))
134 @$(VM) -vector '150 2000 150' -vector '220 1300 -200' $< > $@/output
135 @diff $@/output $@/expected
137 invalid-types-ok: obj invalid-types/assign.qc invalid-types/op.qc invalid-types/call1.qc invalid-types/call2.qc invalid-types/call3.qc
138 @echo "Testing: invalid-types"
139 @if $(QCC) -std=qcc -o obj/invalid.dat invalid-types/op.qc > obj/invalid.out 2>&1 ; then echo "Successfully compiled a file which was supposed to fail: op.qc" ; false ; else true ; fi
140 @if $(QCC) -std=qcc -o obj/invalid.dat invalid-types/call1.qc > obj/invalid.out 2>&1 ; then echo "Successfully compiled a file which was supposed to fail: call1.qc" ; false ; else true ; fi
141 @if $(QCC) -std=qcc -o obj/invalid.dat invalid-types/call2.qc > obj/invalid.out 2>&1 ; then echo "Successfully compiled a file which was supposed to fail: call2.qc" ; false ; else true ; fi
142 @if $(QCC) -std=qcc -o obj/invalid.dat invalid-types/call3.qc > obj/invalid.out 2>&1 ; then echo "Successfully compiled a file which was supposed to fail: call3.qc" ; false ; else true ; fi
143 @if $(QCC) -std=qcc -o obj/invalid.dat invalid-types/assign.qc > obj/invalid.out 2>&1 ; then echo "Successfully compiled a file which was supposed to fail: assign.qc" ; false ; else true ; fi
144 @touch obj/invalid-types-ok
146 invalid-types: invalid-types-ok
148 $(eval $(call maketest,ngraphs,qcc))
150 @$(VM) $< > $@/output
151 @diff $@/output $@/expected
153 invalid-assign-ok: obj invalid-assign/main.qc
154 @echo "Testing: invalid-assign"
155 @if $(QCC) -std=qcc -o obj/invalid.dat invalid-assign/main.qc > obj/invalid.out 2>&1 ; then echo "Successfully compiled a file which was supposed to fail: invalid-assign/main.qc" ; false ; else true ; fi
157 invalid-assign: invalid-assign-ok
159 #######################################################################