Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 50 lines (26 sloc) 1.268 kB
d53b422 [t] moved underscores.t to spec/, simplified
moritz authored
1 use v6;
2
3 use Test;
4
5 =begin pod
6
7 _ should be allowed in numbers
8
9 But according to L<S02/Literals/"A single underscore is allowed only">, only between two digits.
10
11 =end pod
12
13 plan 19;
14
15 is 1_0, 10, "Single embedded underscore works";
16
17 eval_dies_ok '1__0', "Multiple embedded underscores fail";
18
19 eval_dies_ok '_10', "Leading underscore fails";
20
21 eval_dies_ok '10_', "Trailing underscore fails";
22
23 eval_dies_ok '10_.0', "Underscore before . fails";
24
25 eval_dies_ok '10._0', "Underscore after . fails";
26
27 eval_dies_ok '10_e1', "Underscore before e fails";
28
29 eval_dies_ok '10e_1', "Underscore after e fails";
30
31 eval_dies_ok '10_E1', "Underscore before E fails";
32
33 eval_dies_ok '10E_1', "Underscore after E fails";
34
35 is 3.1_41, 3.141, "Underscores work with floating point after decimal";
36
37 is 10_0.8, 100.8, "Underscores work with floating point before decimal";
38
39 is 0xdead_beef, 0xdeadbeef, "Underscores work with hex";
40
41 is 0b1101_1110_1010_1101_1011_1110_1110_1111, 0xdeadbeef, "Underscores work with binary";
42
43 is 2e0_1, 20, "Underscores work in the argument for e";
44
45 is 2.1_23, 2.123, "2.1_23 parses as number";
46
47 dies_ok { 2._foo }, "2._foo parses as method call";
48 dies_ok { 2._123 }, "2._123 parses as method call";
49 dies_ok { 2._e23 }, "2._23 parses as method call";
Something went wrong with that request. Please try again.