From 9cb33c9c795369266d5aa76e24b163268feb8af4 Mon Sep 17 00:00:00 2001 From: Thomas Nagy Date: Sat, 10 Mar 2012 11:14:16 +0100 Subject: [PATCH] testcase for Issue 1122 --- tests/preproc/wscript | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/preproc/wscript b/tests/preproc/wscript index 28e77a1c..fb7fe02c 100644 --- a/tests/preproc/wscript +++ b/tests/preproc/wscript @@ -134,6 +134,27 @@ def build(bld): add_defs(0, 0, 0, 'h.h') + defs = { + 'a' : 'a 0', + 'b' : 'b 1', + 'c' : 'c 1', + 'd' : 'd 0', + 'e' : 'a || b || c || d' + } + + def test(x, result): + toks = c_preproc.tokenize(x) + c_preproc.reduce_tokens(toks, defs, []) + (_, ret) = c_preproc.reduce_eval(toks) + if int(ret) == result: + color = "GREEN" + else: + color = "RED" + pprint(color, "%s\t\t%r" % (ret, toks)) + + test('a||b||c||d', 1) + test('a&&b&&c&&d', 0) + test('e', 1) return test("1?1,(0?5:9):3,4", 0) # <- invalid expression