20 functions-as-parameters \
21 shadow-qcc shadow-gmqcc
27 rm -f */deflist */*.gm.dat */*.qcc.dat */output
32 obj/%.gm.dat: %/main.qc obj
33 @echo "Testing:" $(subst obj/,,$(subst .gm.dat,,$@))
34 @$(QCC) -std=gmqcc -o $@ $< > $@.out 2> $@.err
36 obj/%.qcc.dat: %/main.qc obj
37 @echo "Testing:" $(subst obj/,,$(subst .qcc.dat,,$@))
38 @$(QCC) -std=qcc -o $@ $< > $@.out 2> $@.err
40 #######################################################################
42 # Macro which causes something to be compiled either with -std=qcc or without...
43 # this may at some point be extended to also store information about the progs.dat
44 # somewhere but for now we only need to build the object.
46 $(eval $dat = obj/${1}.${2}.dat)
50 #######################################################################
52 globaldefs: obj/globaldefs.gm.dat
53 @$(VM) -printdefs $< > $@/deflist
54 @diff $@/deflist $@/deflist.expected
56 $(eval $(call maketest,fielddefs,gm))
58 @$(VM) -printfields $< > $@/deflist
59 @diff $@/deflist $@/deflist.expected
61 $(eval $(call maketest,builtins,qcc))
63 @$(VM) -string "Hello 1" $< > $@/output
64 @test "`wc -l $@/output | awk '{ print $$1 }'`" = "1"
65 @grep -qE '^Hello 1$$' $@/output
66 @$(VM) -string "A test message Yeah" $< > $@/output
67 @test "`wc -l $@/output | awk '{ print $$1 }'`" = "1"
68 @grep -qE '^A test message Yeah$$' $@/output
70 $(eval $(call maketest,variadic,qcc))
72 @$(VM) -string "Hello 1" $< > $@/output
73 @test "`wc -l $@/output | awk '{ print $$1 }'`" = "1"
74 @grep -qE '^Hello 1$$' $@/output
75 @$(VM) -string "A test message Yeah" $< > $@/output
76 @test "`wc -l $@/output | awk '{ print $$1 }'`" = "1"
77 @grep -qE '^A test message Yeah$$' $@/output
79 $(eval $(call maketest,calls,qcc))
81 @$(VM) -float 1 -float 100 -float 10000 $< > $@/output
82 @grep -qE '^70907$$' $@/output
83 @$(VM) -float 3 -float 201 -float 90127 $< > $@/output
84 @grep -qE '^632719$$' $@/output
86 $(eval $(call maketest,if1,qcc))
88 @$(VM) -float 1 -float 100 -float 10000 $< > $@/output
89 @grep -qE '^One$$' $@/output
90 @$(VM) -float 2 -float 100 -float 10000 $< > $@/output
91 @grep -qE '^Two$$' $@/output
92 @$(VM) -float 3 -float 100 -float 10000 $< > $@/output
93 @grep -qE '^Three$$' $@/output
94 @$(VM) -float 4 -float 100 -float 10000 $< > $@/output
95 @grep -qE '^Else$$' $@/output
97 $(eval $(call maketest,loops1,qcc))
99 @$(VM) -float 0 $< > $@/output
100 @diff $@/output $@/0.expected
101 @$(VM) -float 1 $< > $@/output
102 @diff $@/output $@/1.expected
103 @$(VM) -float 4 $< > $@/output
104 @diff $@/output $@/4.expected
105 @$(VM) -float 10 $< > $@/output
106 @diff $@/output $@/10.expected
108 $(eval $(call maketest,maths1,qcc))
110 @$(VM) -float 0 -float 3 $< > $@/output
111 @diff $@/output $@/0.3.expected
112 @$(VM) -float 3 -float 6 $< > $@/output
113 @diff $@/output $@/3.6.expected
114 @$(VM) -float 0 -float 0 $< > $@/output
115 @diff $@/output $@/0.0.expected
117 $(eval $(call maketest,maths2,qcc))
119 @$(VM) -vector '1 2 3' -vector '4 5 6' $< > $@/output
120 @grep -qE '^dot = 32$$' $@/output
121 @$(VM) -vector '-5 12 5.5' -vector '4 -5 1' $< > $@/output
122 @grep -qE '^dot = -74.5$$' $@/output
123 @$(VM) -vector '-5 12 5.5' -vector '0 0 0' $< > $@/output
124 @grep -qE '^dot = 0$$' $@/output
126 $(eval $(call maketest,equality,qcc))
128 @$(VM) -float 1 -float 1 $< > $@/output
129 @diff $@/output $@/1.1.expected
130 @$(VM) -float 1 -float 0 $< > $@/output
131 @diff $@/output $@/1.0.expected
132 @$(VM) -float 0 -float 1 $< > $@/output
133 @diff $@/output $@/0.1.expected
135 $(eval $(call maketest,fields1,qcc))
137 @$(VM) -vector '150 2000 150' -vector '220 1300 -200' $< > $@/output
138 @diff $@/output $@/expected
140 invalid-types-ok: obj invalid-types/assign.qc invalid-types/op.qc invalid-types/call1.qc invalid-types/call2.qc invalid-types/call3.qc
141 @echo "Testing: invalid-types"
142 @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
143 @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
144 @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
145 @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
146 @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
147 @touch obj/invalid-types-ok
149 invalid-types: invalid-types-ok
151 $(eval $(call maketest,ngraphs,qcc))
153 @$(VM) $< > $@/output
154 @diff $@/output $@/expected
156 invalid-assign-ok: obj invalid-assign/main.qc
157 @echo "Testing: invalid-assign"
158 @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
160 invalid-assign: invalid-assign-ok
162 $(eval $(call maketest,field-parameters,qcc))
164 @$(VM) $< > $@/output
165 @diff $@/output $@/expected
167 $(eval $(call maketest,functions-as-parameters,qcc))
168 functions-as-parameters:
169 @$(VM) $< > $@/output
170 @diff $@/output $@/expected
172 $(eval $(call maketest,shadow-qcc,qcc))
174 @$(VM) -vector '33 44 55' $< > $@/output
175 @diff $@/output $@/expected
177 $(eval $(call maketest,shadow-gmqcc,gm))
179 @$(VM) -vector '33 44 55' $< > $@/output
180 @diff $@/output $@/expected
182 #######################################################################