Branch: Tag:

2015-05-11

2015-05-11 15:27:43 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Multisets: Improved handling of unorderable values. Fixes [bug 7494 (#7494)].

It's not a good idea to pretend that values that don't have an order
relation do...

Fixes a bug that was introduced ~4 years ago.

5650:   ]], [[({4, 4, 5})]])      test_do(add_constant("cnt");) -  +    test_eq([[sizeof(mtest_m2)]],sizeof(mtest_i2)) -  +  + test_any([[ +  // Test subtraction of multisets of objects. +  class X(int a) +  { +  protected int `<(mixed o) { return objectp(o) && (a < o->a); } +  protected int `==(mixed o) { return objectp(o) && (a == o->a); } +  }; +  multiset m = (< @map(allocate(5), X) >); +  return sizeof(m - (<0>)); + ]], 5) +    test_any([[int e;multiset q=(<>),p=(<>); for(e=0;e<1000;e++) { p[reverse(e)]=1; q+=(<reverse(e)>); if(!equal(sort(indices(p)),sort(indices(q)))) return 0; } return 1;]],1)      test_equal(sort(indices(mtest_m|mtest_m2)),sort(mtest_i|mtest_i2))