diff options
Diffstat (limited to 'tests/features/test_smart_derive.zc')
| -rw-r--r-- | tests/features/test_smart_derive.zc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/features/test_smart_derive.zc b/tests/features/test_smart_derive.zc new file mode 100644 index 0000000..705a12f --- /dev/null +++ b/tests/features/test_smart_derive.zc @@ -0,0 +1,26 @@ + +@derive(Eq) +struct Container { + val: int; +} + +// Ensure derived eq uses pointers by trying to use 'c2' after comparison +test "eq_moves" { + var c1 = Container { val: 10 }; + var c2 = Container { val: 10 }; + + // This should call Container__eq(&c1, &c2) + // If it passed by value, c2 would be moved here + if c1 == c2 { + // c2 must still be valid + assert(c2.val == 10, "c2 moved during equality check!"); + } else { + assert(false, "c1 != c2"); + } + + // Explicitly verify c2 is still valid + c2.val = 20; + assert(c2.val == 20, "c2 invalid"); + + println "Smart Derive Eq Works!"; +} |
