Branch: Tag:

2000-09-03

2000-09-03 23:22:16 by Martin Stjernholm <mast@lysator.liu.se>

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

1: - 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:      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})]])
2093:    }]], 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;    add_constant ("destructing", lambda (string id) {destruct_order += ({id});});