25 rm -f */deflist */*.gm.dat */*.qcc.dat */output
30 obj/%.gm.dat: %/main.qc obj
31 @echo "Testing:" $(subst obj/,,$(subst .gm.dat,,$@))
32 @$(QCC) -std=gmqcc -o $@ $< > $@.out 2> $@.err
34 obj/%.qcc.dat: %/main.qc obj
35 @echo "Testing:" $(subst obj/,,$(subst .qcc.dat,,$@))
36 @$(QCC) -std=qcc -o $@ $< > $@.out 2> $@.err
38 #######################################################################
40 # Macro which causes something to be compiled either with -std=qcc or without...
41 # this may at some point be extended to also store information about the progs.dat
42 # somewhere but for now we only need to build the object.
44 $(eval $dat = obj/${1}.${2}.dat)
48 #######################################################################
50 globaldefs: obj/globaldefs.gm.dat
51 @$(VM) -printdefs $< > $@/deflist
52 @diff $@/deflist $@/deflist.expected
54 $(eval $(call maketest,fielddefs,gm))
56 @$(VM) -printfields $< > $@/deflist
57 @diff $@/deflist $@/deflist.expected
59 $(eval $(call maketest,builtins,qcc))
61 @$(VM) -string "Hello 1" $< > $@/output
62 @test "`wc -l $@/output | awk '{ print $$1 }'`" = "1"
63 @grep -qE '^Hello 1$$' $@/output
64 @$(VM) -string "A test message Yeah" $< > $@/output
65 @test "`wc -l $@/output | awk '{ print $$1 }'`" = "1"
66 @grep -qE '^A test message Yeah$$' $@/output
68 $(eval $(call maketest,variadic,qcc))
70 @$(VM) -string "Hello 1" $< > $@/output
71 @test "`wc -l $@/output | awk '{ print $$1 }'`" = "1"
72 @grep -qE '^Hello 1$$' $@/output
73 @$(VM) -string "A test message Yeah" $< > $@/output
74 @test "`wc -l $@/output | awk '{ print $$1 }'`" = "1"
75 @grep -qE '^A test message Yeah$$' $@/output
77 $(eval $(call maketest,calls,qcc))
79 @$(VM) -float 1 -float 100 -float 10000 $< > $@/output
80 @grep -qE '^70907$$' $@/output
81 @$(VM) -float 3 -float 201 -float 90127 $< > $@/output
82 @grep -qE '^632719$$' $@/output
84 $(eval $(call maketest,if1,qcc))
86 @$(VM) -float 1 -float 100 -float 10000 $< > $@/output
87 @grep -qE '^One$$' $@/output
88 @$(VM) -float 2 -float 100 -float 10000 $< > $@/output
89 @grep -qE '^Two$$' $@/output
90 @$(VM) -float 3 -float 100 -float 10000 $< > $@/output
91 @grep -qE '^Three$$' $@/output
92 @$(VM) -float 4 -float 100 -float 10000 $< > $@/output
93 @grep -qE '^Else$$' $@/output
95 $(eval $(call maketest,loops1,qcc))
97 @$(VM) -float 0 $< > $@/output
98 @diff $@/output $@/0.expected
99 @$(VM) -float 1 $< > $@/output
100 @diff $@/output $@/1.expected
101 @$(VM) -float 4 $< > $@/output
102 @diff $@/output $@/4.expected
103 @$(VM) -float 10 $< > $@/output
104 @diff $@/output $@/10.expected
106 $(eval $(call maketest,maths1,qcc))
108 @$(VM) -float 0 -float 3 $< > $@/output
109 @diff $@/output $@/0.3.expected
110 @$(VM) -float 3 -float 6 $< > $@/output
111 @diff $@/output $@/3.6.expected
112 @$(VM) -float 0 -float 0 $< > $@/output
113 @diff $@/output $@/0.0.expected
115 $(eval $(call maketest,maths2,qcc))
117 @$(VM) -vector '1 2 3' -vector '4 5 6' $< > $@/output
118 @grep -qE '^dot = 32$$' $@/output
119 @$(VM) -vector '-5 12 5.5' -vector '4 -5 1' $< > $@/output
120 @grep -qE '^dot = -74.5$$' $@/output
121 @$(VM) -vector '-5 12 5.5' -vector '0 0 0' $< > $@/output
122 @grep -qE '^dot = 0$$' $@/output
124 $(eval $(call maketest,equality,qcc))
126 @$(VM) -float 1 -float 1 $< > $@/output
127 @diff $@/output $@/1.1.expected
128 @$(VM) -float 1 -float 0 $< > $@/output
129 @diff $@/output $@/1.0.expected
130 @$(VM) -float 0 -float 1 $< > $@/output
131 @diff $@/output $@/0.1.expected
133 $(eval $(call maketest,fields1,qcc))
135 @$(VM) -vector '150 2000 150' -vector '220 1300 -200' $< > $@/output
136 @diff $@/output $@/expected
138 invalid-types-ok: obj invalid-types/assign.qc invalid-types/op.qc invalid-types/call1.qc invalid-types/call2.qc invalid-types/call3.qc
139 @echo "Testing: invalid-types"
140 @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
141 @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
142 @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
143 @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
144 @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
145 @touch obj/invalid-types-ok
147 invalid-types: invalid-types-ok
149 $(eval $(call maketest,ngraphs,qcc))
151 @$(VM) $< > $@/output
152 @diff $@/output $@/expected
154 invalid-assign-ok: obj invalid-assign/main.qc
155 @echo "Testing: invalid-assign"
156 @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
158 invalid-assign: invalid-assign-ok
160 $(eval $(call maketest,field-parameters,qcc))
162 @$(VM) $< > $@/output
163 @diff $@/output $@/expected
165 #######################################################################