From a44f1aaf7b2bae1e98a2ded761ab535c941061bf Mon Sep 17 00:00:00 2001
From: Martin Stjernholm <mast@lysator.liu.se>
Date: Fri, 15 Sep 2000 02:31:43 +0200
Subject: [PATCH] Some more gc checks. Test that copy_value copies the weak
 flags too.

Rev: src/testsuite.in:1.329
---
 src/testsuite.in | 49 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 48 insertions(+), 1 deletion(-)

diff --git a/src/testsuite.in b/src/testsuite.in
index b356388a5f..227b89e8b1 100644
--- a/src/testsuite.in
+++ b/src/testsuite.in
@@ -1,4 +1,4 @@
-test_true([["$Id: testsuite.in,v 1.328 2000/09/10 09:17:05 mirar Exp $"]]);
+test_true([["$Id: testsuite.in,v 1.329 2000/09/15 00:31:43 mast Exp $"]]);
 
 cond([[all_constants()->_verify_internals]],
 [[
@@ -2003,6 +2003,46 @@ ifefun(gc,
     gc(); return a;
   }]], ({4711, 0x54325827a124*0x12348795482485425}))
 
+  test_any_equal([[{
+    object o = class Live {
+      object o;
+      array a = ({17});
+      void create() {o = this_object();}
+      void destroy() {all_constants()->kablutt = a;}
+    }();
+    o = 0;
+    gc();
+    return all_constants()->kablutt;
+  }]], ({17}));
+  test_any([[{
+    object o = class Live {
+      object o;
+      array a = set_weak_flag (({({17})}), 1);
+      void create() {o = this_object();}
+      void destroy() {
+	if (!equal (a, ({({17})})))
+	  error ("Contents in weak array zapped: %O.\n", a);
+      }
+    }();
+    o = 0;
+    return gc() >= 3;
+  }]], 1);
+  test_any_equal([[{
+    object o = class Live {
+      object o;
+      array a = set_weak_flag (({({17})}), 1);
+      void create() {o = this_object();}
+      void destroy() {all_constants()->blatinka = a;}
+    }();
+    o = 0;
+    gc();
+    if (!equal (all_constants()->blatinka, ({({17})})))
+      error ("Contents in saved weak array zapped: %O.\n",
+	     all_constants()->blatinka);
+    gc();
+    return all_constants()->blatinka;
+  }]], ({0}));
+
   test_any([[{
     class Dead {object o;};
     object o = Dead(); o->o = Dead();
@@ -2169,6 +2209,10 @@ ifefun(gc,
     gc();
     return sizeof (a) == 1 && sizeof (b) == 1;
   }]], 1);
+  test_any([[{
+    mapping a = set_weak_flag (([17: set_weak_flag (({({17})}), 1)]), 1);
+    return gc() >= 2 && !sizeof (a);
+  }]], 1);
 
   test_do([[{
     int got_error = 0;
@@ -4672,6 +4716,9 @@ do_test_copy_value( ({1}) )
 do_test_copy_value( ([]) )
 do_test_copy_value( (<>) )
 do_test_copy_value( (< ([]), ({1}) ,"" , 1.0 >) )
+test_true(get_weak_flag(copy_value(set_weak_flag(({17}), 1))))
+test_true(get_weak_flag(copy_value(set_weak_flag(([17:17]), 1))))
+test_true(get_weak_flag(copy_value(set_weak_flag((<17>), 1))))
 
 // - crypt
 test_true(stringp(crypt("hej")))
-- 
GitLab