Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 91 lines (79 sloc) 2.786 kb
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
1 use v6;
2 use Test;
3 plan 76;
4
5 # L<S32::Numeric/Complex/"=item gist">
6
7 #?DOES 4
8 sub Complex_str_test($value, $str_nucleus) {
246ed8d @coke pugs fudges
coke authored
9 #?pugs todo
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
10 is ~$value, $str_nucleus, "~<$str_nucleus>";
246ed8d @coke pugs fudges
coke authored
11 #?pugs skip 'coercion'
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
12 is $value.Str, $str_nucleus, "<$str_nucleus>.Str";
246ed8d @coke pugs fudges
coke authored
13 #?pugs skip '.gist'
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
14 is $value.gist, $str_nucleus, "<$str_nucleus>.gist";
9e48a8d @moritz fudge S32-num/stringify.t for rakudo
moritz authored
15 #?rakudo todo 'Complex.perl'
246ed8d @coke pugs fudges
coke authored
16 #?pugs todo
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
17 is $value.perl, "<$str_nucleus>", "<$str_nucleus>.perl";
18 }
19
20 # basic syntactic correctness - sign flags, lack of space
21 Complex_str_test (3 + 4i), '3+4i';
22 Complex_str_test (3 - 4i), '3-4i';
23 Complex_str_test (-3 + 4i), '-3+4i';
24 # use proper Num formatting - fractionalComplex_str_testm
25 Complex_str_test (3.5 + 4i), '3.5+4i';
26 Complex_str_test (3 + 4.5i), '3+4.5i';
27 # infinities
28 Complex_str_test (Inf + 3i), 'Inf+3i';
246ed8d @coke pugs fudges
coke authored
29 #?pugs skip 'parsefail'
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
30 Complex_str_test (0 + Inf\i), '0+Inf\i';
31 Complex_str_test (-Inf + 3i), '-Inf+3i';
246ed8d @coke pugs fudges
coke authored
32 #?pugs skip 'parsefail'
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
33 Complex_str_test (0 - Inf\i), '0-Inf\i';
34 Complex_str_test (NaN + 3i), 'NaN+3i';
246ed8d @coke pugs fudges
coke authored
35 #?pugs skip 'parsefail'
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
36 Complex_str_test (0 + NaN\i), '0+NaN\i';
37
38 # quick check that type objects stringify correctly - this has been a problem
39 # for Niecza in the past
40
246ed8d @coke pugs fudges
coke authored
41 #?pugs skip 'gist'
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
42 is Complex.gist, 'Complex()', 'Complex.gist';
246ed8d @coke pugs fudges
coke authored
43 #?pugs todo
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
44 is Complex.perl, 'Complex', 'Complex.perl';
45 # XXX Should ~Complex and Complex.Str return something specific? For now
46 # just make sure they don't die
47 lives_ok { ~Complex }, '~Complex does not die';
246ed8d @coke pugs fudges
coke authored
48 #?pugs skip 'coercion'
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
49 lives_ok { Complex.Str }, 'Complex.Str does not die';
50
51 # L<S32::Numeric/Rat/"=item gist">
52
53 # we check against $value.Num because Num stringification isn't precisely
54 # nailed down (and probably shouldn't be, to allow the use of platform
55 # converters)
56 #?DOES 4
57 sub Rat_str_test($value, $str_nucleus) {
246ed8d @coke pugs fudges
coke authored
58 #?pugs 2 skip 'coercion'
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
59 is ~$value, ~$value.Num, "~<$str_nucleus>";
60 is $value.Str, ~$value.Num, "<$str_nucleus>.Str";
246ed8d @coke pugs fudges
coke authored
61 #?pugs skip '.gist'
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
62 is $value.gist, ~$value.Num, "<$str_nucleus>.gist";
9e48a8d @moritz fudge S32-num/stringify.t for rakudo
moritz authored
63 #?rakudo todo 'Rat.perl'
246ed8d @coke pugs fudges
coke authored
64 #?pugs todo
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
65 is $value.perl, "<$str_nucleus>", "<$str_nucleus>.perl";
66 }
67
68 # basic format test
69 Rat_str_test 1/2, '1/2';
70 Rat_str_test -1/2, '-1/2';
71 Rat_str_test 0/2, '0/1';
72 # 1/1 is a Rat too!
73 Rat_str_test 1/1, '1/1';
74 # Return as-if normalized
eeb63aa @moritz fudge some Rat stringification tests for rakudo
moritz authored
75 #?rakudo skip 'formatting precision'
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
76 Rat_str_test 13/39, '1/3';
77 # Bignum sanity
eeb63aa @moritz fudge some Rat stringification tests for rakudo
moritz authored
78 #?rakudo skip 'formatting precision'
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
79 Rat_str_test (4.5 ** 60), '1797010299914431210413179829509605039731475627537851106401/1152921504606846976';
80
246ed8d @coke pugs fudges
coke authored
81 #?pugs skip '.gist'
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
82 is Rat.gist, 'Rat()', 'Rat.gist';
246ed8d @coke pugs fudges
coke authored
83 #?pugs todo
1596c94 @sorear Add tests for perl6/specs@02361b0
sorear authored
84 is Rat.perl, 'Rat', 'Rat.perl';
85 lives_ok { ~Rat }, '~Rat does not die';
86 lives_ok { Rat.Str }, 'Rat.Str does not die';
87
88 # TODO: FatRat, Num (once better specced), Int (maybe, but hard to mess up)
89
90 # vim: ft=perl6
Something went wrong with that request. Please try again.