diff --git t/library/md5.t t/library/md5.t index e747da2..70ceaf9 100644 --- t/library/md5.t +++ t/library/md5.t @@ -1,13 +1,7 @@ -#!perl +#!parrot # Copyright (C) 2001-2005, Parrot Foundation. # $Id$ -use strict; -use warnings; -use lib qw( t . lib ../lib ../../lib ); -use Test::More; -use Parrot::Test tests => 6; - =head1 NAME t/library/md5.t - test MD5 library @@ -32,180 +26,50 @@ regressisions in the parrot VM, JIT and GC ############################## # Stress parrot using MD5 library -pir_output_is( <<'CODE', <<'OUT', "Miscellaneous words" ); -.sub _main +.sub main :main + .include 'test_more.pir' + plan(517) + + test_miscellaneous_words() + test_funny_chars() + test_string_lengths() + test_really_long_string() + test_recursive_md5_1() + test_recursive_md5_2() +.end + +.sub test_miscellaneous_words load_bytecode "Digest/MD5.pbc" $P0 = _md5sum ("Hello") - _md5_print ($P0) - print "\n" + $S0 = _md5_hex($P0) + is($S0, '8b1a9953c4611296a827abf8c47804d7', 'md5 Hello') $P0 = _md5sum ("Goodbye") - _md5_print ($P0) - print "\n" + $S0 = _md5_hex($P0) + is($S0, '6fc422233a40a75a1f028e11c3cd1140', 'md5 Goodbye') $P0 = _md5sum ("Parrot") - _md5_print ($P0) - print "\n" + $S0 = _md5_hex($P0) + is($S0, 'e7cb1e977e896954fec46d2ea7832072', 'md5 Parrot') $P0 = _md5sum ("Hello World!") - _md5_print ($P0) - print "\n" + $S0 = _md5_hex($P0) + is($S0, 'ed076287532e86365e841e92bfc50d8c', 'md5 Hello World') - end .end -CODE -8b1a9953c4611296a827abf8c47804d7 -6fc422233a40a75a1f028e11c3cd1140 -e7cb1e977e896954fec46d2ea7832072 -ed076287532e86365e841e92bfc50d8c -OUT -pir_output_is( <<'CODE', <<'OUT', "Funny chars" ); -.sub _main +.sub test_funny_chars load_bytecode "Digest/MD5.pbc" $P0 = _md5sum ("\n\n\n\n\t") - _md5_print ($P0) - print "\n" - end + $S0 = _md5_hex($P0) + is($S0, 'b66434493525523b4393ce0d1f2425d7', 'funny chars') .end -CODE -b66434493525523b4393ce0d1f2425d7 -OUT - -my $code = join( - "\n\n", - map { - <= 200 goto end - $P0 = _md5sum($S0) - $S0 = _md5_hex($P0) - inc $I0 - branch loop -end: - end -.end -CODE -Hello World! + output = <<'OUTPUT' ed076287532e86365e841e92bfc50d8c 153163e20c7dd03b131fe2bf21927e1e 95b9b73c7a8abe6d5bf5ad8067a53cee @@ -569,7 +432,19 @@ d3ea9bd2f33e17e699517912322fe972 b63d8a186e272754b70953ddd441e9fd 84a112f819bf780dd268c68f21238374 eab26f6455a08779bcb43bc48c02c717 -OUT +OUTPUT + $P1 = split "\n", output + loop: + if $I0 >= 200 goto end + $P0 = _md5sum($S0) + $S0 = _md5_hex($P0) + $S1 = shift $P1 + is($S0, $S1, 'recursive md5 (1)') + inc $I0 + branch loop + end: + +.end =begin bash @@ -586,29 +461,13 @@ done =end bash =cut - -pir_output_is( <<'CODE', <<'OUT', "recursive md5sum (2)" ); -.sub _main +.sub test_recursive_md5_2 load_bytecode "Digest/MD5.pbc" - + .local string output + .local pmc output_array $S0 = "Hello World!" $I0 = 0 - -loop: - print $S0 - print "\n" - if $I0 >= 200 goto end - $S0 = clone $S0 - $S0 = concat $S0, $S0 - $P0 = _md5sum($S0) - $S0 = _md5_hex($P0) - inc $I0 - branch loop -end: - end -.end -CODE -Hello World! + output = <<'OUTPUT' ee41c968530f7715ab70805b341c3956 9548194ce84b2f7953386080da112c3a 9fb892cc0766429a1d8b0f752636c0fa @@ -809,11 +668,25 @@ f67fa138069da8fce68c131106492372 982d93d2437c46edbf99f542900231c0 8408bf5f0144309374e66278bec290b2 982e0fde28cd2f62ef8db2d8dfd0f0d7 -OUT +OUTPUT + output_array = split "\n", output + loop: + if $I0 >= 200 goto end + $S0 = clone $S0 + $S0 = concat $S0, $S0 + $P0 = _md5sum($S0) + $S0 = _md5_hex($P0) + $S1 = shift output_array + is($S0, $S1, 'recursive md5 (2)') + inc $I0 + branch loop + end: + +.end # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 100 # End: -# vim: expandtab shiftwidth=4: +# vim: expandtab shiftwidth=4 filetype=pir: