• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1group if "If Statements"
2
3	case single_statement
4		values
5		{
6			input float in0 = [ 0.0 | 1.0 | 2.0 ];
7			output float out0 = [ 0.0 | 1.0 | 1.0 ];
8		}
9
10		both ""
11			precision mediump float;
12			${DECLARATIONS}
13			void main()
14			{
15				out0 = 0.0;
16				if (in0 >= 1.0)
17					out0 = 1.0;
18				${OUTPUT}
19			}
20		""
21	end
22
23	case compound_statement
24		values
25		{
26			input float in0 = [ 0.0 | 1.0 | 2.0 ];
27			output float out0 = [ 0.0 | 1.0 | 1.0 ];
28			output float out1 = [ 1.0 | 0.0 | 0.0 ];
29		}
30
31		both ""
32			precision mediump float;
33			${DECLARATIONS}
34			void main()
35			{
36				out0 = 0.0;
37				out1 = 1.0;
38				if (in0 >= 1.0)
39				{
40					out0 = 1.0;
41					out1 = 0.0;
42				}
43				${OUTPUT}
44			}
45		""
46	end
47
48	case sequence_statements
49		values
50		{
51			input float in0 = [ 0.0 | 1.0 | 2.0 ];
52			output float out0 = [ 0.0 | 1.0 | 1.0 ];
53			output float out1 = [ 1.0 | 0.0 | 0.0 ];
54		}
55
56		both ""
57			precision mediump float;
58			${DECLARATIONS}
59			void main()
60			{
61				out0 = 0.0;
62				out1 = 1.0;
63				if (in0 >= 1.0)
64					out0 = 1.0, out1 = 0.0;
65				${OUTPUT}
66			}
67		""
68	end
69
70	case sequence_condition
71		values
72		{
73			input float in0 = [ 0.0 | 1.0 | 2.0 ];
74			output float out0 = [ 0.0 | 1.0 | 1.0 ];
75			output float out1 = [ 1.0 | 0.0 | 0.0 ];
76		}
77
78		both ""
79			precision mediump float;
80			${DECLARATIONS}
81			void main()
82			{
83				out0 = 0.0;
84				out1 = 1.0;
85				if (false, in0 >= 1.0)
86					out0 = 1.0, out1 = 0.0;
87				${OUTPUT}
88			}
89		""
90	end
91
92	case complex_condition
93		values
94		{
95			input float in0 = [ 0.0 | 1.0 | 2.0 ];
96			output float out0 = [ 0.0 | 1.0 | 1.0 ];
97			output float out1 = [ 1.0 | 0.0 | 0.0 ];
98		}
99
100		both ""
101			precision mediump float;
102			${DECLARATIONS}
103			void main()
104			{
105				out0 = 0.0;
106				out1 = 1.0;
107				if (false || (in0 >= 1.0) && (in0 - 2.0*in0 < 0.0))
108					out0 = 1.0, out1 = 0.0;
109				${OUTPUT}
110			}
111		""
112	end
113
114	case if_else
115		values
116		{
117			input float in0 = [ 0.0 | 1.0 | 2.0 ];
118			output float out0 = [ 0.0 | 1.0 | 1.0 ];
119		}
120
121		both ""
122			precision mediump float;
123			${DECLARATIONS}
124			void main()
125			{
126				if (in0 >= 1.0)
127					out0 = 1.0;
128				else
129					out0 = 0.0;
130				${OUTPUT}
131			}
132		""
133	end
134
135	case if_elseif
136		values
137		{
138			input float in0 = [ 0.0 | 1.0 | 2.0 ];
139			output float out0 = [ 0.0 | 1.0 | 2.0 ];
140		}
141
142		both ""
143			precision mediump float;
144			${DECLARATIONS}
145			void main()
146			{
147				out0 = 0.0;
148				if (in0 >= 2.0)
149					out0 = 2.0;
150				else if (in0 >= 1.0)
151					out0 = 1.0;
152				${OUTPUT}
153			}
154		""
155	end
156
157	case if_elseif_else
158		values
159		{
160			input float in0 = [ 0.0 | 1.0 | 2.0 ];
161			output float out0 = [ 0.0 | 1.0 | 2.0 ];
162		}
163
164		both ""
165			precision mediump float;
166			${DECLARATIONS}
167			void main()
168			{
169				if (in0 >= 2.0)
170					out0 = 2.0;
171				else if (in0 >= 1.0)
172					out0 = 1.0;
173				else
174					out0 = 0.0;
175				${OUTPUT}
176			}
177		""
178	end
179
180	case mixed_if_elseif_else
181		values
182		{
183			input float in0 = [ 0.0 | 1.0 | 2.0 ];
184			output float out0 = [ 0.0 | 1.0 | 2.0 ];
185		}
186
187		both ""
188			precision mediump float;
189			${DECLARATIONS}
190			void main()
191			{
192				if (in0 >= 2.0)
193				{
194					out0 = 2.0;
195				}
196				else if (in0 >= 1.0)
197					out0 = 2.0, out0 = 1.0;
198				else
199					out0 = 0.0;
200				${OUTPUT}
201			}
202		""
203	end
204
205end # if
206
207group invalid_if "Invalid If Conditionals"
208
209	case missing_parenthesis
210		expect compile_fail
211		both ""
212			precision mediump float;
213			void main()
214			{
215				if true
216					${POSITION_FRAG_COLOR} = vec4(1.0);
217			}
218		""
219	end
220
221	case unclosed_parenthesis
222		expect compile_fail
223		both ""
224			precision mediump float;
225			void main()
226			{
227				if (true
228					${POSITION_FRAG_COLOR} = vec4(1.0);
229			}
230		""
231	end
232
233	case int_condition
234		expect compile_fail
235		both ""
236			precision mediump float;
237			void main()
238			{
239				if (5)
240					${POSITION_FRAG_COLOR} = vec4(1.0);
241			}
242		""
243	end
244
245	case int_zero_condition
246		expect compile_fail
247		both ""
248			precision mediump float;
249			void main()
250			{
251				if (0)
252					${POSITION_FRAG_COLOR} = vec4(1.0);
253			}
254		""
255	end
256
257	case int_one_condition
258		expect compile_fail
259		both ""
260			precision mediump float;
261			void main()
262			{
263				if (1)
264					${POSITION_FRAG_COLOR} = vec4(1.0);
265			}
266		""
267	end
268
269	case int_uniform_condition
270		expect compile_fail
271
272		both ""
273			precision mediump float;
274			precision mediump int;
275			uniform int u0;
276			void main()
277			{
278				if (u0)
279					${POSITION_FRAG_COLOR} = vec4(1.0);
280			}
281		""
282	end
283
284	case float_condition
285		expect compile_fail
286		both ""
287			precision mediump float;
288			void main()
289			{
290				if (5.0)
291					${POSITION_FRAG_COLOR} = vec4(1.0);
292			}
293		""
294	end
295
296	case float_zero_condition
297		expect compile_fail
298		both ""
299			precision mediump float;
300			void main()
301			{
302				if (0.0)
303					${POSITION_FRAG_COLOR} = vec4(1.0);
304			}
305		""
306	end
307
308	case float_one_condition
309		expect compile_fail
310		both ""
311			precision mediump float;
312			void main()
313			{
314				if (1.0)
315					${POSITION_FRAG_COLOR} = vec4(1.0);
316			}
317		""
318	end
319
320	case sampler_condition
321		expect compile_fail
322		both ""
323			precision mediump float;
324			uniform sampler2D s0;
325			void main()
326			{
327				if (s0)
328					${POSITION_FRAG_COLOR} = vec4(1.0);
329			}
330		""
331	end
332
333end # invalid_if
334