diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2024-05-08 23:11:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-08 09:11:46 -0600 |
commit | e662043fd1c43e8447fb7c30e97823f7d0a46a83 (patch) | |
tree | b370dd0d0055d087762c8d5fa78a064d15509f86 /tests/stdlib | |
parent | 1ad4e80060f22275b2f443bd8630e2573619e487 (diff) | |
download | Nim-e662043fd1c43e8447fb7c30e97823f7d0a46a83.tar.gz |
rework `wasMoved`, `move` on the JS backend (#23577)
`reset`, `wasMoved` and `move` doesn't support primitive types, which generate `null` for these types. It is now produce `x = default(...)` in the backend. Ideally it should be done by ast2ir in the future
Diffstat (limited to 'tests/stdlib')
-rw-r--r-- | tests/stdlib/tsystem.nim | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/tests/stdlib/tsystem.nim b/tests/stdlib/tsystem.nim index c1cadb49d..21dbdb59d 100644 --- a/tests/stdlib/tsystem.nim +++ b/tests/stdlib/tsystem.nim @@ -83,24 +83,36 @@ block: X = object a: string b: set[char] + c: int + d: float + e: int64 - var y = X(b: {'a'}) - reset(y) - - doAssert y.b == {} + var x = X(b: {'a'}, e: 10) -block: - type - X = object - a: string - b: int + var y = move x - var y = X(b: 1314) + doAssert x.a == "" + doAssert x.b == {} + doAssert x.c == 0 + doAssert x.d == 0.0 + doAssert x.e == 0 reset(y) - doAssert y.b == 0 + doAssert y.a == "" + doAssert y.b == {} + doAssert y.c == 0 + doAssert y.d == 0.0 + doAssert y.e == 0 + +block: + var x = 2 + var y = move x + doAssert y == 2 + doAssert x == 0 + reset y + doAssert y == 0 block: type |