Debian Codegraph @

test cases/common/56 array methods/meson.build

raw
1 project('array methods', meson_version : '>= 1.9')
2
3 empty = []
4 one = ['abc']
5 two = ['def', 'ghi']
6 combined = [empty, one, two]
7
8 file_list = files('a.txt', 'b.txt')
9 file_a = files('a.txt')
10 file_c = files('c.txt')
11
12 if file_a[0] != file_list[0]
13 error('Files are not equal')
14 endif
15
16 if not file_list.contains(file_a[0])
17 error('Contains with ObjectHolder lists does not work')
18 endif
19
20 if file_list.contains(file_c[0])
21 error('Contains with ObjectHolder lists found nonexistent object')
22 endif
23
24 if empty.contains('abc')
25 error('Empty is not empty.')
26 endif
27
28 if one.contains('a')
29 error('One claims to contain a')
30 endif
31
32 if not one.contains('abc')
33 error('One claims to not contain abc.')
34 endif
35
36 if one.contains('abcd')
37 error('One claims to contain abcd.')
38 endif
39
40 if two.contains('abc')
41 error('Two claims to contain abc.')
42 endif
43
44 if not two.contains('def')
45 error('Two claims not to contain def.')
46 endif
47
48 if not two.contains('ghi')
49 error('Two claims not to contain ghi.')
50 endif
51
52 if two.contains('defg')
53 error('Two claims to contain defg.')
54 endif
55
56 if not combined.contains('abc')
57 error('Combined claims not to contain abc.')
58 endif
59
60 if not combined.contains(one)
61 error('Combined claims not to contain [abc].')
62 endif
63
64 if not combined.contains(two)
65 error('Combined claims not to contain [def, ghi].')
66 endif
67
68 if not combined.contains('ghi')
69 error('Combined claims not to contain ghi.')
70 endif
71
72 # test array slicing
73 assert(['a', 'b', 'c'].slice() == ['a', 'b', 'c'])
74 assert(['a', 'b', 'c'].slice(step : 2) == ['a', 'c'])
75 assert(['a', 'b', 'c'].slice(step : -1) == ['c', 'b', 'a'])
76 assert(['a', 'b', 'c'].slice(step : -2) == ['c', 'a'])
77 assert(['a', 'b', 'c'].slice(1, 2) == ['b'])
78 assert(['a', 'b', 'c'].slice(2, -2) == [])
79 assert(['a', 'b', 'c'].slice(-9876543, 2) == ['a', 'b'])
80 assert(['a', 'b', 'c', 'd', 'e'].slice(1, 12, step : 2) == ['b', 'd'])
81
82 # test array flattening
83 x = ['a', ['b'], [[[[[[['c'], 'd']]], 'e']]]]
84 assert(x.length() == 3)
85 assert(x.flatten().length() == 5)
86 assert(x.flatten() == ['a', 'b', 'c', 'd', 'e'])
87 assert(['a', ['b', 'c']].flatten() == ['a', 'b', 'c'])