diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2018-10-07 20:02:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-07 20:02:03 +0300 |
commit | 85efd363cbcbf3ac5d917a14fe1fccc857c1e859 (patch) | |
tree | f151c2b73bca3e8497c7cd9a3ee8333a14f2fa4f /test cases | |
parent | 091e079354fe6322823048c9debd1a13bdc7e37f (diff) | |
parent | b6fc063b13ff53c6c36abeb592983f50da995e3b (diff) | |
download | meson-85efd363cbcbf3ac5d917a14fe1fccc857c1e859.zip meson-85efd363cbcbf3ac5d917a14fe1fccc857c1e859.tar.gz meson-85efd363cbcbf3ac5d917a14fe1fccc857c1e859.tar.bz2 |
Merge pull request #3900 from xclaesse/in-operator
Interpreter: Add "in", "not in", "break", and "continue" operators
Diffstat (limited to 'test cases')
-rw-r--r-- | test cases/common/17 comparison/meson.build | 15 | ||||
-rw-r--r-- | test cases/common/64 foreach/meson.build | 13 |
2 files changed, 28 insertions, 0 deletions
diff --git a/test cases/common/17 comparison/meson.build b/test cases/common/17 comparison/meson.build index fb641ed..bba0168 100644 --- a/test cases/common/17 comparison/meson.build +++ b/test cases/common/17 comparison/meson.build @@ -137,3 +137,18 @@ assert(2 != 'st', 'not equal') assert(not ([] == 'st'), 'not equal') assert(not ([] == 1), 'not equal') assert(not (2 == 'st'), 'not equal') + +# "in" and "not in" operators + +assert(1 in [1, 2], '''1 should be in [1, 2]''') +assert(3 not in [1, 2], '''3 shouldn't be in [1, 2]''') +assert(not (3 in [1, 2]), '''3 shouldn't be in [1, 2]''') + +assert('b' in ['a', 'b'], ''''b' should be in ['a', 'b']''') +assert('c' not in ['a', 'b'], ''''c' shouldn't be in ['a', 'b']''') + +assert(exe1 in [exe1, exe2], ''''exe1 should be in [exe1, exe2]''') +assert(exe3 not in [exe1, exe2], ''''exe3 shouldn't be in [exe1, exe2]''') + +assert('a' in {'a': 'b'}, '''1 should be in {'a': 'b'}''') +assert('b' not in {'a': 'b'}, '''1 should be in {'a': 'b'}''') diff --git a/test cases/common/64 foreach/meson.build b/test cases/common/64 foreach/meson.build index e633de8..7084e80 100644 --- a/test cases/common/64 foreach/meson.build +++ b/test cases/common/64 foreach/meson.build @@ -18,3 +18,16 @@ foreach i : tests # we definitely don't want that. tests = ['test4', 'prog4', 'prog4.c'] endforeach + +items = ['a', 'continue', 'b', 'break', 'c'] +result = [] +foreach i : items + if i == 'continue' + continue + elif i == 'break' + break + endif + result += i +endforeach + +assert(result == ['a', 'b'], 'Continue or break in foreach failed') |