From 639e6e0bed4c92cd3f621753f1e15a11dbafcdfa Mon Sep 17 00:00:00 2001 From: Martin Stjernholm <mast@lysator.liu.se> Date: Mon, 4 Sep 2000 01:22:16 +0200 Subject: [PATCH] Added some test cases for equal on mappings with destructed indices and gc'ing of mappings with shared data blocks. Rev: src/testsuite.in:1.326 --- src/testsuite.in | 64 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/src/testsuite.in b/src/testsuite.in index b210639168..0329074ba2 100644 --- a/src/testsuite.in +++ b/src/testsuite.in @@ -1,4 +1,4 @@ -test_true([["$Id: testsuite.in,v 1.325 2000/09/01 20:19:35 hubbe Exp $"]]); +test_true([["$Id: testsuite.in,v 1.326 2000/09/03 23:22:16 mast Exp $"]]); cond([[all_constants()->_verify_internals]], [[ @@ -1815,6 +1815,20 @@ test_any([[mapping m=([1:2,3:2]); return search(m,2,search(m,2))!=-1;]],1) test_any([[mapping m=([]); for(int e=0;e<1000;e++) m[e&3]+=({e}); return sizeof(m)==4 && sizeof(m[0])==250;]],1) +// destructed indices +test_any([[{ + object o = class{}(); + mapping m = ([o: 1]); + destruct (o); + return equal (m, ([])) && equal (m, ([])); +}]], 1) +test_any([[{ + object o = class{}(); + mapping m = ([o: 1]), n = ([class{}(): 1]); + destruct (o); + return !equal (m, n) && !equal (m, n); +}]], 1) + // rows test_equal([[rows(({1,2,3,4,5,6,7,8,9}),({6,7,2}))]],[[({7,8,3})]]) test_equal([[rows(({1,2,3,4,5,6,7,8,9}),({0,4,1}))]],[[({1,5,2})]]) @@ -2092,6 +2106,54 @@ ifefun(gc, return gc() + gc() >= 3; }]], 1); + test_do([[{ + mapping a = ([1:({17}),2:3,4:5,6:7,8:9]), b = a + ([]); + set_weak_flag (b, 1); + gc(); + }]]); + test_do([[{ + mapping a = ([1:({17})]), b = a + ([]); + set_weak_flag (b, 1); + gc(); + }]]); + test_any([[{ + mapping a = ([17:({17})]); + for (int i = 0; i < 10; i++) a[class{}()] = i; + mapping b = a + ([]); + set_weak_flag (b, 1); + foreach (indices (a), mixed o) if (objectp (o)) destruct (o); + gc(); + return sizeof (a) == 1 && sizeof (b) == 1; + }]], 1); + test_any([[{ + mapping a = ([17:({17})]); + for (int i = 0; i < 10; i++) a[class{}()] = i; + mapping b = a + ([]); + set_weak_flag (a, 1); + foreach (indices (a), mixed o) if (objectp (o)) destruct (o); + gc(); + return sizeof (a) == 1 && sizeof (b) == 1; + }]], 1); + test_any([[{ + mapping a = ([17:({17})]); + for (int i = 0; i < 10; i++) a[class{}()] = i; + mapping b = a + ([]); + set_weak_flag (a, 1); + set_weak_flag (b, 1); + foreach (indices (a), mixed o) if (objectp (o)) destruct (o); + gc(); + return !sizeof (a) && !sizeof (b); + }]], 1); + test_any([[{ + mapping a = ([17:({17})]); + set_weak_flag (a, 1); + for (int i = 0; i < 10; i++) a[class{}()] = i; + mapping b = a + ([]); + foreach (indices (a), mixed o) if (objectp (o)) destruct (o); + gc(); + return sizeof (a) == 1 && sizeof (b) == 1; + }]], 1); + test_do([[{ int got_error = 0; array(string) destruct_order; -- GitLab