Debian Codegraph @

t/number.t

raw symbols SCIP
1 #!perl
2
3 use Test::Morescip-perl cpan autobox-Core 1.33 Test/More/ tests => 49;
4 use autobox::Corescip-perl cpan autobox-Core 1.33 autobox/Core/;
5
6 #is( 12.34->ceil, 13);
7 #is( 12.34->round_up, 13);
8 #is( 12.34->floor, 12);
9 #is( 12.34->round_down, 12);
10 isscip-perl cpan autobox-Core 1.33 main/is().( 12.34->intscip-perl cpan autobox-Core 1.33 main/int()., 12);
11
12 #is( 2.5->round, 3 );
13 #is( 2->round, 2 );
14 #is( 0->round, 0 );
15 #is( 2.51->round, 3 );
16 #is( -3.51->round, -4 );
17
18 okscip-perl cpan autobox-Core 1.33 main/ok().( 12->is_numberscip-perl cpan autobox-Core 1.33 main/is_number(). );
19 okscip-perl cpan autobox-Core 1.33 main/ok().(!'FF'->is_numberscip-perl cpan autobox-Core 1.33 main/is_number(). );
20
21 okscip-perl cpan autobox-Core 1.33 main/ok().( 12->is_positivescip-perl cpan autobox-Core 1.33 main/is_positive(). );
22 okscip-perl cpan autobox-Core 1.33 main/ok().( "+12"->is_positivescip-perl cpan autobox-Core 1.33 main/is_positive(). );
23 okscip-perl cpan autobox-Core 1.33 main/ok().( 12.34->is_positivescip-perl cpan autobox-Core 1.33 main/is_positive(). );
24 okscip-perl cpan autobox-Core 1.33 main/ok().( !"foo"->is_positivescip-perl cpan autobox-Core 1.33 main/is_positive(). );
25 okscip-perl cpan autobox-Core 1.33 main/ok().( !"-12.2"->is_positivescip-perl cpan autobox-Core 1.33 main/is_positive(). );
26
27 okscip-perl cpan autobox-Core 1.33 main/ok().( !12->is_negativescip-perl cpan autobox-Core 1.33 main/is_negative(). );
28 okscip-perl cpan autobox-Core 1.33 main/ok().( "-12"->is_negativescip-perl cpan autobox-Core 1.33 main/is_negative(). );
29 okscip-perl cpan autobox-Core 1.33 main/ok().( (-12.34)->is_negativescip-perl cpan autobox-Core 1.33 main/is_negative(). );
30 okscip-perl cpan autobox-Core 1.33 main/ok().( !"foo"->is_negativescip-perl cpan autobox-Core 1.33 main/is_negative(). );
31 okscip-perl cpan autobox-Core 1.33 main/ok().( "-12.2"->is_negativescip-perl cpan autobox-Core 1.33 main/is_negative(). );
32
33 ok !0->is_negativescip-perl cpan autobox-Core 1.33 main/is_negative()., "zero is not negative";
34 ok !0->is_positivescip-perl cpan autobox-Core 1.33 main/is_positive()., "zero is not positive";
35
36 okscip-perl cpan autobox-Core 1.33 main/ok().( 12->is_integerscip-perl cpan autobox-Core 1.33 main/is_integer(). );
37 okscip-perl cpan autobox-Core 1.33 main/ok().( -12->is_integerscip-perl cpan autobox-Core 1.33 main/is_integer(). );
38 okscip-perl cpan autobox-Core 1.33 main/ok().( "+12"->is_integerscip-perl cpan autobox-Core 1.33 main/is_integer(). );
39 okscip-perl cpan autobox-Core 1.33 main/ok().(!12.34->is_integerscip-perl cpan autobox-Core 1.33 main/is_integer(). );
40
41 okscip-perl cpan autobox-Core 1.33 main/ok().( 12->is_intscip-perl cpan autobox-Core 1.33 main/is_int(). );
42 okscip-perl cpan autobox-Core 1.33 main/ok().(!12.34->is_intscip-perl cpan autobox-Core 1.33 main/is_int(). );
43
44 okscip-perl cpan autobox-Core 1.33 main/ok().( 12.34->is_decimalscip-perl cpan autobox-Core 1.33 main/is_decimal(). );
45 okscip-perl cpan autobox-Core 1.33 main/ok().( ".34"->is_decimalscip-perl cpan autobox-Core 1.33 main/is_decimal(). );
46 okscip-perl cpan autobox-Core 1.33 main/ok().( !12->is_decimalscip-perl cpan autobox-Core 1.33 main/is_decimal(). );
47 okscip-perl cpan autobox-Core 1.33 main/ok().(!'abc'->is_decimalscip-perl cpan autobox-Core 1.33 main/is_decimal(). );
48
49 isscip-perl cpan autobox-Core 1.33 main/is().( '123'->reversescip-perl cpan autobox-Core 1.33 main/reverse()., '321' );
50
51 TODO: {
52 local $TODOscip-perl cpan autobox-Core 1.33 main/$TODO. = q{ hex is weird };
53
54 isscip-perl cpan autobox-Core 1.33 main/is().( 255->hexscip-perl cpan autobox-Core 1.33 main/hex()., 'FF');
55 isscip-perl cpan autobox-Core 1.33 main/is().( 'FF'->decscip-perl cpan autobox-Core 1.33 main/dec()., 255);
56 isscip-perl cpan autobox-Core 1.33 main/is().( 0xFF->decscip-perl cpan autobox-Core 1.33 main/dec()., 255);
57
58 };
59
60 TODO: {
61 todo_skipscip-perl cpan autobox-Core 1.33 main/todo_skip(). "Make number methods work on non-scalar refs", 20;
62
63 for my $ref ([ 'foo' ], { bar => 1 }, \'baz', sub { 'gorch' }) {
64 for my $method (qw(is_decimal is_integer is_int is_negative is_positive)) {
65 okscip-perl cpan autobox-Core 1.33 main/ok().(!$ref->$methodscip-perl cpan autobox-Core 1.33 main/$method().);
66 }
67 }
68 }