Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

58 lines (46 sloc) 2.054 kb
use v6;
use Test;
plan 35;
# L<S32::Numeric/Real/"=item sign">
=begin pod
Basic tests for the sign() builtin
=end pod
is(0.sign, 0, 'got the right sign for 0');
is(-100.sign, -1, 'got the right sign for -100');
is(100.sign, 1, 'got the right sign for 100');
is((3/2).sign, 1, 'got the right sign for 3/2');
is((-3/2).sign, -1, 'got the right sign for -3/2');
is(1.5e0.sign, 1, 'got the right sign for 1.5e1');
is(-1.5e0.sign, -1, 'got the right sign for -1.5e1');
isa-ok(0.sign, Int, 'got the right type for 0');
isa-ok(-100.sign, Int, 'got the right type for -100');
isa-ok(100.sign, Int, 'got the right type for 100');
isa-ok((3/2).sign, Int, 'got the right type for 3/2');
isa-ok((-3/2).sign, Int, 'got the right type for -3/2');
isa-ok(1.5e0.sign, Int, 'got the right type for 1.5e1');
isa-ok(-1.5e0.sign, Int, 'got the right type for -1.5e1');
is(sign(0), 0, 'got the right sign for 0');
is(sign(-100), -1, 'got the right sign for -100');
is(sign(100), 1, 'got the right sign for 100');
is(sign(1.5), 1, 'got the right sign for 1.5');
is(sign(-1.5), -1, 'got the right sign for -1.5');
is(sign(1.5e1), 1, 'got the right sign for 1.5e1');
is(sign(-1.5e1), -1, 'got the right sign for -1.5e1');
isa-ok(sign(0), Int, 'got the right type for 0');
isa-ok(sign(-100), Int, 'got the right type for -100');
isa-ok(sign(100), Int, 'got the right type for 100');
isa-ok(sign(1.5), Int, 'got the right type for 1.5');
isa-ok(sign(-1.5), Int, 'got the right type for -1.5');
isa-ok(sign(1.5e1), Int, 'got the right type for 1.5e1');
isa-ok(sign(-1.5e1), Int, 'got the right type for -1.5e1');
is(sign(Inf), 1, 'got correct sign for +Inf');
is(sign(-Inf), -1, 'got correct sign for -Inf');
isa-ok(sign(Inf), Int, 'got correct type for +Inf');
isa-ok(sign(-Inf), Int, 'got correct type for -Inf');
#?rakudo todo "Nom does not yet have a NaN framework in place RT #124813"
#?niecza todo
is(sign(NaN),NaN, 'sign of NaN is NaN');
#?niecza todo
nok sign(Int).defined, 'sign(Int) is undefined';
throws-like { sign(3+4i) }, X::Numeric::Real;
# vim: ft=perl6
Jump to Line
Something went wrong with that request. Please try again.