Skip to content

Commit

Permalink
Rearrange and re-fudge Bag symmetric difference.
Browse files Browse the repository at this point in the history
Coming up with a definition of Bag symmetric difference changes the answers we
are looking for. In addition I've moved the corresponding tests from set.t to
bag.t, and fudged them because Rakudo cannot handle them properly yet.  (ab5tract++ and I are working on making them work.)
  • Loading branch information
colomon committed Sep 28, 2014
1 parent 292aaeb commit c8a5e7f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
17 changes: 16 additions & 1 deletion S03-operators/bag.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 109;
plan 117;

sub showkv($x) {
$x.keys.sort.map({ $^k ~ ':' ~ $x{$k} }).join(' ')
Expand Down Expand Up @@ -58,6 +58,21 @@ isa_ok ($s (&) $kb), Bag, "... and it's actually a Bag";
is showkv($kb (&) <glad green blood>), "blood:1", "BagHash intersection with array of strings works (texas)";
isa_ok ($kb (&) <glad green blood>), Bag, "... and it's actually a Bag";

# symmetric difference

#?rakudo 8 todo 'Rakudo is getting this wrong at the moment, fix coming soon'
is showkv($s (^) $b), showkv($s (|) $b), "Bag symmetric difference with Set is correct";
isa_ok ($s (^) $b), Bag, "... and it's actually a Bag";
is showkv($b (^) $s), showkv($s (|) $b), "Set symmetric difference with Bag is correct";
isa_ok ($b (^) $s), Bag, "... and it's actually a Bag";

#?niecza todo "Test is wrong, implementation is wrong"
is showkv($s (^) $kb), showkv(($s (|) $kb) (-) ($s (&) $kb)), "BagHash subtracted from Set is correct";
isa_ok ($s (^) $kb), Bag, "... and it's actually a Bag";
#?niecza todo "Test is wrong, implementation is wrong"
is showkv($kb (^) $s), showkv(($s (|) $kb) (-) ($s (&) $kb)), "Set subtracted from BagHash is correct";
isa_ok ($kb (^) $s), Bag, "... and it's actually a Bag";

# Bag multiplication

is showkv($s $s), "blood:1 love:1", "Bag multiplication with itself yields self squared";
Expand Down
16 changes: 2 additions & 14 deletions S03-operators/set.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 296;
plan 288;

sub showset($s) { $s.keys.sort.join(' ') }
sub showkv($x) { $x.keys.sort.map({ $^k ~ ':' ~ $x{$k} }).join(' ') }
Expand Down Expand Up @@ -126,19 +126,7 @@ isa_ok ($s (^) $ks), Set, "... and it's actually a Set";
is showset($ks (^) $s), showset(set <is isn't your day>), "Set symmetric difference with SetHash is correct";
isa_ok ($ks (^) $s), Set, "... and it's actually a Set";

is showset($s (^) $b), showset($s (|) $b), "Bag symmetric difference with Set is correct";
isa_ok ($s (^) $b), Set, "... and it's actually a Set";
is showset($b (^) $s), showset($s (|) $b), "Set symmetric difference with Bag is correct";
isa_ok ($b (^) $s), Set, "... and it's actually a Set";

#?niecza todo "Test is wrong, implementation is wrong"
#?rakudo todo 'huh?'
is showset($s (^) $kb), showset(($s (|) $kb) (-) set <your>), "BagHash subtracted from Set is correct";
isa_ok ($s (^) $kb), Set, "... and it's actually a Set";
#?niecza todo "Test is wrong, implementation is wrong"
#?rakudo todo 'huh?'
is showset($kb (^) $s), showset(($s (|) $kb) (-) set <your>), "Set subtracted from BagHash is correct";
isa_ok ($kb (^) $s), Set, "... and it's actually a Set";
# symmetric difference with Bag moved to bag.t

# is subset of

Expand Down

0 comments on commit c8a5e7f

Please sign in to comment.