From f030b6c546cc163c4b90a97aa399ffb9c1f6eeae Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 27 Aug 2025 00:06:30 +0900 Subject: feat: implement #elif* directives --- tests/100.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ tests/101.sh | 22 ++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 tests/100.sh create mode 100644 tests/101.sh (limited to 'tests') diff --git a/tests/100.sh b/tests/100.sh new file mode 100644 index 0000000..9df8476 --- /dev/null +++ b/tests/100.sh @@ -0,0 +1,44 @@ +cat <<'EOF' > expected +1 +1 +2 +3 +EOF + +test_diff <<'EOF' +int printf(); + +int main() { +#if 1 + printf("1\n"); +#elif 1 + printf("2\n"); +#else + printf("3\n"); +#endif + +#if 1 + printf("1\n"); +#elif 0 + printf("2\n"); +#else + printf("3\n"); +#endif + +#if 0 + printf("1\n"); +#elif 1 + printf("2\n"); +#else + printf("3\n"); +#endif + +#if 0 + printf("1\n"); +#elif 0 + printf("2\n"); +#else + printf("3\n"); +#endif +} +EOF diff --git a/tests/101.sh b/tests/101.sh new file mode 100644 index 0000000..338b879 --- /dev/null +++ b/tests/101.sh @@ -0,0 +1,22 @@ +cat <<'EOF' > expected +main.c:2: expected '#endif', but got '' +EOF +test_compile_error <<'EOF' +#if 0 +EOF + +cat <<'EOF' > expected +main.c:3: expected '#endif', but got '' +EOF +test_compile_error <<'EOF' +#if 1 +#else +EOF + +cat <<'EOF' > expected +main.c:3: expected '#endif', but got '' +EOF +test_compile_error <<'EOF' +#if 1 +#elif 1 +EOF -- cgit v1.2.3-70-g09d2