Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fudging for niecza / pugs for .total and .grab tests
  • Loading branch information
lizmat committed Oct 4, 2013
1 parent adcc1c7 commit 57a3771
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
12 changes: 12 additions & 0 deletions S02-types/bag.t
Expand Up @@ -42,6 +42,8 @@ sub showkv($x) {
is ~$b<a b>, "5 1", 'Multiple-element access';
is ~$b<a santa b easterbunny>, "5 0 1 0", 'Multiple-element access (with nonexistent elements)';

#?pugs skip '.total NYI'
#?niecza skip '.total NYI'
is $b.total, 8, '.total gives sum of values';
is +$b, 8, '+$bag gives sum of values';
}
Expand Down Expand Up @@ -256,6 +258,8 @@ sub showkv($x) {
is +@a, 100, '.roll(100) returns 100 items';
ok 2 < @a.grep(* eq 'a') < 75, '.roll(100) (1)';
ok @a.grep(* eq 'a') + 2 < @a.grep(* eq 'b'), '.roll(100) (2)';
#?pugs skip '.total NYI'
#?niecza skip '.total NYI'
is $b.total, 3, '.roll should not change Bag';
}

Expand All @@ -269,6 +273,8 @@ sub showkv($x) {
is +@a, 100, '.roll(100) returns 100 items';
ok @a.grep(* eq 'a') > 97, '.roll(100) (1)';
ok @a.grep(* eq 'b') < 3, '.roll(100) (2)';
#?pugs skip '.total NYI'
#?niecza skip '.total NYI'
is $b.total, 100000000001, '.roll should not change Bag';
}

Expand All @@ -289,6 +295,8 @@ sub showkv($x) {
is +@a, 3, '.pick(*) returns the right number of items';
is @a.grep(* eq 'a').elems, 1, '.pick(*) (1)';
is @a.grep(* eq 'b').elems, 2, '.pick(*) (2)';
#?pugs skip '.total NYI'
#?niecza skip '.total NYI'
is $b.total, 3, '.pick should not change Bag';
}

Expand All @@ -302,11 +310,15 @@ sub showkv($x) {
is +@a, 100, '.pick(100) returns 100 items';
ok @a.grep(* eq 'a') > 98, '.pick(100) (1)';
ok @a.grep(* eq 'b') < 2, '.pick(100) (2)';
#?pugs skip '.total NYI'
#?niecza skip '.total NYI'
is $b.total, 100000000001, '.pick should not change Bag';
}

# L<S32::Containers/Bag/grab>

#?pugs skip '.grab NYI'
#?niecza skip '.grab NYI'
{
my $b = bag <a b b c c c>;
dies_ok { $b.grab }, 'cannot call .grab on a Bag';
Expand Down
16 changes: 16 additions & 0 deletions S02-types/baghash.t
Expand Up @@ -43,6 +43,8 @@ sub showkv($x) {
is ~$b<a b>, "5 1", 'Multiple-element access';
is ~$b<a santa b easterbunny>, "5 0 1 0", 'Multiple-element access (with nonexistent elements)';

#?pugs skip '.total NYI'
#?niecza skip '.total NYI'
is $b.total, 8, '.total gives sum of values';
is +$b, 8, '+$bag gives sum of values';

Expand Down Expand Up @@ -264,6 +266,8 @@ sub showkv($x) {
is +@a, 100, '.roll(100) returns 100 items';
ok 2 < @a.grep(* eq 'a') < 75, '.roll(100) (1)';
ok @a.grep(* eq 'a') + 2 < @a.grep(* eq 'b'), '.roll(100) (2)';
#?pugs skip '.total NYI'
#?niecza skip '.total NYI'
is $b.total, 3, '.roll should not change BagHash';
}

Expand All @@ -277,6 +281,8 @@ sub showkv($x) {
is +@a, 100, '.roll(100) returns 100 items';
ok @a.grep(* eq 'a') > 97, '.roll(100) (1)';
ok @a.grep(* eq 'b') < 3, '.roll(100) (2)';
#?pugs skip '.total NYI'
#?niecza skip '.total NYI'
is $b.total, 100000000001, '.roll should not change BagHash';
}

Expand All @@ -297,6 +303,8 @@ sub showkv($x) {
is +@a, 3, '.pick(*) returns the right number of items';
is @a.grep(* eq 'a').elems, 1, '.pick(*) (1)';
is @a.grep(* eq 'b').elems, 2, '.pick(*) (2)';
#?pugs skip '.total NYI'
#?niecza skip '.total NYI'
is $b.total, 3, '.pick should not change BagHash';
}

Expand All @@ -310,11 +318,15 @@ sub showkv($x) {
is +@a, 100, '.pick(100) returns 100 items';
ok @a.grep(* eq 'a') > 98, '.pick(100) (1)';
ok @a.grep(* eq 'b') < 2, '.pick(100) (2)';
#?pugs skip '.total NYI'
#?niecza skip '.total NYI'
is $b.total, 100000000001, '.pick should not change BagHash';
}

# L<S32::Containers/BagHash/grab>

#?pugs skip '.grab NYI'
#?niecza skip '.grab NYI'
{
my $b = BagHash.new("a", "b", "b");

Expand All @@ -328,6 +340,8 @@ sub showkv($x) {
is $b.total, 0, '.grab *should* change BagHash';
}

#?pugs skip '.grab NYI'
#?niecza skip '.grab NYI'
{
my $b = BagHash.new("a", "b", "b");
my @a = $b.grab: *;
Expand All @@ -337,6 +351,8 @@ sub showkv($x) {
is $b.total, 0, '.grab *should* change BagHash';
}

#?pugs skip '.grab NYI'
#?niecza skip '.grab NYI'
{
my $b = {"a" => 100000000000, "b" => 1}.BagHash;

Expand Down
8 changes: 8 additions & 0 deletions S02-types/set.t
Expand Up @@ -248,6 +248,8 @@ sub showset($s) { $s.keys.sort.join(' ') }
@a = $s.roll: 100;
is +@a, 100, '.roll(100) returns 100 items';
is @a.grep(* eq 'a' | 'b' | 'c').elems, 100, '.roll(100) returned "a"s, "b"s, and "c"s';
#?pugs skip '.total NYI'
#?niecza skip '.total NYI'
is $s.total, 3, '.roll should not change Set';
}

Expand All @@ -259,6 +261,8 @@ sub showset($s) { $s.keys.sort.join(' ') }
is @a.sort.join, 'abcdefgh', 'Set.pick(*) gets all elements';
isnt @a.join, 'abcdefgh', 'Set.pick(*) returns elements in a random order';
# There's only a 1/40_320 chance of that test failing by chance alone.
#?pugs skip '.total NYI'
#?niecza skip '.total NYI'
is $s.total, 8, '.pick should not change Set';
}

Expand All @@ -274,11 +278,15 @@ sub showset($s) { $s.keys.sort.join(' ') }
ok @a.grep(* eq 'a').elems <= 1, '.pick(2) returned at most one "a"';
ok @a.grep(* eq 'b').elems <= 1, '.pick(2) returned at most one "b"';
ok @a.grep(* eq 'c').elems <= 1, '.pick(2) returned at most one "c"';
#?pugs skip '.total NYI'
#?niecza skip '.total NYI'
is $s.total, 3, '.pick should not change Set';
}

# L<S32::Containers/Set/grab>

#?pugs skip '.grab NYI'
#?niecza skip '.grab NYI'
{
my $s = set <a b c>;
dies_ok { $s.grab }, 'cannot call .grab on a Set';
Expand Down
10 changes: 10 additions & 0 deletions S02-types/sethash.t
Expand Up @@ -244,6 +244,8 @@ sub showset($s) { $s.keys.sort.join(' ') }
@a = $s.roll: 100;
is +@a, 100, '.roll(100) returns 100 items';
is @a.grep(* eq 'a' | 'b' | 'c').elems, 100, '.roll(100) returned "a"s, "b"s, and "c"s';
#?pugs skip '.total NYI'
#?niecza skip '.total NYI'
is $s.total, 3, '.roll should not change the SetHash';
}

Expand All @@ -255,6 +257,8 @@ sub showset($s) { $s.keys.sort.join(' ') }
is @a.sort.join, 'abcdefgh', 'SetHash.pick(*) gets all elements';
isnt @a.join, 'abcdefgh', 'SetHash.pick(*) returns elements in a random order';
# There's only a 1/40_320 chance of that test failing by chance alone.
#?pugs skip '.total NYI'
#?niecza skip '.total NYI'
is $s.total, 8, '.pick should not change the SetHash';
}

Expand All @@ -270,11 +274,15 @@ sub showset($s) { $s.keys.sort.join(' ') }
ok @a.grep(* eq 'a').elems <= 1, '.pick(2) returned at most one "a"';
ok @a.grep(* eq 'b').elems <= 1, '.pick(2) returned at most one "b"';
ok @a.grep(* eq 'c').elems <= 1, '.pick(2) returned at most one "c"';
#?pugs skip '.total NYI'
#?niecza skip '.total NYI'
is $s.total, 3, '.pick should not change the SetHash';
}

# L<S32::Containers/SetHash/grab>

#?pugs skip '.grab NYI'
#?niecza skip '.grab NYI'
{
my $s = SetHash.new(<a b c d e f g h>);
my @a = $s.grab: *;
Expand All @@ -284,6 +292,8 @@ sub showset($s) { $s.keys.sort.join(' ') }
is $s.total, 0, '.grab *should* change the SetHash';
}

#?pugs skip '.grab NYI'
#?niecza skip '.grab NYI'
{
my $s = SetHash.new(<a b c>);

Expand Down

0 comments on commit 57a3771

Please sign in to comment.