Skip to content

Commit

Permalink
Fix S32-hash/delete-adverb.t and squish.t if hash keys iter randomized
Browse files Browse the repository at this point in the history
Soon I will be making MoarVM randomize the order of the iterator. Though
we have a random order each start of MoarVM currently due to the random
hash secret, if you make two hashes and add things in the same order you
will get the same order as each other when you do .keys. This will be
changing soon and you can't rely on the order (unless you don't modify
the hash, in that case order is consistent).
  • Loading branch information
samcv committed Jul 5, 2018
1 parent 1e17e66 commit 6b98c26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions S32-hash/delete-adverb.t
Expand Up @@ -227,6 +227,8 @@ sub gen_hash {
is +%h, 0, "* should be deleted now";

%h = gen_hash;
@i = map { ($_,True) }, %h.keys;
@ni = map { ($_,False) }, %h.keys;
is %h{*}:!delete:exists:!kv, @i, ":!d:exists:!kv whatever";
is +%h, 26, "* should not be deleted";
is %h{*}:delete:!exists:!kv, @ni, "d:!exists:!kv whatever";
Expand Down
12 changes: 6 additions & 6 deletions S32-list/squish.t
Expand Up @@ -107,14 +107,14 @@ subtest 'with :with and :as' => {
my $with = { @with.push: "$^a $^b"; $^a + 1 == $^b };
is-deeply (1,2,3,2,1,0).squish(:$as,:$with), (1,2,1,0).Seq,
'order of :with operands, and first one of each run (:as)';
is bag(@as), bag(1,2,3,2,1,0), ':as callbacks called once per element';
is bag(@with), bag("1 2","2 3","3 2","2 1","1 0"),
is-deeply bag(@as), bag(1,2,3,2,1,0), ':as callbacks called once per element';
is-deeply bag(@with), bag("1 2","2 3","3 2","2 1","1 0"),
':with callbacks called minimum-ish number of times (:as)';

@with = ();
is-deeply (1,2,3,2,1,0).squish(:$with), (1,2,1,0).Seq,
'order of :with operands, and first one of each run';
is bag(@with), bag("1 2","2 3","3 2","2 1","1 0"),
is-deeply bag(@with), bag("1 2","2 3","3 2","2 1","1 0"),
':with callbacks called minimum-ish number of times.';

subtest 'squish with single element list with :as and :with' => {
Expand Down Expand Up @@ -151,9 +151,9 @@ subtest 'with :with and :as' => {
$i.push-all: my @c;
is-deeply @c, [1, 0], '.push-all values';

is bag(@as), bag(1,2,3,2,1,0),
is-deeply bag(@as), bag(1,2,3,2,1,0),
':as callbacks called once per element (fragged)';
is bag(@with), bag("1 2","2 3","3 2","2 1","1 0"),
is-deeply bag(@with), bag("1 2","2 3","3 2","2 1","1 0"),
':with callbacks called minimumish number of times (:as, fragged)';
}

Expand All @@ -169,7 +169,7 @@ subtest 'with :with and :as' => {

$i.push-all: my @c;
is-deeply @c, [1,0], '.push-all after a couple pull-ones';
is bag(@with), bag("1 2","2 3","3 2","2 1","1 0"),
is-deeply bag(@with), bag("1 2","2 3","3 2","2 1","1 0"),
':with callbacks called minimum-ish number of times (:as, fragged)';
}
}
Expand Down

0 comments on commit 6b98c26

Please sign in to comment.