Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 185 lines (149 sloc) 4.326 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
2cc1341 @hoelzro Bump test count in num.t
hoelzro authored
7 plan 66;
f646c2d [t/spec] Test Num.perl. Who'd have thought that 1.0.perl wouldn't wo…
colomon authored
8
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
9 isa-ok( EVAL(1.Num.perl), Num, 'EVAL 1.Num.perl is Num' );
7cac63f @FROGGS eval => EVAL in S02, take 2
FROGGS authored
10 is_approx( EVAL(1.Num.perl), 1, 'EVAL 1.Num.perl is 1' );
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
11 isa-ok( EVAL(0.Num.perl), Num, 'EVAL 0.Num.perl is Num' );
7cac63f @FROGGS eval => EVAL in S02, take 2
FROGGS authored
12 is_approx( EVAL(0.Num.perl), 0, 'EVAL 0.Num.perl is 0' );
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
13 isa-ok( EVAL((-1).Num.perl), Num, 'EVAL -1.Num.perl is Num' );
7cac63f @FROGGS eval => EVAL in S02, take 2
FROGGS authored
14 is_approx( EVAL((-1).Num.perl), -1, 'EVAL -1.Num.perl is -1' );
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
15 isa-ok( EVAL(1.1.Num.perl), Num, 'EVAL 1.1.Num.perl is Num' );
7cac63f @FROGGS eval => EVAL in S02, take 2
FROGGS authored
16 is_approx( EVAL(1.1.perl), 1.1, 'EVAL 1.1.Num.perl is 1.1' );
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
17 isa-ok( EVAL((-1.1).Num.perl), Num, 'EVAL -1.1.Num.perl is Num' );
7cac63f @FROGGS eval => EVAL in S02, take 2
FROGGS authored
18 is_approx( EVAL((-1.1).perl), -1.1, 'EVAL -1.1.Num.perl is -1.1' );
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
19 isa-ok( EVAL(1e100.Num.perl), Num, 'EVAL 1e100.Num.perl is Num' );
7cac63f @FROGGS eval => EVAL in S02, take 2
FROGGS authored
20 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
21
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
22 {
23 my $a = 1; "$a";
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
24 isa-ok($a, Int);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
25 is($a, "1", '1 stringification works');
26 }
27
28 {
29 my $a = -1; "$a";
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
30 isa-ok($a, Int);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
31 is($a, "-1", '-1 stringification works');
32 }
33
05c3d8d @diakopter re-attempt to fix smartlinks in S02 to headings that contain C<>
diakopter authored
34 #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
35 {
a4ba5fd [t/spec] correct meaning of infix:<div> and infix:</>. Patch courtesy…
moritz authored
36 my $a = 1 / 1;
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
37 isa-ok($a, Rat);
685fe36 [t/spec] fix Rat stringification in num.t
moritz authored
38 is(~$a, "1", '1/1 stringification works');
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
39 }
40
41 {
207f13f [t] and [t/spec]
moritz authored
42 my $a = -1.0;
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
43 isa-ok($a, Rat);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
44 is($a, "-1", '-1 stringification works');
45 }
46
47 {
207f13f [t] and [t/spec]
moritz authored
48 my $a = 0.1;
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
49 isa-ok($a, Rat);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
50 is($a, "0.1", '0.1 stringification works');
51 }
52
53 {
54 my $a = -0.1; "$a";
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
55 isa-ok($a, Rat);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
56 is($a, "-0.1", '-0.1 stringification works');
57 }
58
59 {
60 my $a = 10.01; "$a";
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
61 isa-ok($a, Rat);
d08ca67 [t/spec] Bring num.t up-to-date a bit, and fudge it for Rakudo.
colomon authored
62 is($a, "10.01", '10.01 stringification works');
63 }
64
65 {
66 my $a = -1.0e0;
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
67 isa-ok($a, Num);
d08ca67 [t/spec] Bring num.t up-to-date a bit, and fudge it for Rakudo.
colomon authored
68 is($a, "-1", '-1 stringification works');
69 }
70
71 {
72 my $a = 0.1e0;
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
73 isa-ok($a, Num);
d08ca67 [t/spec] Bring num.t up-to-date a bit, and fudge it for Rakudo.
colomon authored
74 is($a, "0.1", '0.1 stringification works');
75 }
76
77 {
78 my $a = -0.1e0; "$a";
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
79 isa-ok($a, Num);
d08ca67 [t/spec] Bring num.t up-to-date a bit, and fudge it for Rakudo.
colomon authored
80 is($a, "-0.1", '-0.1 stringification works');
81 }
82
83 {
84 my $a = 10.01e0; "$a";
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
85 isa-ok($a, Num);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
86 is($a, "10.01", '10.01 stringification works');
87 }
88
89 {
90 my $a = 1e3; "$a";
207f13f [t] and [t/spec]
moritz authored
91 ok $a ~~ Num, '1e3 conforms to Num';
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
92 is($a, "1000", '1e3 stringification works');
93 }
94
95 {
96 my $a = 10.01e3; "$a";
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
97 isa-ok($a, Num);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
98 is($a, "10010", '10.01e3 stringification works');
99 }
100
05c3d8d @diakopter re-attempt to fix smartlinks in S02 to headings that contain C<>
diakopter authored
101 #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
102
103 {
104 my $a = 0b100; "$a";
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
105 isa-ok($a, Int);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
106 is($a, "4", '0b100 (binary) stringification works');
107 }
108
109 {
110 my $a = 0x100; "$a";
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
111 isa-ok($a, Int);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
112 is($a, "256", '0x100 (hex) stringification works');
113 }
114
115 {
116 my $a = 0o100; "$a";
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
117 isa-ok($a, Int);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
118 is($a, "64", '0o100 (octal) stringification works');
119 }
120
121 {
189b4db [t/spec] cosmetic cleaning: remove trailing space
wollmers authored
122 my $a = 1; "$a";
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
123 is($a + 1, 2, 'basic addition works');
124 }
125
126 {
127 my $a = -1; "$a";
128 ok($a + 1 == 0, 'basic addition with negative numbers works'); # parsing bug
129 }
05c3d8d @diakopter re-attempt to fix smartlinks in S02 to headings that contain C<>
diakopter authored
130 #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
131
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
132 isa-ok(1 / 1, Rat);
207f13f [t] and [t/spec]
moritz authored
133
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
134 {
135 my $a = 80000.0000000000000000000000000;
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
136 isa-ok($a, Rat);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
137 ok($a == 80000.0, 'trailing zeros compare correctly');
138 }
139
140 {
141 my $a = 1.0000000000000000000000000000000000000000000000000000000000000000000e1;
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
142 isa-ok($a, Num);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
143 ok($a == 10.0, 'trailing zeros compare correctly');
144 }
145
05c3d8d @diakopter re-attempt to fix smartlinks in S02 to headings that contain C<>
diakopter authored
146 #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
147 {
148 my $a = "1.01";
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
149 isa-ok($a.Int, Int);
e84b818 Kill off prefix:<int> (as per r25890)
moritz authored
150 is($a.Int, 1, "1.01 intifies to 1");
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
151 }
152
05c3d8d @diakopter re-attempt to fix smartlinks in S02 to headings that contain C<>
diakopter authored
153 #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
154 {
155 my $a = "0d0101";
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
156 isa-ok(+$a, Int);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
157 is(+$a, 101, "0d0101 numifies to 101");
158 }
159
160 {
161 my $a = 2 ** 65; # over the 64 bit limit too
162 is($a, 36893488147419103232, "we have bignums, not weeny floats");
163 }
164
165 is(42_000, 42000, 'underscores allowed (and ignored) in numeric literals');
166 is(42_127_000, 42127000, 'multiple underscores ok');
167 is(42.0_1, 42.01, 'underscores in fraction ok');
168 is(4_2.01, 42.01, 'underscores in whole part ok');
169
08b5de5 @lizmat s/throws_like/throws-like/g
lizmat authored
170 throws-like { EVAL '4_2._0_1' },
8120b6b @lizmat Last batch of dies_ok -> throws_like cleanup
lizmat authored
171 X::Method::NotFound,
172 'single underscores are not ok directly after the dot';
b699884 [spec] fudged num.t
moritz authored
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
0954436 @moritz RT #73238: 0xFFFFFFFFFFFFFFFF overflowed to -1
moritz authored
178 # RT #73238
179 ok 0xFFFFFFFFFFFFFFFF > 1, '0xFFFFFFFFFFFFFFFF is not -1';
180
f59d8d8 @hoelzro Add regression test for RT 122593
hoelzro authored
181 # RT #122593
182 ok Num === Num, 'Num === Num should be truthy, and not die';
183
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
184 # vim: ft=perl6
Something went wrong with that request. Please try again.