Skip to content

HTTPS clone URL

Subversion checkout URL

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