[svn:parrot] r48987 - in trunk: config/gen/makefiles t/op t/op/testlib
plobsing at svn.parrot.org
plobsing at svn.parrot.org
Tue Sep 14 05:32:45 UTC 2010
Author: plobsing
Date: Tue Sep 14 05:32:45 2010
New Revision: 48987
URL: https://trac.parrot.org/parrot/changeset/48987
Log:
add tests for literal string encoding persistence.
TT #468, TT #1791
Added:
trunk/t/op/testlib/ (props changed)
trunk/t/op/testlib/test_strings.pir
Modified:
trunk/config/gen/makefiles/root.in
trunk/t/op/string_cs.t
Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in Tue Sep 14 04:30:56 2010 (r48986)
+++ trunk/config/gen/makefiles/root.in Tue Sep 14 05:32:45 2010 (r48987)
@@ -1698,7 +1698,8 @@
t/steps/*.t
PBC_TEST_FILES = \
t/pmc/testlib/annotations.pbc \
- t/pmc/testlib/number.pbc
+ t/pmc/testlib/number.pbc \
+ t/op/testlib/test_strings.pbc
# pbc files used for several tests
pbctestfiles: $(PARROT) $(PBC_TEST_FILES)
@@ -1709,6 +1710,9 @@
t/pmc/testlib/annotations.pbc: t/pmc/testlib/annotations.pir
$(PARROT) -o t/pmc/testlib/annotations.pbc t/pmc/testlib/annotations.pir
+t/op/testlib/test_strings.pbc: t/op/testlib/test_strings.pir
+ $(PARROT) -o t/op/testlib/test_strings.pbc t/op/testlib/test_strings.pir
+
# Common prep for all test targets.
# We probably need a complete build before running the tests.
test_prep : all pbctestfiles
Modified: trunk/t/op/string_cs.t
==============================================================================
--- trunk/t/op/string_cs.t Tue Sep 14 04:30:56 2010 (r48986)
+++ trunk/t/op/string_cs.t Tue Sep 14 05:32:45 2010 (r48987)
@@ -6,7 +6,7 @@
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
-use Parrot::Test tests => 47;
+use Parrot::Test tests => 49;
use Parrot::Config;
=head1 NAME
@@ -48,6 +48,78 @@
ascii
OUTPUT
+pir_output_is( <<'CODE', <<OUTPUT, "literal encoding persistence - TT #468" );
+.include 'stdio.pasm'
+.sub main
+ # set output encoding to normalize printed strings
+ $P0 = getinterp
+ $P1 = $P0.'stdhandle'(.PIO_STDOUT_FILENO)
+ $P1.'encoding'('utf8')
+
+ load_bytecode 't/op/testlib/test_strings.pbc'
+ $P0 = 'get_hellos'()
+ $P1 = iter $P0
+
+ loop:
+ unless $P1 goto end_loop
+ $S0 = shift $P1
+ show($S0)
+ goto loop
+ end_loop:
+.end
+
+.sub show
+ .param string s
+ print s
+ $I0 = bytelength s
+ print '('
+ print $I0
+ print "): "
+ $I0 = encoding s
+ $S0 = encodingname $I0
+ say $S0
+.end
+CODE
+hello(5): ascii
+hello(5): utf8
+hello(5): utf8
+hello(10): utf16
+hello(10): ucs2
+OUTPUT
+
+pir_output_is( <<'CODE', <<OUTPUT, "empty literal encoding persistence - TT #1791", todo => 'TT #1791' );
+.sub main
+ load_bytecode 't/op/testlib/test_strings.pbc'
+ $P0 = 'get_empties'()
+ $P1 = iter $P0
+
+ loop:
+ unless $P1 goto end_loop
+ $S0 = shift $P1
+ show($S0)
+ goto loop
+ end_loop:
+.end
+
+.sub show
+ .param string s
+ print s
+ $I0 = bytelength s
+ print '('
+ print $I0
+ print "): "
+ $I0 = encoding s
+ $S0 = encodingname $I0
+ say $S0
+.end
+CODE
+(0): fixed_8
+(0): utf8
+(0): utf8
+(0): utf16
+(0): ucs2
+OUTPUT
+
pasm_output_is( <<'CODE', <<OUTPUT, "find_encoding" );
find_encoding I0, "iso-8859-1"
print "ok 1\n"
Added: trunk/t/op/testlib/test_strings.pir
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/t/op/testlib/test_strings.pir Tue Sep 14 05:32:45 2010 (r48987)
@@ -0,0 +1,29 @@
+# Copyright (C) 2006-2009, Parrot Foundation.
+# $Id$
+
+.sub 'get_hellos'
+ $P0 = new ['ResizableStringArray']
+ push $P0, "hello"
+ push $P0, unicode:"hello"
+ push $P0, utf8:unicode:"hello"
+ push $P0, utf16:unicode:"hello"
+ push $P0, ucs2:unicode:"hello"
+ .return ($P0)
+.end
+
+.sub 'get_empties'
+ $P0 = new ['ResizableStringArray']
+ push $P0, ""
+ push $P0, unicode:""
+ push $P0, utf8:unicode:""
+ push $P0, utf16:unicode:""
+ push $P0, ucs2:unicode:""
+ .return ($P0)
+.end
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
+
More information about the parrot-commits
mailing list