aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/interpreterbase/interpreterbase.py4
-rw-r--r--test cases/common/56 array methods/a.txt0
-rw-r--r--test cases/common/56 array methods/b.txt0
-rw-r--r--test cases/common/56 array methods/c.txt0
-rw-r--r--test cases/common/56 array methods/meson.build24
5 files changed, 26 insertions, 2 deletions
diff --git a/mesonbuild/interpreterbase/interpreterbase.py b/mesonbuild/interpreterbase/interpreterbase.py
index b8a6d1a..115e24b 100644
--- a/mesonbuild/interpreterbase/interpreterbase.py
+++ b/mesonbuild/interpreterbase/interpreterbase.py
@@ -783,7 +783,7 @@ The result of this is undefined and will become a hard error in a future Meson r
posargs: T.List[TYPE_var],
kwargs: TYPE_kwargs) -> T.Union[TYPE_var, InterpreterObject]:
if method_name == 'contains':
- def check_contains(el: list) -> bool:
+ def check_contains(el: T.List[TYPE_var]) -> bool:
if len(posargs) != 1:
raise InterpreterException('Contains method takes exactly one argument.')
item = posargs[0]
@@ -795,7 +795,7 @@ The result of this is undefined and will become a hard error in a future Meson r
if element == item:
return True
return False
- return check_contains(obj)
+ return check_contains([_unholder(x) for x in obj])
elif method_name == 'length':
return len(obj)
elif method_name == 'get':
diff --git a/test cases/common/56 array methods/a.txt b/test cases/common/56 array methods/a.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test cases/common/56 array methods/a.txt
diff --git a/test cases/common/56 array methods/b.txt b/test cases/common/56 array methods/b.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test cases/common/56 array methods/b.txt
diff --git a/test cases/common/56 array methods/c.txt b/test cases/common/56 array methods/c.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test cases/common/56 array methods/c.txt
diff --git a/test cases/common/56 array methods/meson.build b/test cases/common/56 array methods/meson.build
index cdda41d..99855bc 100644
--- a/test cases/common/56 array methods/meson.build
+++ b/test cases/common/56 array methods/meson.build
@@ -5,6 +5,22 @@ one = ['abc']
two = ['def', 'ghi']
combined = [empty, one, two]
+file_list = files('a.txt', 'b.txt')
+file_a = files('a.txt')
+file_c = files('c.txt')
+
+if file_a[0] != file_list[0]
+ error('Files are not equal')
+endif
+
+if not file_list.contains(file_a[0])
+ error('Contains with ObjectHolder lists does not work')
+endif
+
+if file_list.contains(file_c[0])
+ error('Contains with ObjectHolder lists found non existant object')
+endif
+
if empty.contains('abc')
error('Empty is not empty.')
endif
@@ -41,6 +57,14 @@ if not combined.contains('abc')
error('Combined claims not to contain abc.')
endif
+if not combined.contains(one)
+ error('Combined claims not to contain [abc].')
+endif
+
+if not combined.contains(two)
+ error('Combined claims not to contain [def, ghi].')
+endif
+
if not combined.contains('ghi')
error('Combined claims not to contain ghi.')
endif