diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-20 12:51:23 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-20 12:51:23 +0000 |
| commit | b106fe19b55e9fe3348b3a5c9992c21dac27b02c (patch) | |
| tree | 32663c9a791b7f45ce9bc61c5a87351d5dc2c782 /tests | |
| parent | e5d8c4219cfe5629a3ce4dbff01406a1817a788f (diff) | |
Working a bit on the LSP + fixed some bugs
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/features/test_match_ref.zc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/features/test_match_ref.zc b/tests/features/test_match_ref.zc index 9734ffe..4e04b89 100644 --- a/tests/features/test_match_ref.zc +++ b/tests/features/test_match_ref.zc @@ -15,3 +15,28 @@ test "match_ref_int" { MyOption::None => assert(false, "fail") } } +// Mover struct to test move semantics vs ref +struct Mover { + val: int; +} + +test "match_ref_mover" { + var m = Mover { val: 100 }; + // MyOption<Mover> instantiation + var opt = MyOption<Mover>::Some(m); + + match opt { + MyOption::Some(ref x) => { + // x should be Mover* + assert(x.val == 100, "Mover ref access failed"); + x.val = 200; + }, + MyOption::None => assert(false, "Should be Some") + } + + // Check if modification persisted + match opt { + MyOption::Some(v) => assert(v.val == 200, "Mutation via ref failed"), + MyOption::None => {} + } +} |
