From dfb18322317b9721d93e422a10b0e0d80a047e08 Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Wed, 10 Feb 2016 18:45:00 -0500 Subject: [PATCH] TEST: More thorough testing of boolean binops. --- tests/pipeline/test_numerical_expression.py | 24 +++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/pipeline/test_numerical_expression.py b/tests/pipeline/test_numerical_expression.py index a49c166a..1026a762 100644 --- a/tests/pipeline/test_numerical_expression.py +++ b/tests/pipeline/test_numerical_expression.py @@ -1,3 +1,4 @@ +from itertools import permutations from operator import ( add, ge, @@ -498,15 +499,20 @@ class NumericalExpressionTestCase(TestCase): self.check_output(eye_filter, eye_mask) self.check_output(first_row_filter, first_row_mask) - def gen_boolops(a, b, c): - yield (a & b) & c - yield (a & b) | c - yield (a | b) & c - yield (a | b) | c - yield a & (b & c) - yield a & (b | c) - yield a | (b & c) - yield a | (b | c) + def gen_boolops(x, y, z): + """ + Generate all possible interleavings of & and | between all possible + orderings of x, y, and z. + """ + for a, b, c in permutations([x, y, z]): + yield (a & b) & c + yield (a & b) | c + yield (a | b) & c + yield (a | b) | c + yield a & (b & c) + yield a & (b | c) + yield a | (b & c) + yield a | (b | c) exprs = gen_boolops(eye_filter, custom_filter, first_row_filter) arrays = gen_boolops(eye_mask, custom_filter_mask, first_row_mask)