]> git.ozlabs.org Git - ccan/blobdiff - ccan/cppmagic/test/run.c
cppmagic: Allow multiple and deferred evaluation
[ccan] / ccan / cppmagic / test / run.c
index 0f8917d6a4afa5d8e620504a197fd7ae14cec7b8..2aa95303ed52d21a14f3a536cc580e7d7050bf07 100644 (file)
@@ -15,9 +15,12 @@ static inline void check1(const char *orig, const char *expand,
 #define CHECK1(orig, match) \
        check1(#orig, CPPMAGIC_STRINGIFY(orig), match)
 
+#define TESTRECURSE()  R CPPMAGIC_DEFER1(_TESTRECURSE)()()
+#define _TESTRECURSE() TESTRECURSE
+
 int main(void)
 {
-       plan_tests(24);
+       plan_tests(27);
 
        CHECK1(CPPMAGIC_NOTHING(), "");
        CHECK1(CPPMAGIC_GLUE2(a, b), "ab");
@@ -51,6 +54,10 @@ int main(void)
        CHECK1(CPPMAGIC_IFELSE(1)(abc)(def), "abc");
        CHECK1(CPPMAGIC_IFELSE(not zero)(abc)(def), "abc");
 
+       CHECK1(TESTRECURSE(), "R R _TESTRECURSE ()()");
+       CHECK1(CPPMAGIC_EVAL1(TESTRECURSE()), "R R R _TESTRECURSE ()()");
+       CHECK1(CPPMAGIC_EVAL2(TESTRECURSE()), "R R R R R _TESTRECURSE ()()");
+
        /* This exits depending on whether all tests passed */
        return exit_status();
 }