commit c2fa2f19835476f038f5167457932fd2a07ac18c parent 4e832881c7ca6b853d8f3a999bf712e8451f12c1 Author: Drew DeVault <sir@cmpwn.com> Date: Mon, 11 Jan 2021 11:46:15 -0500 Add assignment test for slices Diffstat:
M | tests/08-slices.ha | | | 26 | ++++++++++++++++++++++++++ |
1 file changed, 26 insertions(+), 0 deletions(-)
diff --git a/tests/08-slices.ha b/tests/08-slices.ha @@ -35,8 +35,34 @@ fn measurements() void = { assert(&x: uintptr: size % size(int) == 0z); }; +fn assignment() void = { + let source = [1, 2, 3]; + let x: []int = source; + x[0] = 4; + x[1] = 5; + x[2] = 6; + assert(x[0] == 4); + assert(x[1] == 5); + assert(x[2] == 6); + assert(source[0] == 4); + assert(source[1] == 5); + assert(source[2] == 6); + let y: []int = [4, 5, 6]; + x = y; + x[0] = 7; + x[1] = 8; + x[2] = 9; + assert(x[0] == 7); + assert(x[1] == 8); + assert(x[2] == 9); + assert(source[0] == 4); + assert(source[1] == 5); + assert(source[2] == 6); +}; + export fn main() void = { from_array(); storage(); measurements(); + assignment(); };