Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 53 lines (29 sloc) 1.412 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
f34540b [t/spec] fudged underscores.t for rakudo, changed is $a, $b to ok $a == ...
moritz authored
35 #?rakudo 2 todo 'underscores in floating point numbers'
36 ok 3.1_41 == 3.141, "Underscores work with floating point after decimal";
d53b422 [t] moved underscores.t to spec/, simplified
moritz authored
37
f34540b [t/spec] fudged underscores.t for rakudo, changed is $a, $b to ok $a == ...
moritz authored
38 ok 10_0.8 == 100.8, "Underscores work with floating point before decimal";
d53b422 [t] moved underscores.t to spec/, simplified
moritz authored
39
40 is 0xdead_beef, 0xdeadbeef, "Underscores work with hex";
41
42 is 0b1101_1110_1010_1101_1011_1110_1110_1111, 0xdeadbeef, "Underscores work with binary";
43
f34540b [t/spec] fudged underscores.t for rakudo, changed is $a, $b to ok $a == ...
moritz authored
44 #?rakudo skip 'parse 2e0_1'
d53b422 [t] moved underscores.t to spec/, simplified
moritz authored
45 is 2e0_1, 20, "Underscores work in the argument for e";
46
f34540b [t/spec] fudged underscores.t for rakudo, changed is $a, $b to ok $a == ...
moritz authored
47 #?rakudo todo 'underscores in floating point numbers'
48 ok 2.1_23 == 2.123, "2.1_23 parses as number";
d53b422 [t] moved underscores.t to spec/, simplified
moritz authored
49
50 dies_ok { 2._foo }, "2._foo parses as method call";
51 dies_ok { 2._123 }, "2._123 parses as method call";
52 dies_ok { 2._e23 }, "2._23 parses as method call";
Something went wrong with that request. Please try again.