Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 182 lines (148 sloc) 4.243 kB
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
1 use v6;
2
3 use Test;
4
05c3d8d @diakopter re-attempt to fix smartlinks in S02 to headings that contain C<>
diakopter authored
5 #L<S02/The C<Num> and C<Rat> Types/Perl 6 intrinsically supports big integers>
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
6
3548dd2 @colomon Modernize tests a bit. Add new test. Unfudge for niecza.
colomon authored
7 plan 64;
f646c2d [t/spec] Test Num.perl. Who'd have thought that 1.0.perl wouldn't wo…
colomon authored
8
616002e @coke pugs fudges
coke authored
9 #?pugs 7 skip '.Num'
f646c2d [t/spec] Test Num.perl. Who'd have thought that 1.0.perl wouldn't wo…
colomon authored
10 isa_ok( eval(1.Num.perl), Num, 'eval 1.Num.perl is Num' );
11 is_approx( eval(1.Num.perl), 1, 'eval 1.Num.perl is 1' );
12 isa_ok( eval(0.Num.perl), Num, 'eval 0.Num.perl is Num' );
13 is_approx( eval(0.Num.perl), 0, 'eval 0.Num.perl is 0' );
14 isa_ok( eval((-1).Num.perl), Num, 'eval -1.Num.perl is Num' );
15 is_approx( eval((-1).Num.perl), -1, 'eval -1.Num.perl is -1' );
3548dd2 @colomon Modernize tests a bit. Add new test. Unfudge for niecza.
colomon authored
16 isa_ok( eval(1.1.Num.perl), Num, 'eval 1.1.Num.perl is Num' );
f646c2d [t/spec] Test Num.perl. Who'd have thought that 1.0.perl wouldn't wo…
colomon authored
17 is_approx( eval(1.1.perl), 1.1, 'eval 1.1.Num.perl is 1.1' );
616002e @coke pugs fudges
coke authored
18 #?pugs skip '.Num'
3548dd2 @colomon Modernize tests a bit. Add new test. Unfudge for niecza.
colomon authored
19 isa_ok( eval((-1.1).Num.perl), Num, 'eval -1.1.Num.perl is Num' );
f646c2d [t/spec] Test Num.perl. Who'd have thought that 1.0.perl wouldn't wo…
colomon authored
20 is_approx( eval((-1.1).perl), -1.1, 'eval -1.1.Num.perl is -1.1' );
616002e @coke pugs fudges
coke authored
21 #?pugs 2 skip '.Num'
3548dd2 @colomon Modernize tests a bit. Add new test. Unfudge for niecza.
colomon authored
22 isa_ok( eval(1e100.Num.perl), Num, 'eval 1e100.Num.perl is Num' );
23 is_approx( eval(1e100.Num.perl), 1e100, 'eval 1e100.Num.perl is 1' );
f646c2d [t/spec] Test Num.perl. Who'd have thought that 1.0.perl wouldn't wo…
colomon authored
24
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
25 {
26 my $a = 1; "$a";
207f13f [t] and [t/spec]
moritz authored
27 isa_ok($a, Int);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
28 is($a, "1", '1 stringification works');
29 }
30
31 {
32 my $a = -1; "$a";
207f13f [t] and [t/spec]
moritz authored
33 isa_ok($a, Int);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
34 is($a, "-1", '-1 stringification works');
35 }
36
05c3d8d @diakopter re-attempt to fix smartlinks in S02 to headings that contain C<>
diakopter authored
37 #L<S02/The C<Num> and C<Rat> Types/Rat supports extended precision rational arithmetic>
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
38 {
a4ba5fd [t/spec] correct meaning of infix:<div> and infix:</>. Patch courtesy…
moritz authored
39 my $a = 1 / 1;
207f13f [t] and [t/spec]
moritz authored
40 isa_ok($a, Rat);
685fe36 [t/spec] fix Rat stringification in num.t
moritz authored
41 is(~$a, "1", '1/1 stringification works');
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
42 }
43
44 {
207f13f [t] and [t/spec]
moritz authored
45 my $a = -1.0;
d08ca67 [t/spec] Bring num.t up-to-date a bit, and fudge it for Rakudo.
colomon authored
46 isa_ok($a, Rat);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
47 is($a, "-1", '-1 stringification works');
48 }
49
50 {
207f13f [t] and [t/spec]
moritz authored
51 my $a = 0.1;
d08ca67 [t/spec] Bring num.t up-to-date a bit, and fudge it for Rakudo.
colomon authored
52 isa_ok($a, Rat);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
53 is($a, "0.1", '0.1 stringification works');
54 }
55
56 {
57 my $a = -0.1; "$a";
d08ca67 [t/spec] Bring num.t up-to-date a bit, and fudge it for Rakudo.
colomon authored
58 isa_ok($a, Rat);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
59 is($a, "-0.1", '-0.1 stringification works');
60 }
61
62 {
63 my $a = 10.01; "$a";
d08ca67 [t/spec] Bring num.t up-to-date a bit, and fudge it for Rakudo.
colomon authored
64 isa_ok($a, Rat);
65 is($a, "10.01", '10.01 stringification works');
66 }
67
68 {
69 my $a = -1.0e0;
70 isa_ok($a, Num);
71 is($a, "-1", '-1 stringification works');
72 }
73
74 {
75 my $a = 0.1e0;
76 isa_ok($a, Num);
77 is($a, "0.1", '0.1 stringification works');
78 }
79
80 {
81 my $a = -0.1e0; "$a";
82 isa_ok($a, Num);
83 is($a, "-0.1", '-0.1 stringification works');
84 }
85
86 {
87 my $a = 10.01e0; "$a";
207f13f [t] and [t/spec]
moritz authored
88 isa_ok($a, Num);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
89 is($a, "10.01", '10.01 stringification works');
90 }
91
92 {
93 my $a = 1e3; "$a";
207f13f [t] and [t/spec]
moritz authored
94 ok $a ~~ Num, '1e3 conforms to Num';
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
95 is($a, "1000", '1e3 stringification works');
96 }
97
98 {
99 my $a = 10.01e3; "$a";
207f13f [t] and [t/spec]
moritz authored
100 isa_ok($a, Num);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
101 is($a, "10010", '10.01e3 stringification works');
102 }
103
05c3d8d @diakopter re-attempt to fix smartlinks in S02 to headings that contain C<>
diakopter authored
104 #L<S02/The C<Num> and C<Rat> Types/Perl 6 intrinsically supports big integers>
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
105
106 {
107 my $a = 0b100; "$a";
207f13f [t] and [t/spec]
moritz authored
108 isa_ok($a, Int);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
109 is($a, "4", '0b100 (binary) stringification works');
110 }
111
112 {
113 my $a = 0x100; "$a";
207f13f [t] and [t/spec]
moritz authored
114 isa_ok($a, Int);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
115 is($a, "256", '0x100 (hex) stringification works');
116 }
117
118 {
119 my $a = 0o100; "$a";
207f13f [t] and [t/spec]
moritz authored
120 isa_ok($a, Int);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
121 is($a, "64", '0o100 (octal) stringification works');
122 }
123
124 {
189b4db [t/spec] cosmetic cleaning: remove trailing space
wollmers authored
125 my $a = 1; "$a";
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
126 is($a + 1, 2, 'basic addition works');
127 }
128
129 {
130 my $a = -1; "$a";
131 ok($a + 1 == 0, 'basic addition with negative numbers works'); # parsing bug
132 }
05c3d8d @diakopter re-attempt to fix smartlinks in S02 to headings that contain C<>
diakopter authored
133 #L<S02/The C<Num> and C<Rat> Types/Rat supports extended precision rational arithmetic>
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
134
a4ba5fd [t/spec] correct meaning of infix:<div> and infix:</>. Patch courtesy…
moritz authored
135 isa_ok(1 / 1, Rat);
207f13f [t] and [t/spec]
moritz authored
136
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
137 {
138 my $a = 80000.0000000000000000000000000;
0b50b2c @pmichaud Fix a broken test in S02-builtin_data_types/num.t, defudge some passing
pmichaud authored
139 isa_ok($a, Rat);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
140 ok($a == 80000.0, 'trailing zeros compare correctly');
141 }
142
143 {
144 my $a = 1.0000000000000000000000000000000000000000000000000000000000000000000e1;
6e0e9d5 Stop some tests in S02 assuming that a floating point literal like 1.…
toyam authored
145 isa_ok($a, Num);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
146 ok($a == 10.0, 'trailing zeros compare correctly');
147 }
148
05c3d8d @diakopter re-attempt to fix smartlinks in S02 to headings that contain C<>
diakopter authored
149 #L<S02/The C<Num> and C<Rat> Types/Perl 6 intrinsically supports big integers>
616002e @coke pugs fudges
coke authored
150 #?pugs skip '.Int'
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
151 {
152 my $a = "1.01";
4401e31 @coke Fix type test fossil
coke authored
153 isa_ok($a.Int, Int);
e84b818 Kill off prefix:<int> (as per r25890)
moritz authored
154 is($a.Int, 1, "1.01 intifies to 1");
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
155 }
156
05c3d8d @diakopter re-attempt to fix smartlinks in S02 to headings that contain C<>
diakopter authored
157 #L<S02/The C<Num> and C<Rat> Types/may be bound to an arbitrary>
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
158 {
159 my $a = "0d0101";
616002e @coke pugs fudges
coke authored
160 #?pugs todo
0fd99d3 @moritz start to systematically test string numification
moritz authored
161 isa_ok(+$a, Int);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
162 is(+$a, 101, "0d0101 numifies to 101");
163 }
164
165 {
166 my $a = 2 ** 65; # over the 64 bit limit too
167 is($a, 36893488147419103232, "we have bignums, not weeny floats");
168 }
169
170 is(42_000, 42000, 'underscores allowed (and ignored) in numeric literals');
171 is(42_127_000, 42127000, 'multiple underscores ok');
172 is(42.0_1, 42.01, 'underscores in fraction ok');
173 is(4_2.01, 42.01, 'underscores in whole part ok');
174
b699884 [spec] fudged num.t
moritz authored
175 eval_dies_ok('4_2._0_1', 'single underscores are not ok directly after the dot');
176 is(4_2.0_1, 42.01, 'single underscores are ok');
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
177
178 is 0_1, 1, "0_1 is parsed as 0d1";
179 is +^1, -2, '+^1 == -2 as promised';
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
180
181 # vim: ft=perl6
Something went wrong with that request. Please try again.