stack[level].extend(l[1])
elif len(l) == 1 and isinstance(l[0], list):
# l = [[...]]
- last = last_any_of_operator_level(level)
+ last = last_any_of_operator_level(level-1)
if last == -1:
if opconvert and isinstance(l[0], list) \
and l[0] and l[0][0] == '||':
else:
stack[level].extend(l[0])
else:
- stack[level].append(l[0])
+ if opconvert and l[0] and l[0][0] == "||":
+ stack[level].extend(l[0][1:])
+ else:
+ stack[level].append(l[0])
else:
stack[level].extend(l)
else:
stack[level].pop()
stack[level].extend(l)
else:
- if opconvert and starts_with_any_of_dep(level):
+ if opconvert and ends_in_any_of_dep(level):
#In opconvert mode, we have to move the operator from the level
#above into the current list.
stack[level].pop()
"A foo? ( || ( B || ( bar? ( || ( C D E ) ) !bar? ( F ) ) ) ) G",
uselist = ["foo", "bar"],
opconvert = True,
- expected_result = ['A', ['||', 'B', ['||', 'C', 'D', 'E']], 'G']),
+ expected_result = ['A', ['||', 'B', 'C', 'D', 'E'], 'G']),
UseReduceTestCase(
"A foo? ( || ( B || ( bar? ( || ( C D E ) ) !bar? ( F ) ) ) ) G",
uselist = ["foo", "bar"],
"|| ( ( A B ) foo? ( || ( C D ) ) )",
uselist = ["foo"],
opconvert = True,
- expected_result = [['||', ['A', 'B'], ['||', 'C', 'D']]]),
+ expected_result = [['||', ['A', 'B'], 'C', 'D']]),
UseReduceTestCase(
"|| ( ( A B ) foo? ( || ( C D ) ) )",
"|| ( ( A B ) || ( C D || ( E ( F G ) || ( H ) ) ) )",
expected_result = ['||', [['A', 'B'], 'C', 'D', 'E', ['F', 'G'], 'H']]),
+ UseReduceTestCase(
+ "|| ( ( A B ) || ( C D || ( E ( F G ) || ( H ) ) ) )",
+ opconvert = True,
+ expected_result = [['||', ['A', 'B'], 'C', 'D', 'E', ['F', 'G'], 'H']]),
+
UseReduceTestCase(
"|| ( foo? ( A B ) )",
uselist = ["foo"],
UseReduceTestCase(
"|| ( ( A B ) || ( foo? ( bar? ( ( C D || ( baz? ( E ) ( F G ) || ( H ) ) ) ) ) ) )",
uselist = ["foo", "bar", "baz"],
- expected_result = ['||', [['A', 'B'], 'C', 'D', '||', ['E', ['F', 'G'], 'H']]]),
+ expected_result = ['||', [['A', 'B'], ['C', 'D', '||', ['E', ['F', 'G'], 'H']]]]),
+
+ UseReduceTestCase(
+ "|| ( ( A B ) || ( foo? ( bar? ( ( C D || ( baz? ( E ) ( F G ) || ( H ) ) ) ) ) ) )",
+ uselist = ["foo", "bar", "baz"],
+ opconvert = True,
+ expected_result = [['||', ['A', 'B'], ['C', 'D', ['||', 'E', ['F', 'G'], 'H']]]]),
UseReduceTestCase(
"|| ( foo? ( A B ) )",