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

array: test assignment operators

This commit is contained in:
Alexey 2020-04-14 21:32:06 +03:00 committed by GitHub
parent 86402204a7
commit 91de4e1ece
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,6 +21,26 @@ fn test_pointer() {
assert *d_arr[1][0] == 1
}
fn test_assign() {
arr := [2, 4, 8, 16, 32, 64, 128]
arr[0] = 2
arr[1] &= 255
arr[2] |= 255
arr[3] <<= 4
arr[4] >>= 4
arr[5] %= 5
arr[6] ^= 3
assert arr[0] == 2
assert arr[1] == 4 & 255
assert arr[2] == 8 | 255
assert arr[3] == 16 << 4
assert arr[4] == 32 >> 4
assert arr[5] == 64 % 5
assert arr[6] == 128 ^ 3
}
fn test_ints() {
mut a := [1, 5, 2, 3]
assert a.len == 4