Changeset 21191

Show
Ignore:
Timestamp:
07/03/08 21:49:53 (3 months ago)
Author:
Auzon
Message:

[gsoc_spectest] fudged arith.t for Rakudo

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • t/spec/S03-operators/arith.t

    r21190 r21191  
    1818#?DOES 1 
    1919sub tryeq ($lhs, $rhs) { 
    20     ok($lhs == $rhs); 
     20    ok($lhs == $rhs, "$lhs == $rhs"); 
    2121} 
    2222 
     
    3434        } 
    3535    } else { 
    36         my $error = abs($lhs - $rhs) / $lhs; 
     36        my $error = abs($lhs - $rhs); 
     37        $error   /= $lhs; # Syntax highlighting fix 
    3738        if ($todo) { 
    3839            #&ok.nextwith($error <1e-9,$todo ~ " # " ~ $lhs ~ " is close to " ~ $rhs, :todo); 
     
    6869 
    6970# UVs should behave properly 
    70  
    71 tryeq 4063328477 % 65535, 27407; 
    72 tryeq 4063328477 % 4063328476, 1; 
    73 tryeq 4063328477 % 2031664238, 1; 
     71#?rakudo 3 skip 'modulo bugs' 
     72{ 
     73    tryeq 4063328477 % 65535, 27407; 
     74    tryeq 4063328477 % 4063328476, 1; 
     75    tryeq 4063328477 % 2031664238, 1; 
     76} 
    7477tryeq 2031664238 % 4063328477, 2031664238; 
    7578 
     
    7881tryeq 2147483647 + 0, 2147483647; 
    7982 
    80 # IV + IV promote to UV 
    81 tryeq 2147483647 + 1, 2147483648; 
    82 tryeq 2147483640 + 10, 2147483650; 
    83 tryeq 2147483647 + 2147483647, 4294967294; 
    84 # IV + UV promote to NV 
    85 tryeq 2147483647 + 2147483649, 4294967296; 
    86 # UV + IV promote to NV 
    87 tryeq 4294967294 + 2, 4294967296; 
    88 # UV + UV promote to NV 
    89 tryeq 4294967295 + 4294967295, 8589934590; 
     83#?rakudo skip 'addition bugs' 
     84{ 
     85    # IV + IV promote to UV 
     86    tryeq 2147483647 + 1, 2147483648; 
     87    tryeq 2147483640 + 10, 2147483650; 
     88    tryeq 2147483647 + 2147483647, 4294967294; 
     89    # IV + UV promote to NV 
     90    tryeq 2147483647 + 2147483649, 4294967296; 
     91    # UV + IV promote to NV 
     92    tryeq 4294967294 + 2, 4294967296; 
     93    # UV + UV promote to NV 
     94    tryeq 4294967295 + 4294967295, 8589934590; 
    9095 
    9196# UV + IV to IV 
     
    98103tryeq -2147483648 + -2147483648, -4294967296; 
    99104tryeq -2147483640 + -10, -2147483650; 
     105} 
    100106 
    101107# Hmm. Don t forget the simple stuff 
     
    126132 
    127133tryeq 0 - -2147483647, 2147483647; 
    128 tryeq -1 - -2147483648, 2147483647; 
    129 tryeq 2 - -2147483648, 2147483650; 
    130  
    131 tryeq 4294967294 - 3, 4294967291; 
    132 tryeq -2147483648 - -1, -2147483647; 
    133  
    134 # IV - IV promote to UV 
    135 tryeq 2147483647 - -1, 2147483648; 
    136 tryeq 2147483647 - -2147483648, 4294967295; 
    137 # UV - IV promote to NV 
    138 tryeq 4294967294 - -3, 4294967297; 
    139 # IV - IV promote to NV 
    140 tryeq -2147483648 - +1, -2147483649; 
    141 # UV - UV promote to IV 
    142 tryeq 2147483648 - 2147483650, -2; 
     134 
     135#?rakudo skip 'subtraction bugs' 
     136{ 
     137    tryeq -1 - -2147483648, 2147483647; 
     138    tryeq 2 - -2147483648, 2147483650; 
     139 
     140    tryeq 4294967294 - 3, 4294967291; 
     141    tryeq -2147483648 - -1, -2147483647; 
     142 
     143    # IV - IV promote to UV 
     144    tryeq 2147483647 - -1, 2147483648; 
     145    tryeq 2147483647 - -2147483648, 4294967295; 
     146    # UV - IV promote to NV 
     147    tryeq 4294967294 - -3, 4294967297; 
     148    # IV - IV promote to NV 
     149    tryeq -2147483648 - +1, -2147483649; 
     150    # UV - UV promote to IV 
     151    tryeq 2147483648 - 2147483650, -2; 
     152} 
    143153# IV - UV promote to IV 
    144154tryeq 2000000000 - 4000000000, -2000000000; 
     
    203213    tryeq -65535 * 65535, -4294836225; 
    204214    tryeq -65535 * -65535, 4294836225; 
    205 } 
    206  
    207 # check with 0xFFFF and 0x10001 
    208 tryeq 65535 * 65537, 4294967295; 
    209 tryeq 65535 * -65537, -4294967295; 
    210 tryeq -65535 * 65537, -4294967295; 
    211 tryeq -65535 * -65537, 4294967295; 
    212  
    213 # check with 0x10001 and 0xFFFF 
    214 tryeq 65537 * 65535, 4294967295; 
    215 tryeq 65537 * -65535, -4294967295; 
    216 tryeq -65537 * 65535, -4294967295; 
    217 tryeq -65537 * -65535, 4294967295; 
    218  
    219 # These should all be dones as NVs 
    220 tryeq 65537 * 65537, 4295098369; 
    221 tryeq 65537 * -65537, -4295098369; 
    222 tryeq -65537 * 65537, -4295098369; 
    223 tryeq -65537 * -65537, 4295098369; 
    224  
    225 # will overflow an IV (in 32-bit) 
    226 tryeq 46340 * 46342, 0x80001218; 
    227 tryeq 46340 * -46342, -0x80001218; 
    228 tryeq -46340 * 46342, -0x80001218; 
    229 tryeq -46340 * -46342, 0x80001218; 
    230  
    231 tryeq 46342 * 46340, 0x80001218; 
    232 tryeq 46342 * -46340, -0x80001218; 
    233 tryeq -46342 * 46340, -0x80001218; 
    234 tryeq -46342 * -46340, 0x80001218; 
    235  
    236 # will overflow a positive IV (in 32-bit) 
    237 tryeq 65536 * 32768, 0x80000000; 
    238 tryeq 65536 * -32768, -0x80000000; 
    239 tryeq -65536 * 32768, -0x80000000; 
    240 tryeq -65536 * -32768, 0x80000000; 
    241  
    242 tryeq 32768 * 65536, 0x80000000; 
    243 tryeq 32768 * -65536, -0x80000000; 
    244 tryeq -32768 * 65536, -0x80000000; 
    245 tryeq -32768 * -65536, 0x80000000; 
    246  
    247 # 2147483647 is prime. bah. 
    248  
    249 tryeq 46339 * 46341, 0x7ffea80f; 
    250 tryeq 46339 * -46341, -0x7ffea80f; 
    251 tryeq -46339 * 46341, -0x7ffea80f; 
    252 tryeq -46339 * -46341, 0x7ffea80f; 
     215 
     216    # check with 0xFFFF and 0x10001 
     217    tryeq 65535 * 65537, 4294967295; 
     218    tryeq 65535 * -65537, -4294967295; 
     219    tryeq -65535 * 65537, -4294967295; 
     220    tryeq -65535 * -65537, 4294967295; 
     221     
     222    # check with 0x10001 and 0xFFFF 
     223    tryeq 65537 * 65535, 4294967295; 
     224    tryeq 65537 * -65535, -4294967295; 
     225    tryeq -65537 * 65535, -4294967295; 
     226    tryeq -65537 * -65535, 4294967295; 
     227     
     228    # These should all be dones as NVs 
     229    tryeq 65537 * 65537, 4295098369; 
     230    tryeq 65537 * -65537, -4295098369; 
     231    tryeq -65537 * 65537, -4295098369; 
     232    tryeq -65537 * -65537, 4295098369; 
     233     
     234    # will overflow an IV (in 32-bit) 
     235    tryeq 46340 * 46342, 0x80001218; 
     236    tryeq 46340 * -46342, -0x80001218; 
     237    tryeq -46340 * 46342, -0x80001218; 
     238    tryeq -46340 * -46342, 0x80001218; 
     239     
     240    tryeq 46342 * 46340, 0x80001218; 
     241    tryeq 46342 * -46340, -0x80001218; 
     242    tryeq -46342 * 46340, -0x80001218; 
     243    tryeq -46342 * -46340, 0x80001218; 
     244     
     245    # will overflow a positive IV (in 32-bit) 
     246    tryeq 65536 * 32768, 0x80000000; 
     247    tryeq 65536 * -32768, -0x80000000; 
     248    tryeq -65536 * 32768, -0x80000000; 
     249    tryeq -65536 * -32768, 0x80000000; 
     250     
     251    tryeq 32768 * 65536, 0x80000000; 
     252    tryeq 32768 * -65536, -0x80000000; 
     253    tryeq -32768 * 65536, -0x80000000; 
     254    tryeq -32768 * -65536, 0x80000000; 
     255     
     256    # 2147483647 is prime. bah. 
     257     
     258    tryeq 46339 * 46341, 0x7ffea80f; 
     259    tryeq 46339 * -46341, -0x7ffea80f; 
     260    tryeq -46339 * 46341, -0x7ffea80f; 
     261    tryeq -46339 * -46341, 0x7ffea80f; 
     262} 
    253263 
    254264# leading space should be ignored 
     
    282292# [I suspect this is parsing string-to-float problems, not actual arith] 
    283293tryeq_sloppy 18446744073709551616/1, 18446744073709551616; # Bluuurg 
    284 tryeq_sloppy 18446744073709551616/2, 9223372036854775808; 
    285 tryeq_sloppy 18446744073709551616/4294967296, 4294967296; 
    286 tryeq_sloppy 18446744073709551616/9223372036854775808, 2; 
    287  
    288 { 
    289   # The peephole optimiser is wrong to think that it can substitute intops 
    290   # in place of regular ops, because i_multiply can overflow. 
    291   # (Perl 5) Bug reported by "Sisyphus" (kalinabears@hdc.com.au) 
    292   my $n = 1127; 
    293   my $float = ($n % 1000) * 167772160.0; 
    294   tryeq_sloppy $float, 21307064320; 
    295  
    296   # On a 32 bit machine, if the i_multiply op is used, you will probably get 
    297   # -167772160. It's actually undefined behaviour, so anything may happen. 
    298   my $int = ($n % 1000) * 167772160; 
    299   tryeq $int, 21307064320; 
    300  
    301 } 
     294 
     295#?rakudo skip 'division accuracy issues' 
     296{ 
     297    tryeq_sloppy 18446744073709551616/2, 9223372036854775808; 
     298    tryeq_sloppy 18446744073709551616/4294967296, 4294967296; 
     299    tryeq_sloppy 18446744073709551616/9223372036854775808, 2; 
     300} 
     301 
     302#?rakudo skip 'multiplication accuracy bugs' 
     303{ 
     304    # The peephole optimiser is wrong to think that it can substitute intops 
     305    # in place of regular ops, because i_multiply can overflow. 
     306    # (Perl 5) Bug reported by "Sisyphus" (kalinabears@hdc.com.au) 
     307    my $n = 1127; 
     308    my $float = ($n % 1000) * 167772160.0; 
     309    tryeq_sloppy $float, 21307064320; 
     310   
     311    # On a 32 bit machine, if the i_multiply op is used, you will probably get 
     312    # -167772160. It's actually undefined behaviour, so anything may happen. 
     313    my $int = ($n % 1000) * 167772160; 
     314    tryeq $int, 21307064320; 
     315 
     316} 
     317 
    302318 
    303319# exponentiation 
     
    316332#?rakudo skip 'undef.abs' 
    317333is -Inf.abs, Inf; 
    318 #?rakudo 4 todo 'Inf' 
     334#?rakudo 4 skip 'Inf' 
    319335is Inf+100, Inf; 
    320336is Inf-100, Inf; 
     
    396412my $x; 
    397413 
    398 #?rakudo 3 todo 'modulo by zero' 
     414#?rakudo 3 skip 'modulo by zero' 
    399415dies_ok( { say 3 % 0 }, 'Modulo zero dies and is catchable'); 
    400416dies_ok( { $x = 0; say 3 % $x; }, 'Modulo zero dies and is catchable with VInt/VRat variables');