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:
parent
78f9f25a00
commit
74ba8f5cc9
@ -7,22 +7,32 @@ fn test_in_expression() {
|
|||||||
arr1 := [1, 2]
|
arr1 := [1, 2]
|
||||||
arr2 := [0, 2]
|
arr2 := [0, 2]
|
||||||
arr3 := [1, 0]
|
arr3 := [1, 0]
|
||||||
|
|
||||||
a = true && 2 in arr1
|
a = true && 2 in arr1
|
||||||
assert a == true
|
assert a == true
|
||||||
a = false && 2 in arr1
|
a = false && 2 in arr1
|
||||||
assert a == false
|
assert a == false
|
||||||
|
|
||||||
a = true && 0 in arr2
|
a = true && 0 in arr2
|
||||||
assert a == true
|
assert a == true
|
||||||
a = false && 0 in arr3
|
a = false && 0 in arr3
|
||||||
assert a == false
|
assert a == false
|
||||||
|
|
||||||
a = true && 0 in arr1
|
a = true && 0 in arr1
|
||||||
assert a == false
|
assert a == false
|
||||||
a = true && 3 in arr1
|
a = true && 3 in arr1
|
||||||
assert a == false
|
assert a == false
|
||||||
|
|
||||||
a = true && !(2 in arr2)
|
a = true && !(2 in arr2)
|
||||||
assert a == false
|
assert a == false
|
||||||
a = true && !(3 in arr2)
|
a = true && !(3 in arr2)
|
||||||
assert a == true
|
assert a == true
|
||||||
|
|
||||||
|
a = true && (2 !in arr2)
|
||||||
|
assert a == false
|
||||||
|
a = true && (3 !in arr2)
|
||||||
|
assert a == true
|
||||||
|
|
||||||
a = 1 in arr1 && true
|
a = 1 in arr1 && true
|
||||||
assert a == true
|
assert a == true
|
||||||
a = 1 in arr1 && false
|
a = 1 in arr1 && false
|
||||||
@ -66,10 +76,12 @@ fn test_in_expression_with_string() {
|
|||||||
arr1 := ['ab', 'bc']
|
arr1 := ['ab', 'bc']
|
||||||
arr2 := ['', 'bc']
|
arr2 := ['', 'bc']
|
||||||
arr3 := ['ab', '']
|
arr3 := ['ab', '']
|
||||||
|
|
||||||
a = true && 'bc' in arr1
|
a = true && 'bc' in arr1
|
||||||
assert a == true
|
assert a == true
|
||||||
a = false && 'bc' in arr1
|
a = false && 'bc' in arr1
|
||||||
assert a == false
|
assert a == false
|
||||||
|
|
||||||
a = true && '' in arr2
|
a = true && '' in arr2
|
||||||
assert a == true
|
assert a == true
|
||||||
a = false && '' in arr3
|
a = false && '' in arr3
|
||||||
@ -78,10 +90,17 @@ fn test_in_expression_with_string() {
|
|||||||
assert a == false
|
assert a == false
|
||||||
a = true && 'abc' in arr1
|
a = true && 'abc' in arr1
|
||||||
assert a == false
|
assert a == false
|
||||||
|
|
||||||
a = true && !('bc' in arr2)
|
a = true && !('bc' in arr2)
|
||||||
assert a == false
|
assert a == false
|
||||||
a = true && !('abc' in arr2)
|
a = true && !('abc' in arr2)
|
||||||
assert a == true
|
assert a == true
|
||||||
|
|
||||||
|
a = true && ('bc' !in arr2)
|
||||||
|
assert a == false
|
||||||
|
a = true && ('abc' !in arr2)
|
||||||
|
assert a == true
|
||||||
|
|
||||||
a = 'ab' in arr1 && true
|
a = 'ab' in arr1 && true
|
||||||
assert a == true
|
assert a == true
|
||||||
a = 'ab' in arr1 && false
|
a = 'ab' in arr1 && false
|
||||||
@ -94,18 +113,27 @@ fn test_optimized_in_expression() {
|
|||||||
assert a == true
|
assert a == true
|
||||||
a = false && 2 in [1, 2]
|
a = false && 2 in [1, 2]
|
||||||
assert a == false
|
assert a == false
|
||||||
|
|
||||||
a = true && 0 in [0, 2]
|
a = true && 0 in [0, 2]
|
||||||
assert a == true
|
assert a == true
|
||||||
a = false && 0 in [1, 0]
|
a = false && 0 in [1, 0]
|
||||||
assert a == false
|
assert a == false
|
||||||
|
|
||||||
a = true && 0 in [1, 2]
|
a = true && 0 in [1, 2]
|
||||||
assert a == false
|
assert a == false
|
||||||
a = true && 3 in [1, 2]
|
a = true && 3 in [1, 2]
|
||||||
assert a == false
|
assert a == false
|
||||||
|
|
||||||
a = true && !(2 in [0, 2])
|
a = true && !(2 in [0, 2])
|
||||||
assert a == false
|
assert a == false
|
||||||
a = true && !(3 in [0, 2])
|
a = true && !(3 in [0, 2])
|
||||||
assert a == true
|
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
|
a = 1 in [1, 2] && true
|
||||||
assert a == true
|
assert a == true
|
||||||
a = 1 in [1, 2] && false
|
a = 1 in [1, 2] && false
|
||||||
@ -118,18 +146,27 @@ fn test_optimized_in_expression_with_enum() {
|
|||||||
assert a == true
|
assert a == true
|
||||||
a = false && Colors.blue in [.green, .blue]
|
a = false && Colors.blue in [.green, .blue]
|
||||||
assert a == false
|
assert a == false
|
||||||
|
|
||||||
a = true && Colors.red in [.red, .blue]
|
a = true && Colors.red in [.red, .blue]
|
||||||
assert a == true
|
assert a == true
|
||||||
a = false && Colors.red in [.green, .red]
|
a = false && Colors.red in [.green, .red]
|
||||||
assert a == false
|
assert a == false
|
||||||
|
|
||||||
a = true && Colors.red in [.green, .blue]
|
a = true && Colors.red in [.green, .blue]
|
||||||
assert a == false
|
assert a == false
|
||||||
a = true && Colors.yellow in [.green, .blue]
|
a = true && Colors.yellow in [.green, .blue]
|
||||||
assert a == false
|
assert a == false
|
||||||
|
|
||||||
a = true && !(Colors.blue in [.red, .blue])
|
a = true && !(Colors.blue in [.red, .blue])
|
||||||
assert a == false
|
assert a == false
|
||||||
a = true && !(Colors.yellow in [.red, .blue])
|
a = true && !(Colors.yellow in [.red, .blue])
|
||||||
assert a == true
|
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
|
a = Colors.green in [.green, .blue] && true
|
||||||
assert a == true
|
assert a == true
|
||||||
a = Colors.green in [.green, .blue] && false
|
a = Colors.green in [.green, .blue] && false
|
||||||
@ -142,18 +179,27 @@ fn test_optimized_in_expression_with_string() {
|
|||||||
assert a == true
|
assert a == true
|
||||||
a = false && 'bc' in ['ab', 'bc']
|
a = false && 'bc' in ['ab', 'bc']
|
||||||
assert a == false
|
assert a == false
|
||||||
|
|
||||||
a = true && '' in ['', 'bc']
|
a = true && '' in ['', 'bc']
|
||||||
assert a == true
|
assert a == true
|
||||||
a = false && '' in ['ab', '']
|
a = false && '' in ['ab', '']
|
||||||
assert a == false
|
assert a == false
|
||||||
|
|
||||||
a = true && '' in ['ab', 'bc']
|
a = true && '' in ['ab', 'bc']
|
||||||
assert a == false
|
assert a == false
|
||||||
a = true && 'abc' in ['ab', 'bc']
|
a = true && 'abc' in ['ab', 'bc']
|
||||||
assert a == false
|
assert a == false
|
||||||
|
|
||||||
a = true && !('bc' in ['', 'bc'])
|
a = true && !('bc' in ['', 'bc'])
|
||||||
assert a == false
|
assert a == false
|
||||||
a = true && !('abc' in ['', 'bc'])
|
a = true && !('abc' in ['', 'bc'])
|
||||||
assert a == true
|
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
|
a = 'ab' in ['ab', 'bc'] && true
|
||||||
assert a == true
|
assert a == true
|
||||||
a = 'ab' in ['ab', 'bc'] && false
|
a = 'ab' in ['ab', 'bc'] && false
|
||||||
|
Loading…
Reference in New Issue
Block a user