|
| 1 | +extern int printf(const char *__restrict format, ...); |
| 2 | + |
| 3 | +typedef struct { |
| 4 | + _Bool a; |
| 5 | +} bool_test_args; |
| 6 | + |
| 7 | +nx_struct nx_header { |
| 8 | + nx_uint32_t src; |
| 9 | + nx_uint32_t dst; |
| 10 | +}; |
| 11 | + |
| 12 | +module TestP { |
| 13 | + uses interface BoolTest; |
| 14 | +} |
| 15 | +implementation { |
| 16 | + int main() @C() @spontaneous() { |
| 17 | +#define do_test(test_name, bool_expr) call BoolTest.test(#test_name, bool_expr) |
| 18 | + |
| 19 | + do_test(TrueConst, 1); |
| 20 | + do_test(TrueExpr, 1 == 1 && 0 < 1); |
| 21 | + do_test(TrueExprSC, 0 == 0 || 0 > 1); |
| 22 | + do_test(IntTrue, 1234); |
| 23 | + do_test(FloatTrue, 1.23); |
| 24 | + do_test(String, "string"); |
| 25 | + |
| 26 | + do_test(FalseConst, 0); |
| 27 | + do_test(FalseExpr, 0 == 1 || 0 > 1); |
| 28 | + do_test(FalseExprSC, 1 == 0 && 0 < 1); |
| 29 | + do_test(IntZero, 0); |
| 30 | + do_test(FloatZero, 0.0); |
| 31 | + do_test(NullVoid, (const void *)0); |
| 32 | + do_test(NullULL, (unsigned long long *)0); |
| 33 | + do_test(NullStruct, (const bool_test_args *const __restrict)0); |
| 34 | + do_test(NullFnP, (int (*)(char[], double))0); |
| 35 | + do_test(Network, (nx_uint32_t *)0); |
| 36 | + do_test(NetworkStruct, (nx_struct nx_header *)0); |
| 37 | +#undef do_test |
| 38 | + |
| 39 | + return 0; |
| 40 | + } |
| 41 | + |
| 42 | + event void BoolTest.testDone(const char *test_name, _Bool result, _Bool arg) { |
| 43 | + printf("%15s: %d -> %d\n", test_name, arg, result); |
| 44 | + } |
| 45 | +} |
0 commit comments