1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tests: add testing for !in

This commit is contained in:
krischerven 2020-04-12 20:29:07 -04:00 committed by GitHub
parent 78f9f25a00
commit 74ba8f5cc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,22 +7,32 @@ fn test_in_expression() {
arr1 := [1, 2]
arr2 := [0, 2]
arr3 := [1, 0]
a = true && 2 in arr1
assert a == true
a = false && 2 in arr1
assert a == false
a = true && 0 in arr2
assert a == true
a = false && 0 in arr3
assert a == false
a = true && 0 in arr1
assert a == false
a = true && 3 in arr1
assert a == false
a = true && !(2 in arr2)
assert a == false
a = true && !(3 in arr2)
assert a == true
a = true && (2 !in arr2)
assert a == false
a = true && (3 !in arr2)
assert a == true
a = 1 in arr1 && true
assert a == true
a = 1 in arr1 && false
@ -66,10 +76,12 @@ fn test_in_expression_with_string() {
arr1 := ['ab', 'bc']
arr2 := ['', 'bc']
arr3 := ['ab', '']
a = true && 'bc' in arr1
assert a == true
a = false && 'bc' in arr1
assert a == false
a = true && '' in arr2
assert a == true
a = false && '' in arr3
@ -78,10 +90,17 @@ fn test_in_expression_with_string() {
assert a == false
a = true && 'abc' in arr1
assert a == false
a = true && !('bc' in arr2)
assert a == false
a = true && !('abc' in arr2)
assert a == true
a = true && ('bc' !in arr2)
assert a == false
a = true && ('abc' !in arr2)
assert a == true
a = 'ab' in arr1 && true
assert a == true
a = 'ab' in arr1 && false
@ -94,18 +113,27 @@ fn test_optimized_in_expression() {
assert a == true
a = false && 2 in [1, 2]
assert a == false
a = true && 0 in [0, 2]
assert a == true
a = false && 0 in [1, 0]
assert a == false
a = true && 0 in [1, 2]
assert a == false
a = true && 3 in [1, 2]
assert a == false
a = true && !(2 in [0, 2])
assert a == false
a = true && !(3 in [0, 2])
assert a == true
a = true && (2 !in [0, 2])
assert a == false
a = true && (3 !in [0, 2])
assert a == true
a = 1 in [1, 2] && true
assert a == true
a = 1 in [1, 2] && false
@ -118,18 +146,27 @@ fn test_optimized_in_expression_with_enum() {
assert a == true
a = false && Colors.blue in [.green, .blue]
assert a == false
a = true && Colors.red in [.red, .blue]
assert a == true
a = false && Colors.red in [.green, .red]
assert a == false
a = true && Colors.red in [.green, .blue]
assert a == false
a = true && Colors.yellow in [.green, .blue]
assert a == false
a = true && !(Colors.blue in [.red, .blue])
assert a == false
a = true && !(Colors.yellow in [.red, .blue])
assert a == true
a = true && (Colors.blue !in [.red, .blue])
assert a == false
a = true && (Colors.yellow !in [.red, .blue])
assert a == true
a = Colors.green in [.green, .blue] && true
assert a == true
a = Colors.green in [.green, .blue] && false
@ -142,18 +179,27 @@ fn test_optimized_in_expression_with_string() {
assert a == true
a = false && 'bc' in ['ab', 'bc']
assert a == false
a = true && '' in ['', 'bc']
assert a == true
a = false && '' in ['ab', '']
assert a == false
a = true && '' in ['ab', 'bc']
assert a == false
a = true && 'abc' in ['ab', 'bc']
assert a == false
a = true && !('bc' in ['', 'bc'])
assert a == false
a = true && !('abc' in ['', 'bc'])
assert a == true
a = true && ('bc' !in ['', 'bc'])
assert a == false
a = true && ('abc' !in ['', 'bc'])
assert a == true
a = 'ab' in ['ab', 'bc'] && true
assert a == true
a = 'ab' in ['ab', 'bc'] && false