Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Tests for hash slice adverb exception handling
  • Loading branch information
lizmat committed Jul 6, 2015
1 parent 665d368 commit 87dd187
Showing 1 changed file with 99 additions and 15 deletions.
114 changes: 99 additions & 15 deletions S32-hash/adverbs.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 4 * ( 1 + 14 * 17 );
plan 4 * ( 1 + 14 * 20 );

#-------------------------------------------------------------------------------
# initialisations
Expand Down Expand Up @@ -52,7 +52,13 @@ for $%a, Any, $%i, Int, $%c, Any, $%j, Int -> %h, $T {
is %h<b>:p($ok), (b=>2), "$n single key existing: :p(\$ok)";
is %h<b>:!p, (b=>2), "$n single key existing: :!p";
is %h<b>:p($no), (b=>2), "$n single key existing: :p(\$no)";
} #17

throws-like '%h<b>:k:v', X::Adverb::Slice,
:what(%h.name), :nogo(<k v>);
throws-like '%h<b>:zorp', X::AdHoc; # caught by MMD
throws-like '%h<b>:kv:p:zip:zop', X::Adverb::Slice,
:what(%h.name), :nogo(<kv p>), :unexpected(<zip zop>);
} #20

# array single existing key
{
Expand All @@ -73,7 +79,13 @@ for $%a, Any, $%i, Int, $%c, Any, $%j, Int -> %h, $T {
is %h{@b}:p($ok), (b=>2), "$n single key existing: :p(\$ok)";
is %h{@b}:!p, (b=>2), "$n single key existing: :!p";
is %h{@b}:p($no), (b=>2), "$n single key existing: :p(\$no)";
} #17

throws-like '%h{@b}:k:v', X::Adverb::Slice,
:what(%h.name), :nogo(<k v>);
throws-like '%h{@b}:rickroll', X::AdHoc; # caught by MMD
throws-like '%h{@b}:kv:p:zip:zop', X::Adverb::Slice,
:what(%h.name), :nogo(<kv p>), :unexpected(<zip zop>);
} #20

# single missing key
{
Expand All @@ -94,7 +106,13 @@ for $%a, Any, $%i, Int, $%c, Any, $%j, Int -> %h, $T {
is %h<B>:p($ok), (), "$n single key missing: :p";
is %h<B>:!p, (B=>$T), "$n single key missing: :!p";
is %h<B>:p($no), (B=>$T), "$n single key missing: :p(\$no)";
} #17

throws-like '%h<B>:k:v', X::Adverb::Slice,
:what(%h.name), :nogo(<k v>);
throws-like '%h<B>:baxter', X::AdHoc; # caught by MMD
throws-like '%h<B>:kv:p:zip:zop', X::Adverb::Slice,
:what(%h.name), :nogo(<kv p>), :unexpected(<zip zop>);
} #20

# array single missing key
{
Expand All @@ -115,7 +133,13 @@ for $%a, Any, $%i, Int, $%c, Any, $%j, Int -> %h, $T {
is %h{@B}:p($ok), (), "$n array single key missing: :p";
is %h{@B}:!p, (B=>$T), "$n array single key missing: :!p";
is %h{@B}:p($no), (B=>$T), "$n array single key missing: :p(\$no)";
} #17

throws-like '%h{@B}:k:v', X::Adverb::Slice,
:what(%h.name), :nogo(<k v>);
throws-like '%h{@B}:jefferson', X::AdHoc; # caught by MMD
throws-like '%h{@B}:kv:p:zip:zop', X::Adverb::Slice,
:what(%h.name), :nogo(<kv p>), :unexpected(<zip zop>);
} #20

# multiple existing keys
{
Expand All @@ -136,7 +160,13 @@ for $%a, Any, $%i, Int, $%c, Any, $%j, Int -> %h, $T {
is %h<b c>:p($ok), (b=>2,c=>3), "$n multiple key existing: :p(\$ok)";
is %h<b c>:!p, (b=>2,c=>3), "$n multiple key existing: :!p";
is %h<b c>:p($no), (b=>2,c=>3), "$n multiple key existing: :p(\$no)";
} #17

throws-like '%h<b c>:k:v', X::Adverb::Slice,
:what(%h.name), :nogo(<k v>);
throws-like '%h<b c>:egg', X::AdHoc; # caught by MMD
throws-like '%h<b c>:kv:p:zip:zop', X::Adverb::Slice,
:what(%h.name), :nogo(<kv p>), :unexpected(<zip zop>);
} #20

# array multiple existing keys
{
Expand All @@ -157,7 +187,13 @@ for $%a, Any, $%i, Int, $%c, Any, $%j, Int -> %h, $T {
is %h{@bc}:p($ok), (b=>2,c=>3), "$n array multi key existing: :p(\$ok)";
is %h{@bc}:!p, (b=>2,c=>3), "$n array multi key existing: :!p";
is %h{@bc}:p($no), (b=>2,c=>3), "$n array multi key existing: :p(\$no)";
} #17

throws-like '%h{@bc}:k:v', X::Adverb::Slice,
:what(%h.name), :nogo(<k v>);
throws-like '%h{@bc}:omelet', X::AdHoc; # caught by MMD
throws-like '%h{@bc}:kv:p:zip:zop', X::Adverb::Slice,
:what(%h.name), :nogo(<kv p>), :unexpected(<zip zop>);
} #20

# range multiple existing keys
{
Expand All @@ -178,7 +214,13 @@ for $%a, Any, $%i, Int, $%c, Any, $%j, Int -> %h, $T {
is %h{"b".."c"}:p($ok), (b=>2,c=>3), "$n range mult key exist: :p(\$ok)";
is %h{"b".."c"}:!p, (b=>2,c=>3), "$n range mult key exist: :!p";
is %h{"b".."c"}:p($no), (b=>2,c=>3), "$n range mult key exist: :p(\$no)";
} #17

throws-like '%h{"b".."c"}:k:v', X::Adverb::Slice,
:what(%h.name), :nogo(<k v>);
throws-like '%h{"b".."c"}:rivet', X::AdHoc; # caught by MMD
throws-like '%h{"b".."c"}:kv:p:zip:zop', X::Adverb::Slice,
:what(%h.name), :nogo(<kv p>), :unexpected(<zip zop>);
} #20

# multiple missing keys
{
Expand All @@ -199,7 +241,13 @@ for $%a, Any, $%i, Int, $%c, Any, $%j, Int -> %h, $T {
is %h<B C>:p($ok), (), "$n multiple key missing: :p";
is %h<B C>:!p, (B=>$T,C=>$T), "$n multiple key missing: :!p";
is %h<B C>:p($no), (B=>$T,C=>$T), "$n multiple key missing: :p(\$no)";
} #17

throws-like '%h<B C>:k:v', X::Adverb::Slice,
:what(%h.name), :nogo(<k v>);
throws-like '%h<B C>:echt', X::AdHoc; # caught by MMD
throws-like '%h<B C>:kv:p:zip:zop', X::Adverb::Slice,
:what(%h.name), :nogo(<kv p>), :unexpected(<zip zop>);
} #20

# array multiple missing keys
{
Expand All @@ -220,7 +268,13 @@ for $%a, Any, $%i, Int, $%c, Any, $%j, Int -> %h, $T {
is %h{@BC}:p($ok), (), "$n array multi key missing: :p";
is %h{@BC}:!p, (B=>$T,C=>$T), "$n array multi key missing: :!p";
is %h{@BC}:p($no), (B=>$T,C=>$T), "$n array multi key missing: :p(\$no)";
} #17

throws-like '%h{@BC}:k:v', X::Adverb::Slice,
:what(%h.name), :nogo(<k v>);
throws-like '%h{@BC}:gaston', X::AdHoc; # caught by MMD
throws-like '%h{@BC}:kv:p:zip:zop', X::Adverb::Slice,
:what(%h.name), :nogo(<kv p>), :unexpected(<zip zop>);
} #20

# range multiple missing keys
{
Expand All @@ -241,7 +295,13 @@ for $%a, Any, $%i, Int, $%c, Any, $%j, Int -> %h, $T {
is %h{"B".."C"}:p($ok), (), "$n range mul key miss: :p";
is %h{"B".."C"}:!p, (B=>$T,C=>$T), "$n range mul key miss: :!p";
is %h{"B".."C"}:p($no), (B=>$T,C=>$T), "$n range mul key miss: :p(\$no)";
} #17

throws-like '%h{"B".."C"}:k:v', X::Adverb::Slice,
:what(%h.name), :nogo(<k v>);
throws-like '%h{"B".."C"}:noshit', X::AdHoc; # caught by MMD
throws-like '%h{"B".."C"}:kv:p:zip:zop', X::Adverb::Slice,
:what(%h.name), :nogo(<kv p>), :unexpected(<zip zop>);
} #20

# mixed existing/missing keys
{
Expand All @@ -262,7 +322,13 @@ for $%a, Any, $%i, Int, $%c, Any, $%j, Int -> %h, $T {
is %h<b C>:p($ok), (b=>2), "$n multiple key mixed: :p";
is %h<b C>:!p, (b=>2,C=>$T), "$n multiple key mixed: :!p";
is %h<b C>:p($no), (b=>2,C=>$T), "$n multiple key mixed: :p(\$no)";
} #17

throws-like '%h<b C>:k:v', X::Adverb::Slice,
:what(%h.name), :nogo(<k v>);
throws-like '%h<b C>:fnoppo', X::AdHoc; # caught by MMD
throws-like '%h<b C>:kv:p:zip:zop', X::Adverb::Slice,
:what(%h.name), :nogo(<kv p>), :unexpected(<zip zop>);
} #20

# array mixed existing/missing keys
{
Expand All @@ -283,7 +349,13 @@ for $%a, Any, $%i, Int, $%c, Any, $%j, Int -> %h, $T {
is %h{@bC}:p($ok), (b=>2), "$n array multiple key mixed: :p";
is %h{@bC}:!p, (b=>2,C=>$T), "$n array multiple key mixed: :!p";
is %h{@bC}:p($no), (b=>2,C=>$T), "$n array multiple key mixed: :p(\$no)";
} #17

throws-like '%h{@bC}:k:v', X::Adverb::Slice,
:what(%h.name), :nogo(<k v>);
throws-like '%h{@bC}:frits', X::AdHoc; # caught by MMD
throws-like '%h{@bC}:kv:p:zip:zop', X::Adverb::Slice,
:what(%h.name), :nogo(<kv p>), :unexpected(<zip zop>);
} #20

# whatever
{
Expand All @@ -304,7 +376,13 @@ for $%a, Any, $%i, Int, $%c, Any, $%j, Int -> %h, $T {
is (%h{*}:p($ok)).sort(*.key), (:1a,:2b,:3c,:4d), "$n whatever: :p";
is (%h{*}:!p).sort(*.key), (:1a,:2b,:3c,:4d), "$n whatever: :!p";
is (%h{*}:p($no)).sort(*.key), (:1a,:2b,:3c,:4d), "$n whatever: :p(\$no)";
} #17

throws-like '%h{*}:k:v', X::Adverb::Slice,
:what(%h.name), :nogo(<k v>);
throws-like '%h{*}:whatever', X::AdHoc; # caught by MMD
throws-like '%h{*}:kv:p:zip:zop', X::Adverb::Slice,
:what(%h.name), :nogo(<kv p>), :unexpected(<zip zop>);
} #20

# zen
{
Expand All @@ -325,7 +403,13 @@ for $%a, Any, $%i, Int, $%c, Any, $%j, Int -> %h, $T {
is (%h{}:p($ok)).sort(*.key), (:1a,:2b,:3c,:4d), "$n zen: :p";
is (%h{}:!p).sort(*.key), (:1a,:2b,:3c,:4d), "$n zen: :!p";
is (%h{}:p($no)).sort(*.key), (:1a,:2b,:3c,:4d), "$n zen: :p(\$no)";
} #17

throws-like '%h{}:k:v', X::Adverb::Slice,
:what(%h.name), :nogo(<k v>);
throws-like '%h{}:zen', X::AdHoc; # caught by MMD
throws-like '%h{}:kv:p:zip:zop', X::Adverb::Slice,
:what(%h.name), :nogo(<kv p>), :unexpected(<zip zop>);
} #20

}

Expand Down

0 comments on commit 87dd187

Please sign in to comment.