-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move all (<+) and (>+) tests into a separate file
Tests are copied verbatim as there will be no further development of the (<+) and (>+) operators.
- Loading branch information
Showing
1 changed file
with
78 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
use v6; | ||
use Test; | ||
|
||
# This test file tests the following set operators: | ||
# (<+) precedes (Texas) | ||
# ≼ precedes | ||
# (>+) succeeds (Texas) | ||
# ≽ succeeds | ||
|
||
plan 32; | ||
|
||
# "We're more of the love, blood, and rhetoric school. Well, we can do you blood | ||
# and love without the rhetoric, and we can do you blood and rhetoric without | ||
# the love, and we can do you all three concurrent or consecutive. But we can't | ||
# give you love and rhetoric without the blood. Blood is compulsory. They're all | ||
# blood, you see." -- Tom Stoppard | ||
|
||
my $b = bag <blood blood rhetoric love love>; | ||
my $kb = BagHash.new(<blood love love>); | ||
|
||
# msubset | ||
{ | ||
ok $kb ≼ $b, "Our keybag is a msubset of our bag"; | ||
nok $b ≼ $kb, "Our bag is not a msubset of our keybag"; | ||
ok $b ≼ $b, "Our bag is a msubset of itself"; | ||
ok $kb ≼ $kb, "Our keybag is a msubset of itself"; | ||
ok $kb (<+) $b, "Our keybag is a msubset of our bag (texas)"; | ||
nok $b (<+) $kb, "Our bag is not a msubset of our keybag (texas)"; | ||
ok $b (<+) $b, "Our bag is a msubset of itself (texas)"; | ||
ok $kb (<+) $kb, "Our keybag is a msubset of itself (texas)"; | ||
} | ||
|
||
# msuperset | ||
{ | ||
nok $kb ≽ $b, "Our keybag is not a msuperset of our bag"; | ||
ok $b ≽ $kb, "Our keybag is not a msuperset of our bag"; | ||
ok $b ≽ $b, "Our bag is a msuperset of itself"; | ||
ok $kb ≽ $kb, "Our keybag is a msuperset of itself"; | ||
nok $kb (>+) $b, "Our keybag is not a msuperset of our bag"; | ||
ok $b (>+) $kb, "Our bag is a msuperset of our keybag"; | ||
ok $b (>+) $b, "Our bag is a msuperset of itself"; | ||
ok $kb (>+) $kb, "Our keybag is a msuperset of itself"; | ||
} | ||
|
||
my $m = ("blood" => 1.1, "rhetoric" => 1, "love" => 1.2).Mix; | ||
my $mh = MixHash.new-from-pairs("blood" => 1.1, "love" => 1.3); | ||
|
||
# msubset | ||
{ | ||
# adding a local MixHash here to avoid redoing all of the multiplication/addition return values | ||
my $mh = MixHash.new-from-pairs("blood" => 1.1, "love" => 1.3, "rhetoric" => 2.2); | ||
|
||
nok $mh ≼ $m, "Our MixHash is not a msubset of our Mix"; | ||
ok $m ≼ $mh, "Our Mix is a msubset of our MixHash"; | ||
ok $m ≼ $m, "Our Mix is a msubset of itself"; | ||
ok $mh ≼ $mh, "Our MixHash is a msubset of itself"; | ||
nok $mh (<+) $m, "Our MixHash is not a msubset of our Mix (texas)"; | ||
ok $m (<+) $mh, "Our Mix is a msubset of our MixHash (texas)"; | ||
ok $m (<+) $m, "Our Mix is a msubset of itself (texas)"; | ||
ok $mh (<+) $mh, "Our MixHash is a msubset of itself (texas)"; | ||
} | ||
|
||
# msuperset | ||
{ | ||
# adding a local MixHash here to avoid redoing all of the multiplication/addition return values | ||
my $mh = MixHash.new-from-pairs("blood" => 1.1, "love" => 1.3, "rhetoric" => 2.2); | ||
|
||
ok $mh ≽ $m, "Our MixHash is a msuperset of our Mix"; | ||
nok $m ≽ $mh, "Our Mix is not a msuperset of our MixHash"; | ||
ok $m ≽ $m, "Our mix is a msuperset of itself"; | ||
ok $mh ≽ $mh, "Our keymix is a msuperset of itself"; | ||
ok $mh (>+) $m, "Our MixHash is a msuperset of our Mix (Texas)"; | ||
nok $m (>+) $mh, "Our Mix is not a msuperset of our MixHash (Texas)"; | ||
ok $m (>+) $m, "Our Mix is a msuperset of itself (Texas)"; | ||
ok $mh (>+) $mh, "Our MixHash is a msuperset of itself (Texas)"; | ||
} | ||
|
||
# vim: ft=perl6 |