]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Checking in test for nested ternaries; this is more a test of the ast than the parser
authorWolfgang (Blub) Bumiller <blub@speed.at>
Mon, 26 Nov 2012 13:12:56 +0000 (14:12 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Mon, 26 Nov 2012 13:12:56 +0000 (14:12 +0100)
tests/ternary.qc [new file with mode: 0644]
tests/ternary.tmpl [new file with mode: 0644]

diff --git a/tests/ternary.qc b/tests/ternary.qc
new file mode 100644 (file)
index 0000000..0f9233a
--- /dev/null
@@ -0,0 +1,27 @@
+void     print(...)   = #1;
+string   ftos (float) = #2;
+
+void test(float cond, float v1, float v2, float a) {
+       print(ftos(cond ? v1 : v2), " ");
+       print( (cond ? v1 : v2) ? ( (a == 1) ? "a=1"
+                                 : (a == 2) ? "a=2"
+                                 : "a=other"
+                                 )
+                               : "not met",
+             "\n");
+}
+
+void main() {
+       test(0, -99, 1, 1);
+       test(0, -99, 1, 2);
+       test(0, -99, 1, 3);
+       test(0, -99, 0, 1);
+       test(0, -99, 0, 2);
+       test(0, -99, 0, 3);
+       test(1, 1, -99, 1);
+       test(1, 1, -99, 2);
+       test(1, 1, -99, 3);
+       test(1, 0, -99, 1);
+       test(1, 0, -99, 2);
+       test(1, 0, -99, 3);
+}
diff --git a/tests/ternary.tmpl b/tests/ternary.tmpl
new file mode 100644 (file)
index 0000000..ebc6a41
--- /dev/null
@@ -0,0 +1,16 @@
+I: ternary.qc
+D: nested ternary expressions
+T: -execute
+C: -std=fteqcc
+M: 1 a=1
+M: 1 a=2
+M: 1 a=other
+M: 0 not met
+M: 0 not met
+M: 0 not met
+M: 1 a=1
+M: 1 a=2
+M: 1 a=other
+M: 0 not met
+M: 0 not met
+M: 0 not met