Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 89 lines (71 sloc) 2.506 kb
58135b3 [t/spec] changed 'use v6-alpha;' to 'use v6;'
moritz authored
1 use v6;
ad1b86b [t] Test suite refactoring.
cosimo authored
2 use Test;
76f901d Tests for rounding NaN and Inf
leto authored
3 plan 50;
ad1b86b [t] Test suite refactoring.
cosimo authored
4
b8d99dd [t/spec] fix more smartlinks
moritz authored
5 # L<S32::Numeric/Real/"=item round">
6 # L<S32::Numeric/Real/"=item floor">
7 # L<S32::Numeric/Real/"=item truncate">
8 # L<S32::Numeric/Real/"=item ceiling">
ad1b86b [t] Test suite refactoring.
cosimo authored
9
626a59c [rakudo] add directives to S29-num/ and convert pod to pod6
particle authored
10 =begin pod
ad1b86b [t] Test suite refactoring.
cosimo authored
11
76f901d Tests for rounding NaN and Inf
leto authored
12 Basic tests for the round(), floor(), truncate() and ceiling() built-ins
ad1b86b [t] Test suite refactoring.
cosimo authored
13
626a59c [rakudo] add directives to S29-num/ and convert pod to pod6
particle authored
14 =end pod
ad1b86b [t] Test suite refactoring.
cosimo authored
15
76f901d Tests for rounding NaN and Inf
leto authored
16 #?rakudo 4 skip 'Rounding NaN should give NaN'
17
18 is( floor(NaN), NaN, 'floor(NaN) is NaN');
19 is( round(NaN), NaN, 'round(NaN) is NaN');
20 is( ceiling(NaN), NaN, 'ceiling(NaN) is NaN');
21 is( truncate(NaN), NaN, 'truncate(NaN) is NaN');
22
23 #?rakudo 4 skip 'Rounding Inf should give Inf'
24
25 is( floor(Inf), Inf, 'floor(Inf) is Inf');
26 is( round(Inf), Inf, 'round(Inf) is Inf');
27 is( ceiling(Inf), Inf, 'ceiling(Inf) is Inf');
28 is( truncate(Inf), Inf, 'truncate(Inf) is Inf');
29
ad1b86b [t] Test suite refactoring.
cosimo authored
30 my %tests =
31 ( ceiling => [ [ 1.5, 2 ], [ 2, 2 ], [ 1.4999, 2 ],
32 [ -0.1, 0 ], [ -1, -1 ], [ -5.9, -5 ],
33 [ -0.5, 0 ], [ -0.499, 0 ], [ -5.499, -5 ] ],
34 floor => [ [ 1.5, 1 ], [ 2, 2 ], [ 1.4999, 1 ],
35 [ -0.1, -1 ], [ -1, -1 ], [ -5.9, -6 ],
36 [ -0.5, -1 ], [ -0.499, -1 ], [ -5.499, -6 ] ],
37 round => [ [ 1.5, 2 ], [ 2, 2 ], [ 1.4999, 1 ],
38 [ -0.1, 0 ], [ -1, -1 ], [ -5.9, -6 ],
ee7b7eb [t/spec] corrected rounders.t; fudged for rakudo (ugly mess)
moritz authored
39 [ -0.5, 0 ], [ -0.499, 0 ], [ -5.499, -5 ] ],
ad1b86b [t] Test suite refactoring.
cosimo authored
40 truncate => [ [ 1.5, 1 ], [ 2, 2 ], [ 1.4999, 1 ],
41 [ -0.1, 0 ], [ -1, -1 ], [ -5.9, -5 ],
42 [ -0.5, 0 ], [ -0.499, 0 ], [ -5.499, -5 ] ],
43 );
44
626a59c [rakudo] add directives to S29-num/ and convert pod to pod6
particle authored
45 #?pugs emit if $?PUGS_BACKEND ne "BACKEND_PUGS" {
46 #?pugs emit skip_rest "PIL2JS and PIL-Run do not support eval() yet.";
47 #?pugs emit exit;
48 #?pugs emit }
ad1b86b [t] Test suite refactoring.
cosimo authored
49
50 for %tests.keys.sort -> $type {
51 my @subtests = @(%tests{$type}); # XXX .[] doesn't work yet!
52 for @subtests -> $test {
62910e6 [t/spec] clean up of S29-num/rounders.t
moritz authored
53 my $code = "{$type}({$test[0]})";
ee7b7eb [t/spec] corrected rounders.t; fudged for rakudo (ugly mess)
moritz authored
54 my $res = eval($code);
55
ad1b86b [t] Test suite refactoring.
cosimo authored
56 if ($!) {
57 #?pugs todo 'feature'
58 flunk("failed to parse $code ($!)");
59 } else {
62910e6 [t/spec] clean up of S29-num/rounders.t
moritz authored
60 ok($res == $test[1], "$code == {$test[1]}");
ad1b86b [t] Test suite refactoring.
cosimo authored
61 }
62 }
63 }
64
576906b [t] added named arg tests to trig and num functions
frew authored
65 #?rakudo skip 'named args'
66 {
67 for %tests.keys.sort -> $type {
68 my @subtests = @(%tests{$type}); # XXX .[] doesn't work yet!
69 for @subtests -> $test {
70 my $code = "{$type}(:x({$test[0]}))";
71 my $res = eval($code);
72
73 if ($!) {
74 #?pugs todo 'feature'
75 flunk("failed to parse $code ($!)");
76 } else {
77 ok($res == $test[1], "$code == {$test[1]}");
78 }
79 }
80 }
81 }
82
6e20293 [t/spec] check that the rounder functions return Int values (RT #61526)
moritz authored
83 for %tests.keys.sort -> $t {
84 isa_ok eval("{$t}(1.1)"), Int, "rounder $t returns an int";
85
86 }
87
88 # vim: ft=perl6
Something went wrong with that request. Please try again.