Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
More "is element of" tests, first union tests.
- Loading branch information
Showing
1 changed file
with
31 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,46 @@ | ||
| use v6; | ||
| use Test; | ||
|
|
||
| plan 4; | ||
| plan 23; | ||
|
|
||
| sub showset($s) { $s.keys.sort.join(' ') } | ||
|
|
||
| my $s = set <I'm afraid it isn't your day>; | ||
| 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(<None of us have all the heaven we want>); # Donald McCaig | ||
| my $kb = KeyBag.new(<Come, take your bread with joy, and your wine with a glad heart>); # Ecclesiastes 9:7 | ||
|
|
||
| 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"; | ||
| ok "heaven" β $kb, "heaven is an element of KeyBag"; | ||
| ok "your" β $kb, "heaven is an element of KeyBag"; | ||
| ok "d" β <a b c d e>, "d is an element of a b c d e"; | ||
|
|
||
| ok "afraid" (elem) $s, "afraid is an element of Set (texas)"; | ||
| ok "afraid" (elem) $ks, "afraid is an element of KeySet (texas)"; | ||
| 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)"; | ||
|
|
||
| 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)"; | ||
|
|
||
| is showset($s βͺ $s), showset($s), "Set union with itself yields self"; | ||
| isa_ok ($s βͺ $s), Set, "... and it's actually a Set"; | ||
| is showset($ks βͺ $ks), showset($ks), "KeySet union with itself yields self (as Set)"; | ||
| isa_ok ($ks βͺ $ks), Set, "... and it's actually a Set"; | ||
| is showset($b βͺ $b), showset($b), "Bag union with itself yields self (as Set)"; | ||
| 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"; | ||
|
|
||
| # vim: ft=perl6 |