Ticket #1310: library_md5_t.patch

File library_md5_t.patch, 13.0 KB (added by bubaflub, 12 years ago)

patch for t/library/md5.t

  • t/library/md5.t

    diff --git t/library/md5.t t/library/md5.t
    index e747da2..70ceaf9 100644
     
    1 #!perl 
     1#!parrot 
    22# Copyright (C) 2001-2005, Parrot Foundation. 
    33# $Id$ 
    44 
    5 use strict; 
    6 use warnings; 
    7 use lib qw( t . lib ../lib ../../lib ); 
    8 use Test::More; 
    9 use Parrot::Test tests => 6; 
    10  
    115=head1 NAME 
    126 
    137t/library/md5.t - test MD5 library 
     
    3226############################## 
    3327# Stress parrot using MD5 library 
    3428 
    35 pir_output_is( <<'CODE', <<'OUT', "Miscellaneous words" ); 
    36 .sub _main 
     29.sub main :main 
     30    .include 'test_more.pir' 
     31    plan(517) 
     32 
     33    test_miscellaneous_words() 
     34    test_funny_chars() 
     35    test_string_lengths() 
     36    test_really_long_string() 
     37    test_recursive_md5_1() 
     38    test_recursive_md5_2() 
     39.end 
     40 
     41.sub test_miscellaneous_words 
    3742    load_bytecode "Digest/MD5.pbc" 
    3843    $P0 = _md5sum ("Hello") 
    39     _md5_print ($P0) 
    40     print "\n" 
     44    $S0 = _md5_hex($P0) 
     45    is($S0, '8b1a9953c4611296a827abf8c47804d7', 'md5 Hello') 
    4146 
    4247    $P0 = _md5sum ("Goodbye") 
    43     _md5_print ($P0) 
    44     print "\n" 
     48    $S0 = _md5_hex($P0) 
     49    is($S0, '6fc422233a40a75a1f028e11c3cd1140', 'md5 Goodbye') 
    4550 
    4651    $P0 = _md5sum ("Parrot") 
    47     _md5_print ($P0) 
    48     print "\n" 
     52    $S0 = _md5_hex($P0) 
     53    is($S0, 'e7cb1e977e896954fec46d2ea7832072', 'md5 Parrot') 
    4954 
    5055    $P0 = _md5sum ("Hello World!") 
    51     _md5_print ($P0) 
    52     print "\n" 
     56    $S0 = _md5_hex($P0) 
     57    is($S0, 'ed076287532e86365e841e92bfc50d8c', 'md5 Hello World') 
    5358 
    54     end 
    5559.end 
    56 CODE 
    57 8b1a9953c4611296a827abf8c47804d7 
    58 6fc422233a40a75a1f028e11c3cd1140 
    59 e7cb1e977e896954fec46d2ea7832072 
    60 ed076287532e86365e841e92bfc50d8c 
    61 OUT 
    6260 
    63 pir_output_is( <<'CODE', <<'OUT', "Funny chars" ); 
    64 .sub _main 
     61.sub test_funny_chars 
    6562    load_bytecode "Digest/MD5.pbc" 
    6663    $P0 = _md5sum ("\n\n\n\n\t") 
    67     _md5_print ($P0) 
    68     print "\n" 
    69     end 
     64    $S0 = _md5_hex($P0) 
     65    is($S0, 'b66434493525523b4393ce0d1f2425d7', 'funny chars') 
    7066.end 
    71 CODE 
    72 b66434493525523b4393ce0d1f2425d7 
    73 OUT 
    74  
    75 my $code = join( 
    76     "\n\n", 
    77     map { 
    78         <<CODE 
    79              \$P0 = _md5sum ("$_") 
    80              _md5_print (\$P0) 
    81              print "\\n" 
    82 CODE 
    83             ; 
    84         } ( 
    85         "", 
    86         "0", 
    87         "01", 
    88         "012", 
    89         "0123", 
    90         "01234", 
    91         "012345", 
    92         "0123456", 
    93         "01234567", 
    94         "012345678", 
    95         "0123456789", 
    96         "01234567890", 
    97         "012345678901", 
    98         "0123456789012", 
    99         "01234567890123", 
    100         "012345678901234", 
    101         "0123456789012345", 
    102         "01234567890123456", 
    103         "012345678901234567", 
    104         "0123456789012345678", 
    105         "01234567890123456789", 
    106         "012345678901234567890", 
    107         "0123456789012345678901", 
    108         "01234567890123456789012", 
    109         "012345678901234567890123", 
    110         "0123456789012345678901234", 
    111         "01234567890123456789012345", 
    112         "012345678901234567890123456", 
    113         "0123456789012345678901234567", 
    114         "01234567890123456789012345678", 
    115         "012345678901234567890123456789", 
    116         "0123456789012345678901234567890", 
    117         "01234567890123456789012345678901", 
    118         "012345678901234567890123456789012", 
    119         "0123456789012345678901234567890123", 
    120         "01234567890123456789012345678901234", 
    121         "012345678901234567890123456789012345", 
    122         "0123456789012345678901234567890123456", 
    123         "01234567890123456789012345678901234567", 
    124         "012345678901234567890123456789012345678", 
    125         "0123456789012345678901234567890123456789", 
    126         "01234567890123456789012345678901234567890", 
    127         "012345678901234567890123456789012345678901", 
    128         "0123456789012345678901234567890123456789012", 
    129         "01234567890123456789012345678901234567890123", 
    130         "012345678901234567890123456789012345678901234", 
    131         "0123456789012345678901234567890123456789012345", 
    132         "01234567890123456789012345678901234567890123456", 
    133         "012345678901234567890123456789012345678901234567", 
    134         "0123456789012345678901234567890123456789012345678", 
    135         "01234567890123456789012345678901234567890123456789", 
    136         "012345678901234567890123456789012345678901234567890", 
    137         "0123456789012345678901234567890123456789012345678901", 
    138         "01234567890123456789012345678901234567890123456789012", 
    139         "012345678901234567890123456789012345678901234567890123", 
    140         "0123456789012345678901234567890123456789012345678901234", 
    141         "01234567890123456789012345678901234567890123456789012345", 
    142         "012345678901234567890123456789012345678901234567890123456", 
    143         "0123456789012345678901234567890123456789012345678901234567", 
    144         "01234567890123456789012345678901234567890123456789012345678", 
    145         "012345678901234567890123456789012345678901234567890123456789", 
    146         "0123456789012345678901234567890123456789012345678901234567890", 
    147         "01234567890123456789012345678901234567890123456789012345678901", 
    148         "012345678901234567890123456789012345678901234567890123456789012", 
    149         "0123456789012345678901234567890123456789012345678901234567890123", 
    150         "01234567890123456789012345678901234567890123456789012345678901234", 
    151         "012345678901234567890123456789012345678901234567890123456789012345", 
    152         "0123456789012345678901234567890123456789012345678901234567890123456", 
    153         "01234567890123456789012345678901234567890123456789012345678901234567", 
    154         "012345678901234567890123456789012345678901234567890123456789012345678", 
    155         "0123456789012345678901234567890123456789012345678901234567890123456789", 
    156         "01234567890123456789012345678901234567890123456789012345678901234567890", 
    157         "012345678901234567890123456789012345678901234567890123456789012345678901", 
    158         "0123456789012345678901234567890123456789012345678901234567890123456789012", 
    159         "01234567890123456789012345678901234567890123456789012345678901234567890123", 
    160         "012345678901234567890123456789012345678901234567890123456789012345678901234", 
    161         "0123456789012345678901234567890123456789012345678901234567890123456789012345", 
    162         "01234567890123456789012345678901234567890123456789012345678901234567890123456", 
    163         "012345678901234567890123456789012345678901234567890123456789012345678901234567", 
    164         "0123456789012345678901234567890123456789012345678901234567890123456789012345678", 
    165         "01234567890123456789012345678901234567890123456789012345678901234567890123456789", 
    166         "012345678901234567890123456789012345678901234567890123456789012345678901234567890", 
    167         "0123456789012345678901234567890123456789012345678901234567890123456789012345678901", 
    168         "01234567890123456789012345678901234567890123456789012345678901234567890123456789012", 
    169         "012345678901234567890123456789012345678901234567890123456789012345678901234567890123", 
    170         "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234", 
    171         "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345", 
    172         "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456", 
    173         "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567", 
    174         "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", 
    175 "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", 
    176 "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 
    177 "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", 
    178 "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012", 
    179 "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123", 
    180 "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234", 
    181 "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345", 
    182 "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456", 
    183 "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567", 
    184 "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", 
    185 "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", 
    186 "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 
    187 "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", 
    188 "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012", 
    189 "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123", 
    190 "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234", 
    191 "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345", 
    192 "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456", 
    193 "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567", 
    194 "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", 
    195 "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", 
    196 "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 
    197  
    198         ) 
    199 ); 
    200  
    201 pir_output_is( <<CODE, <<'OUT', "String lengths" ); 
    202 .sub _main 
     67 
     68.sub test_string_lengths 
    20369    load_bytecode "Digest/MD5.pbc" 
    204     $code 
    205     end 
    206 .end 
    207 CODE 
    208 d41d8cd98f00b204e9800998ecf8427e 
     70    $I0 = 0 
     71 
     72    $S10 = <<'OUTPUT' 
    20973cfcd208495d565ef66e7dff9f98764da 
    2107496a3be3cf272e017046d1b2674a52bd3 
    21175d2490f048dc3b77a457e3e450ab4eb38 
     
    3171812468a5c59cccb56bd51ed5ee766b2d2b 
    31818209e32555adc12a6f2c8fed9a459935af 
    3191836c27622d1d5365e4abfd02f2eccfd8f9 
    320 OUT 
    321  
    322 my $text = "Hello Parrot World! " x 50_000; 
     184OUTPUT 
     185    $P0 = split "\n", $S10 
     186  testing_loop: 
     187    $S1 = $I0 
     188    $S0 .= $S1 
     189    $S5 = shift $P0 
     190    $P1 = _md5sum ($S0) 
     191    $S6 = _md5_hex($P1) 
     192    inc $I0 
     193    mod $I0, $I0, 10 
     194    $I1 = length $S0 
     195    $S12 = $I1 
     196    $S11 = 'string length ' 
     197    $S11 .= $S12 
     198    is($S6, $S5, $S11) 
     199    if $I1 <= 110 goto testing_loop 
     200.end 
    323201 
    324 pir_output_is( <<CODE, <<'OUT', "REALLY long string" ); 
    325 .sub _main 
     202.sub test_really_long_string 
    326203    load_bytecode "Digest/MD5.pbc" 
    327     \$P0 = _md5sum ("$text") 
    328     _md5_print (\$P0) 
    329     print "\\n" 
    330     end 
     204    $S0 = "Hello Parrot World! " 
     205    repeat $S1, $S0, 50000 
     206    $P0 = _md5sum ($S1) 
     207    $S2 = _md5_hex($P0) 
     208    is($S2, '840e4dec51660b1f52473e0b0b9545f5', 'really long string') 
    331209.end 
    332 CODE 
    333 840e4dec51660b1f52473e0b0b9545f5 
    334 OUT 
     210 
    335211 
    336212=begin bash 
    337213 
     
    349225 
    350226=cut 
    351227 
    352 pir_output_is( <<'CODE', <<'OUT', "recursive md5sum (1)" ); 
    353 .sub _main 
     228.sub test_recursive_md5_1 
    354229    load_bytecode "Digest/MD5.pbc" 
    355  
     230    .local string output 
    356231    $S0 = "Hello World!" 
    357232    $I0 = 0 
    358233 
    359 loop: 
    360     print $S0 
    361     print "\n" 
    362     if $I0 >= 200 goto end 
    363     $P0 = _md5sum($S0) 
    364     $S0 = _md5_hex($P0) 
    365     inc $I0 
    366     branch loop 
    367 end: 
    368     end 
    369 .end 
    370 CODE 
    371 Hello World! 
     234    output = <<'OUTPUT' 
    372235ed076287532e86365e841e92bfc50d8c 
    373236153163e20c7dd03b131fe2bf21927e1e 
    37423795b9b73c7a8abe6d5bf5ad8067a53cee 
     
    569432b63d8a186e272754b70953ddd441e9fd 
    57043384a112f819bf780dd268c68f21238374 
    571434eab26f6455a08779bcb43bc48c02c717 
    572 OUT 
     435OUTPUT 
     436    $P1 = split "\n", output 
     437  loop: 
     438    if $I0 >= 200 goto end 
     439    $P0 = _md5sum($S0) 
     440    $S0 = _md5_hex($P0) 
     441    $S1 = shift $P1 
     442    is($S0, $S1, 'recursive md5 (1)') 
     443    inc $I0 
     444    branch loop 
     445  end: 
     446 
     447.end 
    573448 
    574449=begin bash 
    575450 
     
    586461=end bash 
    587462 
    588463=cut 
    589  
    590 pir_output_is( <<'CODE', <<'OUT', "recursive md5sum (2)" ); 
    591 .sub _main 
     464.sub test_recursive_md5_2 
    592465    load_bytecode "Digest/MD5.pbc" 
    593  
     466    .local string output 
     467    .local pmc output_array 
    594468    $S0 = "Hello World!" 
    595469    $I0 = 0 
    596  
    597 loop: 
    598     print $S0 
    599     print "\n" 
    600     if $I0 >= 200 goto end 
    601     $S0 = clone $S0 
    602     $S0 = concat $S0, $S0 
    603     $P0 = _md5sum($S0) 
    604     $S0 = _md5_hex($P0) 
    605     inc $I0 
    606     branch loop 
    607 end: 
    608     end 
    609 .end 
    610 CODE 
    611 Hello World! 
     470    output = <<'OUTPUT' 
    612471ee41c968530f7715ab70805b341c3956 
    6134729548194ce84b2f7953386080da112c3a 
    6144739fb892cc0766429a1d8b0f752636c0fa 
     
    809668982d93d2437c46edbf99f542900231c0 
    8106698408bf5f0144309374e66278bec290b2 
    811670982e0fde28cd2f62ef8db2d8dfd0f0d7 
    812 OUT 
     671OUTPUT 
     672    output_array = split "\n", output 
     673  loop: 
     674    if $I0 >= 200 goto end 
     675    $S0 = clone $S0 
     676    $S0 = concat $S0, $S0 
     677    $P0 = _md5sum($S0) 
     678    $S0 = _md5_hex($P0) 
     679    $S1 = shift output_array 
     680    is($S0, $S1, 'recursive md5 (2)') 
     681    inc $I0 
     682    branch loop 
     683  end: 
     684 
     685.end 
    813686 
    814687# Local Variables: 
    815688#   mode: cperl 
    816689#   cperl-indent-level: 4 
    817690#   fill-column: 100 
    818691# End: 
    819 # vim: expandtab shiftwidth=4: 
     692# vim: expandtab shiftwidth=4 filetype=pir: