1#!./perl 2 3# These Config-dependent tests were originally in t/opbasic/arith.t, 4# but moved here because t/opbasic/* should not depend on sophisticated 5# constructs like "use Config;". 6 7BEGIN { 8 chdir 't' if -d 't'; 9 require './test.pl'; 10 set_up_inc('../lib'); 11} 12 13use Config; 14use strict; 15 16plan tests => 9; 17 18my $vms_no_ieee; 19if ($^O eq 'VMS') { 20 $vms_no_ieee = 1 unless defined($Config{useieee}); 21} 22 23SKIP: 24{ 25 if ($^O eq 'vos') { 26 skip "VOS raises SIGFPE instead of producing infinity", 1; 27 } 28 elsif ($vms_no_ieee || !$Config{d_double_has_inf}) { 29 skip "the IEEE infinity model is unavailable in this configuration", 1; 30 } 31 # The computation of $v should overflow and produce "infinity" 32 # on any system whose max exponent is less than 10**1506. 33 # The exact string used to represent infinity varies by OS, 34 # so we don't test for it; all we care is that we don't die. 35 # 36 # Perl considers it to be an error if SIGFPE is raised. 37 # Chances are the interpreter will die, since it doesn't set 38 # up a handler for SIGFPE. That's why this test is last; to 39 # minimize the number of test failures. --PG 40 41 my $n = 5000; 42 my $v = 2; 43 while (--$n) { 44 $v *= 2; 45 } 46 pass("infinity"); 47} 48 49 50# [perl #120426] 51# small numbers shouldn't round to zero if they have extra floating digits 52 53SKIP: 54{ 55 skip "not IEEE", 8 unless $Config{d_double_style_ieee}; 56 ok 0.153e-305 != 0.0, '0.153e-305'; 57 ok 0.1530e-305 != 0.0, '0.1530e-305'; 58 ok 0.15300e-305 != 0.0, '0.15300e-305'; 59 ok 0.153000e-305 != 0.0, '0.153000e-305'; 60 ok 0.1530000e-305 != 0.0, '0.1530000e-305'; 61 ok 0.1530001e-305 != 0.0, '0.1530001e-305'; 62 ok 1.17549435100e-38 != 0.0, 'min single'; 63 # For flush-to-zero systems this may flush-to-zero, see PERL_SYS_FPU_INIT 64 ok 2.2250738585072014e-308 != 0.0, 'min double'; 65} 66