[svn:parrot] r46405 - trunk/t/dynpmc
fperrad at svn.parrot.org
fperrad at svn.parrot.org
Sat May 8 11:05:07 UTC 2010
Author: fperrad
Date: Sat May 8 11:05:04 2010
New Revision: 46405
URL: https://trac.parrot.org/parrot/changeset/46405
Log:
[GzipHandle] more tests
Modified:
trunk/t/dynpmc/gziphandle.t
Modified: trunk/t/dynpmc/gziphandle.t
==============================================================================
--- trunk/t/dynpmc/gziphandle.t Sat May 8 09:29:05 2010 (r46404)
+++ trunk/t/dynpmc/gziphandle.t Sat May 8 11:05:04 2010 (r46405)
@@ -22,7 +22,7 @@
.local pmc config_hash, interp
.local int num_tests
- num_tests = 6
+ num_tests = 9
plan(num_tests)
interp = getinterp
config_hash = interp[.IGLOBALS_CONFIG_HASH]
@@ -31,6 +31,7 @@
$P0 = loadlib 'gziphandle'
test_handle()
+ test_stream()
test_version()
test_basic()
.return()
@@ -49,6 +50,32 @@
ok($I0, 'does Handle')
.end
+.include 'stat.pasm'
+
+.sub 'test_stream'
+ $P0 = new 'FileHandle'
+ $S0 = $P0.'readall'('t/dynpmc/gziphandle.t')
+ $I0 = length $S0
+ diag($I0)
+ .const string filename = 't/dynpmc/gziphandle.t.gz'
+ $P1 = new 'GzipHandle'
+ $P1.'open'(filename, 'wb')
+ $P1.'puts'($S0)
+ $P1.'close'()
+ $I1 = stat filename, .STAT_FILESIZE
+ diag($I1)
+ $I2 = $I1 < $I0
+ ok($I2, "compressed")
+ $P2 = new 'GzipHandle'
+ $P2.'open'(filename, 'rb')
+ $S1 = $P2.'read'($I0)
+ $P2.'close'()
+ is($S1, $S0, "gzip stream")
+ $P0 = loadlib 'os'
+ $P0 = new 'OS'
+ $P0.'rm'(filename)
+.end
+
.sub 'test_version'
$P0 = new 'GzipHandle'
$S0 =$P0.'version'()
@@ -67,6 +94,15 @@
is($I0, 15, "compress")
$S0 = $P0.'uncompress'($S0)
is($S0, data, "uncompress")
+
+ $S0 = repeat 'repeat', 100
+ $I0 = length $S0
+ $S1 = $P0.'compress'($S0)
+ $I1 = length $S1
+ $N0 = $I1 / $I0
+ diag($N0)
+ $S2 = $P0.'uncompress'($S1)
+ is($S2, $S0, "uncompress with many realloc")
.end
# Local Variables:
More information about the parrot-commits
mailing list