The Meson Build System
http://mesonbuild.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
872 B
36 lines
872 B
7 years ago
|
project('dict test', 'c')
|
||
|
|
||
|
dict = {'foo' : 'bar',
|
||
|
'baz' : 'foo',
|
||
|
'foo bar': 'baz'}
|
||
|
|
||
|
exe = executable('prog', sources : ['prog.c'])
|
||
|
|
||
7 years ago
|
i = 0
|
||
|
|
||
7 years ago
|
foreach key, value : dict
|
||
|
test('dict test @0@'.format(key), exe,
|
||
|
args : [dict[key], value])
|
||
7 years ago
|
i += 1
|
||
7 years ago
|
endforeach
|
||
7 years ago
|
|
||
7 years ago
|
assert(i == 3, 'There should be three elements in that dictionary')
|
||
|
|
||
7 years ago
|
empty_dict = {}
|
||
|
|
||
|
foreach key, value : empty_dict
|
||
|
assert(false, 'This dict should be empty')
|
||
|
endforeach
|
||
7 years ago
|
|
||
|
d1 = empty_dict + {'a' : 'b'}
|
||
|
assert(d1 == {'a' : 'b'}, 'dict addition is not working')
|
||
|
|
||
|
d2 = d1 + {'a' : 'b2', 'c' : 'd'}
|
||
|
assert(d2 == {'a' : 'b2', 'c' : 'd'}, 'dict addition is not working')
|
||
|
assert(d1 == {'a' : 'b'}, 'dict should be immutable')
|
||
|
|
||
|
d3 = d2
|
||
|
d3 += {'e' : 'f'}
|
||
|
assert(d3 == {'a' : 'b2', 'c' : 'd', 'e' : 'f'}, 'dict plusassign is not working')
|
||
|
assert(d2 == {'a' : 'b2', 'c' : 'd'}, 'dict should be immutable')
|