Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 178 lines (144 sloc) 4.163 kb
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
1 use v6;
2
3 use Test;
4
05c3d8d Matthew Wilson 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 Solomon Foster 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 work ...
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' );
3548dd2 Solomon Foster Modernize tests a bit. Add new test. Unfudge for niecza.
colomon authored
15 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 work ...
colomon authored
16 is_approx( eval(1.1.perl), 1.1, 'eval 1.1.Num.perl is 1.1' );
3548dd2 Solomon Foster Modernize tests a bit. Add new test. Unfudge for niecza.
colomon authored
17 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 work ...
colomon authored
18 is_approx( eval((-1.1).perl), -1.1, 'eval -1.1.Num.perl is -1.1' );
3548dd2 Solomon Foster Modernize tests a bit. Add new test. Unfudge for niecza.
colomon authored
19 isa_ok( eval(1e100.Num.perl), Num, 'eval 1e100.Num.perl is Num' );
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 work ...
colomon authored
21
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
22 {
23 my $a = 1; "$a";
207f13f [t] and [t/spec]
moritz 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";
207f13f [t] and [t/spec]
moritz 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 Matthew Wilson 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 (m...
moritz authored
36 my $a = 1 / 1;
207f13f [t] and [t/spec]
moritz 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;
d08ca67 [t/spec] Bring num.t up-to-date a bit, and fudge it for Rakudo.
colomon 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;
d08ca67 [t/spec] Bring num.t up-to-date a bit, and fudge it for Rakudo.
colomon 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";
d08ca67 [t/spec] Bring num.t up-to-date a bit, and fudge it for Rakudo.
colomon 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";
d08ca67 [t/spec] Bring num.t up-to-date a bit, and fudge it for Rakudo.
colomon authored
61 isa_ok($a, Rat);
62 is($a, "10.01", '10.01 stringification works');
63 }
64
65 {
66 my $a = -1.0e0;
67 isa_ok($a, Num);
68 is($a, "-1", '-1 stringification works');
69 }
70
71 {
72 my $a = 0.1e0;
73 isa_ok($a, Num);
74 is($a, "0.1", '0.1 stringification works');
75 }
76
77 {
78 my $a = -0.1e0; "$a";
79 isa_ok($a, Num);
80 is($a, "-0.1", '-0.1 stringification works');
81 }
82
83 {
84 my $a = 10.01e0; "$a";
207f13f [t] and [t/spec]
moritz 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";
207f13f [t] and [t/spec]
moritz 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 Matthew Wilson 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";
207f13f [t] and [t/spec]
moritz 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";
207f13f [t] and [t/spec]
moritz 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";
207f13f [t] and [t/spec]
moritz 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 Matthew Wilson 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
a4ba5fd [t/spec] correct meaning of infix:<div> and infix:</>. Patch courtesy (m...
moritz 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;
0b50b2c Patrick R. Michaud Fix a broken test in S02-builtin_data_types/num.t, defudge some passing
pmichaud 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;
6e0e9d5 Stop some tests in S02 assuming that a floating point literal like 1.2 i...
toyam 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 Matthew Wilson 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";
4401e31 Will Coleda Fix type test fossil
coke 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 Matthew Wilson 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";
616002e Will Coleda pugs fudges
coke authored
156 #?pugs todo
0fd99d3 Moritz Lenz start to systematically test string numification
moritz authored
157 isa_ok(+$a, Int);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
158 is(+$a, 101, "0d0101 numifies to 101");
159 }
160
161 {
162 my $a = 2 ** 65; # over the 64 bit limit too
163 is($a, 36893488147419103232, "we have bignums, not weeny floats");
164 }
165
166 is(42_000, 42000, 'underscores allowed (and ignored) in numeric literals');
167 is(42_127_000, 42127000, 'multiple underscores ok');
168 is(42.0_1, 42.01, 'underscores in fraction ok');
169 is(4_2.01, 42.01, 'underscores in whole part ok');
170
b699884 [spec] fudged num.t
moritz authored
171 eval_dies_ok('4_2._0_1', 'single underscores are not ok directly after the dot');
172 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
173
174 is 0_1, 1, "0_1 is parsed as 0d1";
175 is +^1, -2, '+^1 == -2 as promised';
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
176
177 # vim: ft=perl6
Something went wrong with that request. Please try again.