summaryrefslogtreecommitdiffstats
path: root/test cases/common/15 if
diff options
context:
space:
mode:
Diffstat (limited to 'test cases/common/15 if')
-rw-r--r--test cases/common/15 if/meson.build72
-rw-r--r--test cases/common/15 if/prog.c1
2 files changed, 73 insertions, 0 deletions
diff --git a/test cases/common/15 if/meson.build b/test cases/common/15 if/meson.build
new file mode 100644
index 0000000..f8d8295
--- /dev/null
+++ b/test cases/common/15 if/meson.build
@@ -0,0 +1,72 @@
+project('if test', 'c')
+
+var1 = true
+set_variable('var2', false)
+
+if var1
+ exe = executable('prog', 'prog.c')
+endif
+
+if var2
+ exe = executable('breakbreakbreak', 'crashing.c')
+endif
+
+test('iftest', exe)
+
+if not is_variable('var1')
+ error('Is_variable fail.')
+endif
+
+if is_variable('nonexisting')
+ error('Is_variable fail 2.')
+endif
+
+if not get_variable('var1', false)
+ error('Get_variable fail.')
+endif
+
+if get_variable('nonexisting', false)
+ error('Get_variable fail.')
+endif
+
+
+# Now test elseif
+
+t = true
+f = false
+
+if true
+ message('Ok.')
+elif true
+ error('Error')
+else
+ error('Error')
+endif
+
+if f
+ error('Error.')
+elif t
+ message('Ok')
+else
+ error('Error')
+endif
+
+if f
+ error('Error.')
+elif false
+ error('Error')
+else
+ message('Ok')
+endif
+
+# Test plain else
+
+var = false
+
+if var
+ exe = executable('break', 'break.c')
+else
+ exe = executable('eprog', 'prog.c')
+endif
+
+test('elsetest', exe)
diff --git a/test cases/common/15 if/prog.c b/test cases/common/15 if/prog.c
new file mode 100644
index 0000000..78f2de1
--- /dev/null
+++ b/test cases/common/15 if/prog.c
@@ -0,0 +1 @@
+int main(void) { return 0; }