diff options
author | Mike Guy <mjtg@cam.ac.uk> | 2000-09-01 18:43:33 +0100 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2000-09-01 19:37:40 +0000 |
commit | 246fae53ea6ae12991e7653f136a0f797ce002d4 (patch) | |
tree | 217a07ca92ca48618ff14c8cead58f88b284fbb3 /t/op/vec.t | |
parent | 93d73c42a7dc0b497a6a2eb40edcb6429896653c (diff) | |
download | perl-246fae53ea6ae12991e7653f136a0f797ce002d4.tar.gz |
Fix vec() / utf8 (was Re: bitvec ops still broken with utf8 -- or not?)
Message-Id: <E13Utuf-0004Bw-00@draco.cus.cam.ac.uk>
p4raw-id: //depot/perl@6988
Diffstat (limited to 't/op/vec.t')
-rwxr-xr-x | t/op/vec.t | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/t/op/vec.t b/t/op/vec.t index 52b20cd7fa..b75bebfade 100755 --- a/t/op/vec.t +++ b/t/op/vec.t @@ -1,6 +1,6 @@ #!./perl -print "1..23\n"; +print "1..30\n"; print vec($foo,0,1) == 0 ? "ok 1\n" : "not ok 1\n"; print length($foo) == 0 ? "ok 2\n" : "not ok 2\n"; @@ -48,3 +48,32 @@ print "not " if defined $x or $@ !~ /^Assigning to negative offset in vec/; print "ok 22\n"; print "not " if vec('abcd', 7, 8); print "ok 23\n"; + +# UTF8 +# N.B. currently curiously coded to circumvent bugs elswhere in UTF8 handling + +$foo = "\x{100}" . "\xff\xfe"; +$x = substr $foo, 1; +print "not " if vec($x, 0, 8) != 255; +print "ok 24\n"; +eval { vec($foo, 1, 8) }; +print "not " unless $@ =~ /^Character > 255 in vec\(\) /; +print "ok 25\n"; +eval { vec($foo, 1, 8) = 13 }; +print "not " unless $@ =~ /^Character > 255 in vec\(\) /; +print "ok 26\n"; +print "not " if $foo ne "\x{100}" . "\xff\xfe"; +print "ok 27\n"; +$x = substr $foo, 1; +vec($x, 2, 4) = 7; +print "not " if $x ne "\xff\xf7"; +print "ok 28\n"; + +# mixed magic + +$foo = "\x61\x62\x63\x64\x65\x66"; +print "not " if vec(substr($foo, 2, 2), 0, 16) != 25444; +print "ok 29\n"; +vec(substr($foo, 1,3), 5, 4) = 3; +print "not " if $foo ne "\x61\x62\x63\x34\x65\x66"; +print "ok 30\n"; |