[svn:parrot] r49721 - trunk/t/op
nwellnhof at svn.parrot.org
nwellnhof at svn.parrot.org
Fri Oct 29 01:15:43 UTC 2010
Author: nwellnhof
Date: Fri Oct 29 01:15:43 2010
New Revision: 49721
URL: https://trac.parrot.org/parrot/changeset/49721
Log:
[t] Add some string tests
Modified:
trunk/t/op/string.t
trunk/t/op/string_cs.t
Modified: trunk/t/op/string.t
==============================================================================
--- trunk/t/op/string.t Fri Oct 29 01:15:23 2010 (r49720)
+++ trunk/t/op/string.t Fri Oct 29 01:15:43 2010 (r49721)
@@ -55,6 +55,7 @@
substr_offset_zero_zero_length_string()
exception_substr_offset_one_zero_length_string()
exception_substr_neg_offset_zero_length_string()
+ exception_substr_oob_utf8()
zero_length_substr_zero_length_string()
zero_length_substr_zero_length_string()
three_arg_substr_zero_length_string()
@@ -529,6 +530,14 @@
.exception_is( "Cannot take substr outside string" )
.end
+.sub exception_substr_oob_utf8
+ set $S0, utf8:"abc\uBEEFdef"
+ push_eh handler
+ substr $S1, $S0, 8, 5
+handler:
+ .exception_is( "Cannot take substr outside string" )
+.end
+
.sub zero_length_substr_zero_length_string
set $S0, ""
substr $S1, $S0, 10, 0
Modified: trunk/t/op/string_cs.t
==============================================================================
--- trunk/t/op/string_cs.t Fri Oct 29 01:15:23 2010 (r49720)
+++ trunk/t/op/string_cs.t Fri Oct 29 01:15:43 2010 (r49721)
@@ -6,7 +6,7 @@
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
-use Parrot::Test tests => 50;
+use Parrot::Test tests => 53;
use Parrot::Config;
=head1 NAME
@@ -91,9 +91,13 @@
set S0, iso-8859-1:"zAEIOU_ÄÖÜ\n"
titlecase S1, S0
print S1
+ set S0, iso-8859-1:"äAEIOU_ÄÖÜ\n"
+ titlecase S1, S0
+ print S1
end
CODE
Zaeiou_äöü
+Äaeiou_äöü
OUTPUT
pasm_output_is( <<'CODE', <<OUTPUT, "is_whitespace" );
@@ -247,7 +251,7 @@
0 2 5 7 ok
OUTPUT
-pasm_output_is( <<'CODE', <<OUTPUT, "trans_encoding_s_s_i" );
+pasm_output_is( <<'CODE', <<OUTPUT, "trans_encoding_s_s_i ascii to iso-8859-1" );
set S0, "abc"
find_encoding I0, "iso-8859-1"
trans_encoding S1, S0, I0
@@ -263,7 +267,23 @@
iso-8859-1
OUTPUT
-pasm_error_output_like( <<'CODE', <<OUTPUT, "trans_encoding_s_s_i - lossy" );
+pasm_output_is( <<'CODE', <<OUTPUT, "trans_encoding_s_s_i iso-8859-1 to ascii" );
+ set S0, iso-8859-1:"abc"
+ find_encoding I0, "ascii"
+ trans_encoding S1, S0, I0
+ print S1
+ print "\n"
+ encoding I0, S1
+ encodingname S2, I0
+ print S2
+ print "\n"
+ end
+CODE
+abc
+ascii
+OUTPUT
+
+pasm_error_output_like( <<'CODE', <<OUTPUT, "trans_encoding_s_s_i iso-8859-1 to ascii - lossy" );
set S1, iso-8859-1:"abcä"
find_encoding I0, "ascii"
trans_encoding S2, S1, I0
@@ -305,22 +325,6 @@
binary
OUTPUT
-pasm_output_is( <<'CODE', <<OUTPUT, "trans_encoding_s_s_i ascii to iso-8859-1" );
- set S0, ascii:"abc"
- find_encoding I0, "iso-8859-1"
- trans_encoding S1, S0, I0
- print S1
- print "\n"
- encoding I0, S1
- encodingname S2, I0
- print S2
- print "\n"
- end
-CODE
-abc
-iso-8859-1
-OUTPUT
-
pasm_output_is( <<'CODE', <<OUTPUT, "trans_encoding_s_s_i iso-8859-1 to utf8" );
set S0, iso-8859-1:"abc_ä_"
find_encoding I0, "utf8"
@@ -365,6 +369,26 @@
6
OUTPUT
+pasm_error_output_like( <<'CODE', <<OUTPUT, "trans_encoding_s_s_i utf-8 to iso-8859-1 - lossy" );
+ set S1, utf8:"abc\uBABE"
+ find_encoding I0, "iso-8859-1"
+ trans_encoding S2, S1, I0
+ print "never\n"
+ end
+CODE
+/lossy conversion to iso-8559-1/
+OUTPUT
+
+pasm_error_output_like( <<'CODE', <<OUTPUT, "trans_encoding_s_s_i utf-8 to ascii - lossy" );
+ set S1, utf8:"abc\xFC"
+ find_encoding I0, "ascii"
+ trans_encoding S2, S1, I0
+ print "never\n"
+ end
+CODE
+/can't convert unicode string to ascii/
+OUTPUT
+
pir_output_is( <<'CODE', <<'OUTPUT', "bug #34661 literal" );
.sub main :main
$S0 = utf8:"\"]\nif I3 == "
@@ -786,7 +810,7 @@
T\x{c3}\x{b6}tsch Leo
OUTPUT
- pir_output_is( <<'CODE', <<OUTPUT, "combose combined char" );
+ pir_output_is( <<'CODE', <<OUTPUT, "compose combined char" );
.sub main :main
set $S1, utf8:"___\u01f0___"
length $I0, $S1
@@ -867,6 +891,29 @@
x/\u0445\u0440\u0435\u043d\u044c_09-10.txt
OUTPUT
+pir_output_is(<<'CODE', <<'OUTPUT', 'compare mixed encodings' );
+.sub 'main'
+ $S0 = iso-8859-1:"a\xFCb 1"
+ $S1 = utf8:"a\xFCb 2"
+ $I0 = islt $S0, $S1
+ say $I0
+ $I0 = isgt $S1, $S0
+ say $I0
+
+ $S0 = utf8:"a\uBABEb c\uBEEFd 1"
+ $S1 = ucs2:"a\uBABEb c\uBEEFd 2"
+ $I0 = islt $S0, $S1
+ say $I0
+ $I0 = isgt $S1, $S0
+ say $I0
+.end
+CODE
+1
+1
+1
+1
+OUTPUT
+
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
More information about the parrot-commits
mailing list