diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-08-31 18:19:43 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-08-31 18:43:05 +0900 |
| commit | c78ad80457ac1497c314a8dbd30c65590d00f1e2 (patch) | |
| tree | 82da68f62a9ec5145e9b4cd5ef6bedcf88dffc0e /tests | |
| parent | 4ab3700128f0a628b2a8f86e1dfde30ca7891f9d (diff) | |
| download | ducc-c78ad80457ac1497c314a8dbd30c65590d00f1e2.tar.gz ducc-c78ad80457ac1497c314a8dbd30c65590d00f1e2.tar.zst ducc-c78ad80457ac1497c314a8dbd30c65590d00f1e2.zip | |
feat: support multiple tokens in macro arguments
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/112.sh | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/112.sh b/tests/112.sh new file mode 100644 index 0000000..c56e0d6 --- /dev/null +++ b/tests/112.sh @@ -0,0 +1,35 @@ +cat <<'EOF' > expected +42 +100 200 +300 +0 +1 2 3 +15 +42 +123 +879 +EOF + +test_diff <<'EOF' +int printf(); + +#define ADD(a, b) ((a) + (b)) +#define PRINT_TWO(x, y) printf("%d %d\n", x, y) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define NESTED(x) (x) +#define CONCAT3(a, b, c) a ## b ## c + +int main() { + printf("%d\n", ADD(40, 2)); + PRINT_TWO(100, 200); + printf("%d\n", MAX(100 + 200, 250)); + printf("%d\n"); + NESTED((printf("1 "), printf("2 "), printf("3\n"), 0)); + + int x = 5, y = 10; + printf("%d\n", ADD(x + 2, y - 2)); + printf("%d\n", ADD(MAX(10, 20), MAX(15 + 5, 22))); + printf("%d\n", ADD( 100 , 23 )); + printf("%d\n", ADD(NESTED((100 + 200)), MAX((123 + 456), (111 + 222)))); +} +EOF |
