From 3c1e4f24910fb2d57d0f1139d496579a2d54d052 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 9 Jan 2026 01:43:09 +0900 Subject: feat: implement # operator (stringification) --- tests/macro_operators.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/macro_operators.sh') diff --git a/tests/macro_operators.sh b/tests/macro_operators.sh index e456d4f..a6d0445 100644 --- a/tests/macro_operators.sh +++ b/tests/macro_operators.sh @@ -87,3 +87,23 @@ int main() { printf("%d\n", F(123)); } EOF + +test_exit_code 0 <<'EOF' +#include + +int strcmp(const char*, const char*); + +#define FOO 42 + +#define TO_STRING(x) TO_STRING_HELPER(x) +#define TO_STRING_HELPER(x) #x +#define BAR TO_STRING(FOO) + +#define TO_STRING2(x) #x +#define BAZ TO_STRING2(FOO) + +int main() { + ASSERT_EQ(0, strcmp("42", BAR)); + ASSERT_EQ(0, strcmp("FOO", BAZ)); +} +EOF -- cgit v1.2.3-70-g09d2