aboutsummaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorMarc Herbert <marc.herbert@gmail.com>2019-12-03 16:45:28 -0800
committerXavier Claessens <xclaesse@gmail.com>2019-12-03 22:10:07 -0500
commit80bfe593fccfaca880f38754fbf115ca0d591e44 (patch)
tree251aa34af3ad415e029b5fbfcd4207af2911c40a /test cases
parent11639dd922aadb82545e2bce4edc558467a1fa21 (diff)
downloadmeson-80bfe593fccfaca880f38754fbf115ca0d591e44.zip
meson-80bfe593fccfaca880f38754fbf115ca0d591e44.tar.gz
meson-80bfe593fccfaca880f38754fbf115ca0d591e44.tar.bz2
mparser.py: actually check the type of key variable, not its value
Fixes PR #6166 and more specifically commit 4e460f04f3b2 that tried to make sure the type of a key variable is a string but checked the type of the value instead. Extends test common/228's limited coverage, its only test case had (surprise) a string value. Also avoid reserved python keyword 'dict' and potentially confusing string 'key'. Implements #5231 for real.
Diffstat (limited to 'test cases')
-rw-r--r--test cases/common/228 add dict variable key/meson.build19
1 files changed, 14 insertions, 5 deletions
diff --git a/test cases/common/228 add dict variable key/meson.build b/test cases/common/228 add dict variable key/meson.build
index b39c17e..faa6854 100644
--- a/test cases/common/228 add dict variable key/meson.build
+++ b/test cases/common/228 add dict variable key/meson.build
@@ -1,12 +1,21 @@
project('add dictionary entry using string variable as key', meson_version: '>=0.52')
-dict = {}
+dict1 = {}
# A variable to be used as a key
-key = 'myKey'
+testkey1 = 'myKey1'
+testkey2 = 'myKey2'
# Add new entry using the variable
-dict += {key : 'myValue'}
+dict1 += {testkey1 : 'myValue'}
+dict1 += {testkey2 : 42}
-# Test that the stored value is correct
-assert(dict[key] == 'myValue', 'Incorrect value retrieved from dictionary')
+# Test that the stored values are correct
+assert(dict1[testkey1] == 'myValue',
+ 'Incorrect string value retrieved from dictionary - variable key')
+assert(dict1['myKey1'] == 'myValue',
+ 'Incorrect string value retrieved from dictionary - literal key')
+assert(dict1[testkey2] == 42,
+ 'Incorrect int value retrieved from dictionary - variable key')
+assert(dict1['myKey2'] == 42,
+ 'Incorrect int value retrieved from dictionary - literal key')