| ... | @@ -2808,4 +2808,43 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2808,4 +2808,43 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2808 | \\ return if (x > y) x else y; | 2808 | \\ return if (x > y) x else y; |
| 2809 | \\} | 2809 | \\} |
| 2810 | }); | 2810 | }); |
| | 2811 | |
| | 2812 | cases.add("string concatenation in macros", |
| | 2813 | \\#define FOO "hello" |
| | 2814 | \\#define BAR FOO " world" |
| | 2815 | \\#define BAZ "oh, " FOO |
| | 2816 | , &[_][]const u8{ |
| | 2817 | \\pub const FOO = "hello"; |
| | 2818 | , |
| | 2819 | \\pub const BAR = FOO ++ " world"; |
| | 2820 | , |
| | 2821 | \\pub const BAZ = "oh, " ++ FOO; |
| | 2822 | }); |
| | 2823 | |
| | 2824 | cases.add("string concatenation in macros: two defines", |
| | 2825 | \\#define FOO "hello" |
| | 2826 | \\#define BAZ " world" |
| | 2827 | \\#define BAR FOO BAZ |
| | 2828 | , &[_][]const u8{ |
| | 2829 | \\pub const FOO = "hello"; |
| | 2830 | , |
| | 2831 | \\pub const BAZ = " world"; |
| | 2832 | , |
| | 2833 | \\pub const BAR = FOO ++ BAZ; |
| | 2834 | }); |
| | 2835 | |
| | 2836 | cases.add("string concatenation in macros: two strings", |
| | 2837 | \\#define FOO "a" "b" |
| | 2838 | \\#define BAR FOO "c" |
| | 2839 | , &[_][]const u8{ |
| | 2840 | \\pub const FOO = "a" ++ "b"; |
| | 2841 | , |
| | 2842 | \\pub const BAR = FOO ++ "c"; |
| | 2843 | }); |
| | 2844 | |
| | 2845 | cases.add("string concatenation in macros: three strings", |
| | 2846 | \\#define FOO "a" "b" "c" |
| | 2847 | , &[_][]const u8{ |
| | 2848 | \\pub const FOO = "a" ++ ("b" ++ "c"); |
| | 2849 | }); |
| 2811 | } | 2850 | } |