diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-09-13 00:05:12 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-09-13 01:38:56 +0900 |
| commit | 8de7fa9da5fd8015f4fcc826b9270061b7b89478 (patch) | |
| tree | ec9c1e56f179be207c31a113a0a96210f7509431 /tests/test_preprocess_flag.sh | |
| parent | d41a97e957ef616d194f60b9b79820cd0162d920 (diff) | |
| download | ducc-8de7fa9da5fd8015f4fcc826b9270061b7b89478.tar.gz ducc-8de7fa9da5fd8015f4fcc826b9270061b7b89478.tar.zst ducc-8de7fa9da5fd8015f4fcc826b9270061b7b89478.zip | |
feat: implement -E flag (preprocess only)
Diffstat (limited to 'tests/test_preprocess_flag.sh')
| -rw-r--r-- | tests/test_preprocess_flag.sh | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/tests/test_preprocess_flag.sh b/tests/test_preprocess_flag.sh new file mode 100644 index 0000000..3b52bc0 --- /dev/null +++ b/tests/test_preprocess_flag.sh @@ -0,0 +1,122 @@ +cat <<'EOF' > expected + +int main () { + int x = 100; + int y = 0; + return 0; +} +EOF + +test_cpp <<'EOF' +#define MAX 100 +#define MIN 0 + +int main() { + int x = MAX; + int y = MIN; + return 0; +} +EOF + +cat <<'EOF' > expected + +int main () { + int sum = ( ( 10) + ( 20)); + int product = ( ( 3) * ( 4)); + return 0; +} +EOF + +test_cpp <<'EOF' +#define ADD(a, b) ((a) + (b)) +#define MUL(x, y) ((x) * (y)) + +int main() { + int sum = ADD(10, 20); + int product = MUL(3, 4); + return 0; +} +EOF + +cat <<'EOF' > expected +int main () { + return 42; +} +EOF + +test_cpp <<'EOF' +#define FOO 42 +int main() { + return FOO; +} +EOF + +cat <<'EOF' > expected +int foo () { return 1; } +EOF + +test_cpp <<'EOF' +#define X 1 +#ifdef X +int foo() { return 1; } +#else +int foo() { return 0; } +#endif +EOF + +cat <<'EOF' > expected + +int main () { + int x = 1 + 2 * 3; + return 0; +} +EOF + +test_cpp <<'EOF' +#define A 1 +#define B A + 2 +#define C B * 3 + +int main() { + int x = C; + return 0; +} +EOF + +cat <<'EOF' > expected + +int main () { + int x = ( 5 + 3); + int y = ( ( 5) + ( 3)); + return 0; +} +EOF + +test_cpp <<'EOF' +#define SIMPLE (5 + 3) +#define COMPLEX(a, b) ((a) + (b)) + +int main() { + int x = SIMPLE; + int y = COMPLEX(5, 3); + return 0; +} +EOF + +cat <<'EOF' > expected + +int main () { + int bar = 0; + bar ++; +} +EOF + +test_cpp <<'EOF' +#define A(a) a +#define B(b) b + +int main() { + A(int)B(bar) = 0; + bar++; +} +EOF |
