diff options
Diffstat (limited to 'tests/js/tcopying.nim')
-rw-r--r-- | tests/js/tcopying.nim | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/js/tcopying.nim b/tests/js/tcopying.nim index 387df9cd3..c58a080e9 100644 --- a/tests/js/tcopying.nim +++ b/tests/js/tcopying.nim @@ -2,6 +2,10 @@ discard """ output: '''123 2 9 2 9 +1 124 +true false +100 300 100 +1 ''' """ @@ -35,3 +39,34 @@ block: obj.ary2[1] = 9 echo ary1[1], " ", obj.ary2[1] + +block: + type TestObj = object + x, y: int + + let obj = TestObj(x: 1, y: 2) + var s = @[obj] + s[0].x += 123 + echo obj.x, " ", s[0].x + +block: + var nums = {1, 2, 3, 4} + let obj = (n: nums) + nums.incl 5 + echo (5 in nums), " ", (5 in obj.n) + +block: + let tup1 = (a: 100) + var tup2 = (t: (t2: tup1)) + var tup3 = tup1 + tup2.t.t2.a = 300 + echo tup1.a, " ", tup2.t.t2.a, " ", tup3.a + +block: + proc foo(arr: array[2, int]) = + var s = @arr + s[0] = 500 + + var nums = [1, 2] + foo(nums) + echo nums[0] \ No newline at end of file |