Merge pull request #6011 from xclaesse/not-disabler

Fix `if not disabler()` case
pull/6018/head
Jussi Pakkanen 5 years ago committed by GitHub
commit 34ea71239d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      mesonbuild/interpreterbase.py
  2. 44
      test cases/common/163 disabler/meson.build

@ -500,6 +500,8 @@ class InterpreterBase:
def evaluate_notstatement(self, cur):
v = self.evaluate_statement(cur.value)
if is_disabler(v):
return v
if not isinstance(v, bool):
raise InterpreterException('Argument to "not" is not a boolean.')
return not v
@ -680,8 +682,6 @@ The result of this is undefined and will become a hard error in a future Meson r
if len(node.varnames) != 1:
raise InvalidArguments('Foreach on array does not unpack')
varname = node.varnames[0].value
if is_disabler(items):
return items
for item in items:
self.set_variable(varname, item)
try:
@ -693,8 +693,6 @@ The result of this is undefined and will become a hard error in a future Meson r
elif isinstance(items, dict):
if len(node.varnames) != 2:
raise InvalidArguments('Foreach on dict unpacks key and value')
if is_disabler(items):
return items
for key, value in items.items():
self.set_variable(node.varnames[0].value, key)
self.set_variable(node.varnames[1].value, value)

@ -76,3 +76,47 @@ else
has_not_changed = true
endif
assert(has_not_changed, 'App has changed.')
if_is_disabled = true
if disabler()
if_is_disabled = false
else
if_is_disabled = false
endif
assert(if_is_disabled, 'Disabler in "if condition" must skip both blocks')
if not disabler()
if_is_disabled = false
else
if_is_disabled = false
endif
assert(if_is_disabled, 'Disabler in "if not condition" must skip both blocks')
if disabler() == 1
if_is_disabled = false
else
if_is_disabled = false
endif
assert(if_is_disabled, 'Disabler in "if a==b" must skip both blocks')
loops = 0
disablers = 0
foreach i : [true, disabler(), true]
loops += 1
if is_disabler(i)
disablers += 1
endif
endforeach
assert(loops == 3, 'Disabler in foreach array')
assert(disablers == 1, 'Disabler in foreach array')
loops = 0
disablers = 0
foreach k, i : {'a': true, 'b': disabler(), 'c': true}
loops += 1
if is_disabler(i)
disablers += 1
endif
endforeach
assert(loops == 3, 'Disabler in foreach dict')
assert(disablers == 1, 'Disabler in foreach dict')

Loading…
Cancel
Save