1 /** 2 C tests that must run 3 */ 4 module it.c.run.c; 5 6 import it; 7 8 @Tags("run") 9 @("function named debug") 10 @safe unittest { 11 shouldCompileAndRun( 12 C( 13 q{ 14 void debug(const char* msg); 15 } 16 ), 17 C( 18 ` 19 #include <stdio.h> 20 void debug(const char* msg) { printf("%s\n", msg); } 21 ` 22 ), 23 D( 24 q{ 25 debug_("Hello world!\n"); 26 } 27 ), 28 ); 29 } 30 31 32 @Tags("run") 33 @("struct var collision") 34 @safe unittest { 35 shouldCompileAndRun( 36 C( 37 q{ 38 struct foo { int dummy; }; 39 extern int foo; 40 } 41 ), 42 C( 43 q{ 44 int foo; 45 } 46 ), 47 D( 48 q{ 49 auto s = foo(33); 50 foo_ = 42; 51 } 52 ), 53 ); 54 } 55 56 @Tags("run") 57 @("struct function collision") 58 @safe unittest { 59 shouldCompileAndRun( 60 C( 61 q{ 62 struct foo { int dummy; }; 63 void foo(void); 64 } 65 ), 66 C( 67 q{ 68 void foo(void) {} 69 } 70 ), 71 D( 72 q{ 73 auto s = foo(33); 74 foo_(); 75 } 76 ), 77 ); 78 } 79 80 @Tags("run") 81 @("static.inline") 82 @safe unittest { 83 shouldCompileAndRun( 84 C( 85 ` 86 static inline int _add(int i, int j) { 87 return i + j; 88 } 89 #define add(i, j) _add(i, j) 90 ` 91 ), 92 C( 93 q{ 94 } 95 ), 96 D( 97 q{ 98 // this is a workaround for not translating the static inline function 99 int _add(int i, int j) { return i + j + 1; } 100 assert(add(2, 3) == 6); 101 } 102 ), 103 ); 104 }