Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Replace more eval-dies-ok with throws-like (S15/S29)
  • Loading branch information
usev6 committed Sep 28, 2015
1 parent 106b31a commit 202bbe6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
6 changes: 4 additions & 2 deletions S15-literals/identifiers.t
Expand Up @@ -7,9 +7,11 @@ plan 7;
# tests that the proper characters are supported
eval-lives-ok('my $foo', "Handles ASCII identifier");
eval-lives-ok('my $foo', "Handles non-ASCII identifier");
eval-dies-ok('my $১০kinds', "Doesn't allow non-ASCII digits at start of identifier");
throws-like 'my $১০kinds', X::Syntax::Variable::Numeric,
"Doesn't allow non-ASCII digits at start of identifier";

eval-dies-ok('my $̈a;', "Combining marks not allowed as first character of identifier");
throws-like 'my $̈a;', X::Syntax::Malformed,
"Combining marks not allowed as first character of identifier";

my $ẛ̣ = 42; # LATIN SMALL LETTER LONG S WITH DOT ABOVE + COMBINING DOT BELOW

Expand Down
32 changes: 16 additions & 16 deletions S15-literals/numbers.t
Expand Up @@ -22,10 +22,10 @@ is 4᱂, 42, "Can mix scripts in one number";

# check that only Nd characters are allowed
# XXX might want to check for a specific exception at some point?
eval-dies-ok("say ↈ;", "Numerals in category 'Nl' not allowed as numeric literal");
eval-dies-ok("say 𒐀", "Numerals in category 'Nl' not allowed as numeric literal, even if its value is an integer within the range 0..9");
eval-dies-ok("say ፼", "Numerals in category 'No' not allowed as numeric literal");
eval-dies-ok("say ⓿", "Numerals in category 'No' not allowed as numeric literal, even if its value is an integer within the range 0..9");
throws-like "say ↈ;", X::Comp::Group, "Numerals in category 'Nl' not allowed as numeric literal";
throws-like "say 𒐀", X::Comp::Group, "Numerals in category 'Nl' not allowed as numeric literal, even if its value is an integer within the range 0..9";
throws-like "say ፼", X::Comp::Group, "Numerals in category 'No' not allowed as numeric literal";
throws-like "say ⓿", X::Comp::Group, "Numerals in category 'No' not allowed as numeric literal, even if its value is an integer within the range 0..9";

# other radices

Expand All @@ -34,43 +34,43 @@ is 0b101010, 42, "ASCII binary literals work";
#?rakudo.jvm 2 skip "Confused"
is 0b༡༠༡༠༡༠, 42, "Non-ASCII binary literals work";
is 0b༡༠༡010, 42, "Binary literals with a mixture of scripts work";
eval-dies-ok("say 0b¹0", "Numerals in category 'No' can't be used in binary literals");
eval-dies-ok("say 0b1〇", "Numerals in category 'Nl' can't be used in binary literals");
throws-like "say 0b¹0", X::Syntax::Confused, "Numerals in category 'No' can't be used in binary literals";
throws-like "say 0b1〇", X::Syntax::Confused, "Numerals in category 'Nl' can't be used in binary literals";

# octal
is 0o755, 493, "ASCII octal literals work";
#?rakudo.jvm 2 skip "Confused"
is 0o᠗᠕᠕, 493, "Non-ASCII octal literals work";
is 0o᠗5᠕, 493, "Octal literals with a mixture of scripts work";
eval-dies-ok("say 0o7₅₅", "Numerals in category 'No' can't be used in octal literals");
eval-dies-ok("say 0oⅦ55", "Numerals in category 'Nl' can't be used in octal literals");
throws-like "say 0o7₅₅", X::Syntax::Confused, "Numerals in category 'No' can't be used in octal literals";
throws-like "say 0oⅦ55", X::Syntax::Confused, "Numerals in category 'Nl' can't be used in octal literals";

# hexadecimal
is 0x42, 66, "ASCII hexadecimal literals work";
#?rakudo.jvm 2 skip "Confused"
is 0x๔๒, 66, "Non-ASCII hexadecimal literals work";
is 0x๔2, 66, "Hexadecimal literals with a mixture of scripts work";
eval-dies-ok("say 0x④2", "Numerals in category 'No' can't be used in hexadecimal literals");
eval-dies-ok("say 0x4〢", "Numerals in category 'Nl' can't be used in hexadecimal literals");
throws-like "say 0x④2", X::Syntax::Confused, "Numerals in category 'No' can't be used in hexadecimal literals";
throws-like "say 0x4〢", X::Syntax::Confused, "Numerals in category 'Nl' can't be used in hexadecimal literals";

is 0xCAFE, 51966, "Uppercase ASCII letters work in hexadecimal literals";
is 0xcafe, 51966, "Lowercase ASCII letters work in hexadecimal literals";
#?rakudo.jvm 3 skip "Confused"
is 0xCAFE, 51966, "Uppercase fullwidth letters work in hexadecimal literals";
is 0xcafe, 51966, "Lowercase fullwidth letters work in hexadecimal literals";
is 0xCaFe, 51966, "Valid Hex_Digit characters from different scripts can be mixed in hexadecimal literals";
eval-dies-ok("say 0xΓαfe", "Can't use characters without true Hex_Digit properties in hexadecimal literals");
eval-dies-ok("say 0xCAF⒕", "Numerals in category 'No' can't be used in hexadecimal literals");
eval-dies-ok("say 0xC𐏓FE", "Numerals in category 'Nl' can't be used in hexadecimal literals");
throws-like "say 0xΓαfe", X::Syntax::Confused, "Can't use characters without true Hex_Digit properties in hexadecimal literals";
throws-like "say 0xCAF⒕", X::Syntax::Confused, "Numerals in category 'No' can't be used in hexadecimal literals";
throws-like "say 0xC𐏓FE", X::Syntax::Confused, "Numerals in category 'Nl' can't be used in hexadecimal literals";

# generic radices
is :36<Unicodez>, 2402100600299, "ASCII letters work in general radix numbers";
#?rakudo.jvm 2 skip "Malformed radix number"
is :36<Unicodez>, 2402100600299, "Fullwidth letters work in general radix numbers";
is :36<Unicodez>, 2402100600299, "Mixture of ASCII and fullwidth letters work in general radix numbers";
eval-dies-ok("say :36<αω>", "Scripts without Hex_Digit characters not allowed in general radix numbers");
throws-like "say :36<αω>", X::Syntax::Malformed, "Scripts without Hex_Digit characters not allowed in general radix numbers";

#?rakudo.jvm 1 skip "Malformed radix number"
is :36<utf១៦>, 51760986, "Nd numerals can be used in general radix numbers";
eval-dies-ok("say :36<utfⅧ>", "Nl numerals are not allowed in general radix numbers");
eval-dies-ok("say :36<utf㉜>", "No numerals are not allowed in general radix numbers");
throws-like "say :36<utfⅧ>", X::Syntax::Malformed, "Nl numerals are not allowed in general radix numbers";
throws-like "say :36<utf㉜>", X::Syntax::Malformed, "No numerals are not allowed in general radix numbers";
2 changes: 1 addition & 1 deletion S29-any/isa.t
Expand Up @@ -41,7 +41,7 @@ plan 10;

{
my @arr = <1 2 3 4>;
eval-dies-ok 'isa(@arr, Array)', 'no sub called isa()';
throws-like 'isa(@arr, Array)', X::Undeclared::Symbols, 'no sub called isa()';
dies-ok { @arr.isa() }, '... isa() with a single arg is a failing case (invocant notation)';

dies-ok { @arr.isa(Array, Hash) }, '... isa() with a extra args is a failing case (invocant notation)';
Expand Down

0 comments on commit 202bbe6

Please sign in to comment.