From a301796186b592ad913c1452b84059d0d74e7b2a Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 20 Dec 2012 12:00:39 +0100 Subject: [PATCH] Added tests for 'noreturn' --- tests/noreturn.qc | 29 +++++++++++++++++++++++++++++ tests/noreturn1.tmpl | 4 ++++ tests/noreturn2.tmpl | 4 ++++ tests/noreturn3.tmpl | 4 ++++ tests/noreturn4.tmpl | 4 ++++ 5 files changed, 45 insertions(+) create mode 100644 tests/noreturn.qc create mode 100644 tests/noreturn1.tmpl create mode 100644 tests/noreturn2.tmpl create mode 100644 tests/noreturn3.tmpl create mode 100644 tests/noreturn4.tmpl diff --git a/tests/noreturn.qc b/tests/noreturn.qc new file mode 100644 index 0000000..1437b06 --- /dev/null +++ b/tests/noreturn.qc @@ -0,0 +1,29 @@ +#ifndef NORETURN +#define NORETURN noreturn +#endif + +void print(...) = #1; +string ftos(float) = #2; +NORETURN void error(...) = #6; + +#if TEST == 1 +void test1(float a) { + float x; + + if (a == 1) x = 1337; + else if (a == 2) x = 1338; + else + error("Error\n"); + print("Is this initialized: ", ftos(x), "\n"); +} + +#else + +float test2(float it) { + switch (it) { + case 1: return 0; + case 2: return 1; + default: error("End of non-void not reachable...\n"); + } +} +#endif diff --git a/tests/noreturn1.tmpl b/tests/noreturn1.tmpl new file mode 100644 index 0000000..db507dd --- /dev/null +++ b/tests/noreturn1.tmpl @@ -0,0 +1,4 @@ +I: noreturn.qc +D: noreturn keyword - should work +T: -compile +C: -std=fteqcc -Wall -Werror -DTEST=1 -DNORETURN=noreturn diff --git a/tests/noreturn2.tmpl b/tests/noreturn2.tmpl new file mode 100644 index 0000000..d5d73c2 --- /dev/null +++ b/tests/noreturn2.tmpl @@ -0,0 +1,4 @@ +I: noreturn.qc +D: noreturn keyword - should fail +T: -compile +C: -std=fteqcc -Wall -Werror -DTEST=2 -DNORETURN=noreturn diff --git a/tests/noreturn3.tmpl b/tests/noreturn3.tmpl new file mode 100644 index 0000000..56c28b5 --- /dev/null +++ b/tests/noreturn3.tmpl @@ -0,0 +1,4 @@ +I: noreturn.qc +D: noreturn keyword - should work +T: -fail +C: -std=fteqcc -Wall -Werror -DTEST=1 -DNORETURN diff --git a/tests/noreturn4.tmpl b/tests/noreturn4.tmpl new file mode 100644 index 0000000..18dc275 --- /dev/null +++ b/tests/noreturn4.tmpl @@ -0,0 +1,4 @@ +I: noreturn.qc +D: noreturn keyword - should fail +T: -fail +C: -std=fteqcc -Wall -Werror -DTEST=2 -DNORETURN -- 2.39.2