Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
test for unival literals
  • Loading branch information
TimToady committed Nov 25, 2015
1 parent a96334c commit 373ecf3
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions S15-literals/numbers.t
Expand Up @@ -2,7 +2,7 @@

use Test;

plan 41;
plan 46;

# basic test of literals
#?rakudo.jvm 2 skip "is not a valid number"
Expand All @@ -20,12 +20,17 @@ is 42 * 2, ٨٤, "ASCII-only expression can be succesfully compared to non-ASCII
is ᱄2, 42, "Can mix scripts in one number";
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?
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";
# check that No and Nl characters are allowed
is ↈ, 100000, "Numerals in category 'Nl' allowed as numeric literal";
is 𒐀, 2, "Numerals in category 'Nl' allowed as numeric literal";
throws-like "say 𒐀𒐀", X::Comp, "Numerals in category 'Nl' die when attempt is made to use as digit";
is ፼, 10000, "Numerals in category 'No' allowed as numeric literal";
is ⓿, 0, "Numerals in category 'No' allowed as numeric literal";
throws-like "say ⓿⓿", X::Comp, "Numerals in category 'No' die when attempt is made to use as digit";

is.WHAT, Rat, "vulgar fraction literal produces a Rat";
is.WHAT, Int, "Roman numeral literal produces a Int";
is ༳, -0.5, "Tibetan number literal produces a negative";

# other radices

Expand Down

0 comments on commit 373ecf3

Please sign in to comment.