summaryrefslogtreecommitdiff
path: root/tests/memory/test_drop.zc
diff options
context:
space:
mode:
authorSAJJA EASWAR <eshwarsajja20@gmail.com>2026-01-25 22:59:36 +0530
committerSAJJA EASWAR <eshwarsajja20@gmail.com>2026-01-25 22:59:36 +0530
commitebc8b94baa6bc694cb4829e2eb2934a1f17fa6a1 (patch)
tree71b952ad455bf17d5bdea01472f0e2297f25eabe /tests/memory/test_drop.zc
parent863118c95caac0d69a35f6ae4d2e83844734a8a1 (diff)
parent489336b2101bf16edeec7bfc4379408eb19b936e (diff)
Merge branch 'main' into pr-109
Diffstat (limited to 'tests/memory/test_drop.zc')
-rw-r--r--tests/memory/test_drop.zc26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/memory/test_drop.zc b/tests/memory/test_drop.zc
new file mode 100644
index 0000000..6b1ccdf
--- /dev/null
+++ b/tests/memory/test_drop.zc
@@ -0,0 +1,26 @@
+import "../../std/mem.zc"
+
+let DROP_CALLED = 0;
+
+struct MyResource {
+ id: int;
+}
+
+impl Drop for MyResource {
+ fn drop(self) {
+ println "Dropping MyResource {self.id}";
+ DROP_CALLED = 1;
+ }
+}
+
+test "drop_trait" {
+ {
+ let res = MyResource { id: 1 };
+ // Scope ends here, drop should be called
+ }
+
+ if (DROP_CALLED != 1) {
+ println "Error: Drop was not called!";
+ exit(1);
+ }
+}