Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Transmogrified the @A[]:delete tests to @A[]:exists
  • Loading branch information
lizmat committed May 15, 2013
1 parent 7d2d74c commit 1b950fe
Showing 1 changed file with 25 additions and 81 deletions.
106 changes: 25 additions & 81 deletions S32-hash/exists-adverb.t
Expand Up @@ -65,93 +65,37 @@ sub gen_hash {
{
my @a = gen_array;
is @a.elems, 10, "basic sanity";
} #1

{ # single element
my @a = gen_array;
my $b = @a[3];

#?pugs 3 skip "no adverbials"
#?niecza 3 skip "no adverbials"
is @a[3]:delete, $b, "Test for delete single element";
#?rakudo todo "not being destructively read yet"
is @a[3], $default, "3 should be deleted now";
is +@a, 10, "array still has same length";

#?pugs 11 skip "no adverbials"
#?niecza 11 skip "no adverbials"
my $c = @a[9];
is @a[9]:!delete, $c, "Test non-deletion with ! single elem";
is @a[9], $c, "9 should not have been deleted";
is @a[9]:delete(0), $c, "Test non-deletion with (0) single elem";
is @a[9], $c, "9 should not have been deleted";
is @a[9]:delete(False), $c, "Test non-deletion with (False) single elem";
is @a[9], $c, "9 should not have been deleted";
is @a[9]:delete($dont), $c, "Test non-deletion with (\$dont) single elem";
is @a[9], $c, "9 should not have been deleted";
is @a[9]:delete(1), $c, "Test deletion with (1) single elem";
#?rakudo 2 todo "not being destructively read yet"
is @a[9], $default, "9 should be deleted now";
is +@a, 9, "array should be shortened now";
} #14

{ # multiple elements
my @a = gen_array;
my @b = @a[1,3];

#?pugs 3 skip "no adverbials"
#?niecza 3 skip "no adverbials"
is @a[1,3]:delete, @b, "Test for delete multiple elements";
#?rakudo todo "not being destructively read yet"
is @a[1,3], $default, "1 3 should be deleted now";
is +@a, 10, "1 3 should be deleted now";

#?pugs 11 skip "no adverbials"
#?niecza 11 skip "no adverbials"
my @c = @a[2,4,9];
is @a[2,4,9]:!delete, @c, "Test non-deletion with ! multiple";
is @a[2,4,9], @c, "2 4 9 should not have been deleted";
is @a[2,4,9]:delete(0), @c, "Test non-deletion with (0) multiple";
is @a[2,4,9], @c, "2 4 9 should not have been deleted";
is @a[2,4,9]:delete(False), @c, "Test non-deletion with (False) multiple";
is @a[2,4,9], @c, "2 4 9 should not have been deleted";
is @a[2,4,9]:delete($dont), @c, "Test non-deletion with (\$dont) multiple";
is @a[2,4,9], @c, "2 4 9 should not have been deleted";
is @a[2,4,9]:delete(1), @c, "Test deletion with (1) multiple";
#?rakudo 2 todo "not being destructively read yet"
ok !any(@a[2,4,9]), "2 4 9 should be deleted now";
is +@a, 9, "array should be shortened now";
} #14

{ # whatever
my @a = gen_array;
my @all = @a[^10];

#?pugs 2 skip "no adverbials"
#?niecza 2 skip "no adverbials"
is @a[*]:delete, @all, "Test deletion with whatever";
#?rakudo todo "not being destructively read yet"
is +@a, 0, "* should be deleted now";
} #2

{
my @a = gen_array;
my @all = @a[^10];
ok @a[3]:exists, "Test for exists single element";
ok !(@a[10]:exists), "Test for non-exists single element";

#?pugs 10 skip "no adverbials"
#?niecza 10 skip "no adverbials"
is @a[*]:!delete, @all, "Test non-deletion with ! whatever";
is +@a, 10, "* should not be deleted now";
is @a[*]:delete(0), @all, "Test non-deletion with (0) whatever";
is +@a, 10, "* should not be deleted now";
is @a[*]:delete(False), @all, "Test non-deletion with (False) whatever";
is +@a, 10, "* should not be deleted now";
is @a[*]:delete($dont), @all, "Test non-deletion with (\$dont) whatever";
is +@a, 10, "* should not be deleted now";
is @a[*]:delete(1), @all, "Test deletion with (1) whatever";
#?rakudo todo "not being destructively read yet"
is +@a, 0, "* should be deleted now";
} #10
ok @a[9]:!exists, "Test non-exists with ! single elem 9";
ok !(@a[10]:!exists), "Test non-exists with ! single elem 10";
ok @a[9]:exists(0), "Test non-exists with (0) single elem 9";
ok !(@a[10]:exists(0)), "Test non-exists with (0) single elem 10";
ok @a[9]:exists(False), "Test non-exists with (False) single elem 9";
ok !(@a[10]:exists(False)), "Test non-exists with (False) single elem 10";
ok @a[9]:exists($dont), "Test non-exists with (\$dont) single elem 9";
ok !(@a[10]:exists($dont)), "Test non-exists with (\$dont) single elem 10";
ok @a[9]:exists(1), "Test exists with (1) single elem 9";
ok !(@a[10]:exists(1)), "Test exists with (1) single elem 10";

#?pugs 6 skip "no adverbials"
#?rakudo 6 skip "oh noes, it dies"
is @a[1,2,4]:exists, (True, True, True), "Test for exists TTT";
is @a[1,2,10]:exists, (True, True, False), "Test for exists TTF";
is @a1[*]>:exists, (True xx 26), "Test for non-exists T*";
#?niezca 3 todo "adverbial pairs only used as True"
is @a[1,2,4]:!exists, (False,False,False), "Test for non-exists FFF";
is @a[1,2,10]:!exists, (False,False,True), "Test for non-exists FFT";
is %h1[*]>:!exists, (False xx 26), "Test for non-exists F*";

is +@a, 10, "* should be deleted now";
} #20

#-------------------------------------------------------------------------------
# Scalar
Expand Down

0 comments on commit 1b950fe

Please sign in to comment.