Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[t] moved underscores.t to spec/, simplified

git-svn-id: http://svn.pugscode.org/pugs@22228 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
commit d53b42260f7b820322b09a9a42991fac8fa9c31b 1 parent e117f28
moritz authored
Showing with 49 additions and 0 deletions.
  1. +49 −0 S02-literals/underscores.t
49 S02-literals/underscores.t
View
@@ -0,0 +1,49 @@
+use v6;
+
+use Test;
+
+=begin pod
+
+_ should be allowed in numbers
+
+But according to L<S02/Literals/"A single underscore is allowed only">, only between two digits.
+
+=end pod
+
+plan 19;
+
+is 1_0, 10, "Single embedded underscore works";
+
+eval_dies_ok '1__0', "Multiple embedded underscores fail";
+
+eval_dies_ok '_10', "Leading underscore fails";
+
+eval_dies_ok '10_', "Trailing underscore fails";
+
+eval_dies_ok '10_.0', "Underscore before . fails";
+
+eval_dies_ok '10._0', "Underscore after . fails";
+
+eval_dies_ok '10_e1', "Underscore before e fails";
+
+eval_dies_ok '10e_1', "Underscore after e fails";
+
+eval_dies_ok '10_E1', "Underscore before E fails";
+
+eval_dies_ok '10E_1', "Underscore after E fails";
+
+is 3.1_41, 3.141, "Underscores work with floating point after decimal";
+
+is 10_0.8, 100.8, "Underscores work with floating point before decimal";
+
+is 0xdead_beef, 0xdeadbeef, "Underscores work with hex";
+
+is 0b1101_1110_1010_1101_1011_1110_1110_1111, 0xdeadbeef, "Underscores work with binary";
+
+is 2e0_1, 20, "Underscores work in the argument for e";
+
+is 2.1_23, 2.123, "2.1_23 parses as number";
+
+dies_ok { 2._foo }, "2._foo parses as method call";
+dies_ok { 2._123 }, "2._123 parses as method call";
+dies_ok { 2._e23 }, "2._23 parses as method call";
Please sign in to comment.
Something went wrong with that request. Please try again.