Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add the "contains" tests, plus turn on the negated texas tests.
  • Loading branch information
colomon committed Feb 12, 2012
1 parent ec4e4e0 commit 874369d
Showing 1 changed file with 44 additions and 6 deletions.
50 changes: 44 additions & 6 deletions S03-operators/set.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 23;
plan 50;

sub showset($s) { $s.keys.sort.join(' ') }

Expand All @@ -10,6 +10,8 @@ my $ks = KeySet.new(<I'm afraid it is>); # Tom Stoppard
my $b = bag <Whoever remains for long here in this earthly life will enjoy and endure more than enough>; # Seamus Heaney
my $kb = KeyBag.new(<Come, take your bread with joy, and your wine with a glad heart>); # Ecclesiastes 9:7

# Is an element of

ok "afraid" ∈ $s, "afraid is an element of Set";
ok "afraid" ∈ $ks, "afraid is an element of KeySet";
ok "earthly" ∈ $b, "earthly is an element of Bag";
Expand All @@ -22,17 +24,49 @@ ok "earthly" (elem) $b, "earthly is an element of Bag (texas)";
ok "your" (elem) $kb, "heaven is an element of KeyBag (texas)";
ok "d" (elem) <a b c d e>, "d is an element of a b c d e (texas)";

# Is not an element of

ok "marmoset" βˆ‰ $s, "marmoset is not an element of Set";
ok "marmoset" βˆ‰ $ks, "marmoset is not an element of KeySet";
ok "marmoset" βˆ‰ $b, "marmoset is not an element of Bag";
ok "marmoset" βˆ‰ $kb, "marmoset is not an element of KeyBag";
ok "marmoset" βˆ‰ <a b c d e>, "marmoset is not an element of a b c d e";

# ok "hogwash" !(elem) $s, "hogwash is not an element of Set (texas)";
# ok "hogwash" !(elem) $ks, "hogwash is not an element of KeySet (texas)";
# ok "hogwash" !(elem) $b, "hogwash is not an element of Bag (texas)";
# ok "hogwash" !(elem) $kb, "hogwash is not an element of KeyBag (texas)";
# ok "hogwash" !(elem) <a b c d e>, "hogwash is not an element of a b c d e (texas)";
ok "hogwash" !(elem) $s, "hogwash is not an element of Set (texas)";
ok "hogwash" !(elem) $ks, "hogwash is not an element of KeySet (texas)";
ok "hogwash" !(elem) $b, "hogwash is not an element of Bag (texas)";
ok "hogwash" !(elem) $kb, "hogwash is not an element of KeyBag (texas)";
ok "hogwash" !(elem) <a b c d e>, "hogwash is not an element of a b c d e (texas)";

# Contains

ok $s βˆ‹ "afraid", "afraid is contained by Set";
ok $ks βˆ‹ "afraid", "afraid is contained by KeySet";
ok $b βˆ‹ "earthly", "earthly is contained by Bag";
ok $kb βˆ‹ "your", "heaven is contained by KeyBag";
ok <a b c d e> βˆ‹ "d", "d is contained by a b c d e";

ok $s (cont) "afraid", "afraid is contained by Set";
ok $ks (cont) "afraid", "afraid is contained by KeySet";
ok $b (cont) "earthly", "earthly is contained by Bag";
ok $kb (cont) "your", "heaven is contained by KeyBag";
ok <a b c d e> (cont) "d", "d is contained by a b c d e";

# Does not contain

ok $s ∌ "marmoset", "marmoset is not contained by Set";
ok $ks ∌ "marmoset", "marmoset is not contained by KeySet";
ok $b ∌ "marmoset", "marmoset is not contained by Bag";
ok $kb ∌ "marmoset", "marmoset is not contained by KeyBag";
ok <a b c d e> ∌ "marmoset", "marmoset is not contained by a b c d e";

ok $s !(cont) "marmoset", "marmoset is not contained by Set";
ok $ks !(cont) "marmoset", "marmoset is not contained by KeySet";
ok $b !(cont) "marmoset", "marmoset is not contained by Bag";
ok $kb !(cont) "marmoset", "marmoset is not contained by KeyBag";
ok <a b c d e> !(cont) "marmoset", "marmoset is not contained by a b c d e";

# Union

is showset($s βˆͺ $s), showset($s), "Set union with itself yields self";
isa_ok ($s βˆͺ $s), Set, "... and it's actually a Set";
Expand All @@ -43,4 +77,8 @@ isa_ok ($b βˆͺ $b), Set, "... and it's actually a Set";
is showset($kb βˆͺ $kb), showset($kb), "KeyBag union with itself yields (as Set)";
isa_ok ($kb βˆͺ $kb), Set, "... and it's actually a Set";

is showset($s βˆͺ $ks), showset(set <I'm afraid it is isn't your day>), "Set union with KeySet works";
isa_ok ($s βˆͺ $ks), Set, "... and it's actually a Set";


# vim: ft=perl6

0 comments on commit 874369d

Please sign in to comment.