20 functions-as-parameters
26 rm -f */deflist */*.gm.dat */*.qcc.dat */output
31 obj/%.gm.dat: %/main.qc obj
32 @echo "Testing:" $(subst obj/,,$(subst .gm.dat,,$@))
33 @$(QCC) -std=gmqcc -o $@ $< > $@.out 2> $@.err
35 obj/%.qcc.dat: %/main.qc obj
36 @echo "Testing:" $(subst obj/,,$(subst .qcc.dat,,$@))
37 @$(QCC) -std=qcc -o $@ $< > $@.out 2> $@.err
39 #######################################################################
41 # Macro which causes something to be compiled either with -std=qcc or without...
42 # this may at some point be extended to also store information about the progs.dat
43 # somewhere but for now we only need to build the object.
45 $(eval $dat = obj/${1}.${2}.dat)
49 #######################################################################
51 globaldefs: obj/globaldefs.gm.dat
52 @$(VM) -printdefs $< > $@/deflist
53 @diff $@/deflist $@/deflist.expected
55 $(eval $(call maketest,fielddefs,gm))
57 @$(VM) -printfields $< > $@/deflist
58 @diff $@/deflist $@/deflist.expected
60 $(eval $(call maketest,builtins,qcc))
62 @$(VM) -string "Hello 1" $< > $@/output
63 @test "`wc -l $@/output | awk '{ print $$1 }'`" = "1"
64 @grep -qE '^Hello 1$$' $@/output
65 @$(VM) -string "A test message Yeah" $< > $@/output
66 @test "`wc -l $@/output | awk '{ print $$1 }'`" = "1"
67 @grep -qE '^A test message Yeah$$' $@/output
69 $(eval $(call maketest,variadic,qcc))
71 @$(VM) -string "Hello 1" $< > $@/output
72 @test "`wc -l $@/output | awk '{ print $$1 }'`" = "1"
73 @grep -qE '^Hello 1$$' $@/output
74 @$(VM) -string "A test message Yeah" $< > $@/output
75 @test "`wc -l $@/output | awk '{ print $$1 }'`" = "1"
76 @grep -qE '^A test message Yeah$$' $@/output
78 $(eval $(call maketest,calls,qcc))
80 @$(VM) -float 1 -float 100 -float 10000 $< > $@/output
81 @grep -qE '^70907$$' $@/output
82 @$(VM) -float 3 -float 201 -float 90127 $< > $@/output
83 @grep -qE '^632719$$' $@/output
85 $(eval $(call maketest,if1,qcc))
87 @$(VM) -float 1 -float 100 -float 10000 $< > $@/output
88 @grep -qE '^One$$' $@/output
89 @$(VM) -float 2 -float 100 -float 10000 $< > $@/output
90 @grep -qE '^Two$$' $@/output
91 @$(VM) -float 3 -float 100 -float 10000 $< > $@/output
92 @grep -qE '^Three$$' $@/output
93 @$(VM) -float 4 -float 100 -float 10000 $< > $@/output
94 @grep -qE '^Else$$' $@/output
96 $(eval $(call maketest,loops1,qcc))
98 @$(VM) -float 0 $< > $@/output
99 @diff $@/output $@/0.expected
100 @$(VM) -float 1 $< > $@/output
101 @diff $@/output $@/1.expected
102 @$(VM) -float 4 $< > $@/output
103 @diff $@/output $@/4.expected
104 @$(VM) -float 10 $< > $@/output
105 @diff $@/output $@/10.expected
107 $(eval $(call maketest,maths1,qcc))
109 @$(VM) -float 0 -float 3 $< > $@/output
110 @diff $@/output $@/0.3.expected
111 @$(VM) -float 3 -float 6 $< > $@/output
112 @diff $@/output $@/3.6.expected
113 @$(VM) -float 0 -float 0 $< > $@/output
114 @diff $@/output $@/0.0.expected
116 $(eval $(call maketest,maths2,qcc))
118 @$(VM) -vector '1 2 3' -vector '4 5 6' $< > $@/output
119 @grep -qE '^dot = 32$$' $@/output
120 @$(VM) -vector '-5 12 5.5' -vector '4 -5 1' $< > $@/output
121 @grep -qE '^dot = -74.5$$' $@/output
122 @$(VM) -vector '-5 12 5.5' -vector '0 0 0' $< > $@/output
123 @grep -qE '^dot = 0$$' $@/output
125 $(eval $(call maketest,equality,qcc))
127 @$(VM) -float 1 -float 1 $< > $@/output
128 @diff $@/output $@/1.1.expected
129 @$(VM) -float 1 -float 0 $< > $@/output
130 @diff $@/output $@/1.0.expected
131 @$(VM) -float 0 -float 1 $< > $@/output
132 @diff $@/output $@/0.1.expected
134 $(eval $(call maketest,fields1,qcc))
136 @$(VM) -vector '150 2000 150' -vector '220 1300 -200' $< > $@/output
137 @diff $@/output $@/expected
139 invalid-types-ok: obj invalid-types/assign.qc invalid-types/op.qc invalid-types/call1.qc invalid-types/call2.qc invalid-types/call3.qc
140 @echo "Testing: invalid-types"
141 @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
142 @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
143 @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
144 @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
145 @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
146 @touch obj/invalid-types-ok
148 invalid-types: invalid-types-ok
150 $(eval $(call maketest,ngraphs,qcc))
152 @$(VM) $< > $@/output
153 @diff $@/output $@/expected
155 invalid-assign-ok: obj invalid-assign/main.qc
156 @echo "Testing: invalid-assign"
157 @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
159 invalid-assign: invalid-assign-ok
161 $(eval $(call maketest,field-parameters,qcc))
163 @$(VM) $< > $@/output
164 @diff $@/output $@/expected
166 $(eval $(call maketest,functions-as-parameters,qcc))
167 functions-as-parameters:
168 @$(VM) $< > $@/output
169 @diff $@/output $@/expected
171 #######################################################################