summaryrefslogtreecommitdiff
path: root/t/op/ord.t
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-12-16 02:45:06 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-12-16 02:45:06 +0000
commit9466bab696bbe701541ead3a883c2387f5110da2 (patch)
tree070a0fde8d3f0dcf9fbcc1b789f7e4ee2c1ce265 /t/op/ord.t
parent76ccdbe266e63a2a3ac21a782e44a6b13093ac7f (diff)
downloadperl-9466bab696bbe701541ead3a883c2387f5110da2.tar.gz
Make creating UTF-8 surrogates a punishable act.
p4raw-id: //depot/perl@13707
Diffstat (limited to 't/op/ord.t')
-rwxr-xr-xt/op/ord.t34
1 files changed, 21 insertions, 13 deletions
diff --git a/t/op/ord.t b/t/op/ord.t
index f664078d00..f7460553cc 100755
--- a/t/op/ord.t
+++ b/t/op/ord.t
@@ -1,34 +1,42 @@
#!./perl
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '.';
+ require "test.pl";
+}
+
print "1..8\n";
# compile time evaluation
# 'A' 65 ASCII
# 'A' 193 EBCDIC
-if (ord('A') == 65 || ord('A') == 193) {print "ok 1\n";} else {print "not ok 1\n";}
-print "not " unless ord(chr(500)) == 500;
-print "ok 2\n";
+ok(ord('A') == 65 || ord('A') == 193, "ord('A') is ".ord('A'));
+
+is(ord(chr(500)), 500, "compile time chr 500");
# run time evaluation
$x = 'ABC';
-if (ord($x) == 65 || ord($x) == 193) {print "ok 3\n";} else {print "not ok 3\n";}
-if (chr 65 eq 'A' || chr 193 eq 'A') {print "ok 4\n";} else {print "not ok 4\n";}
+ok(ord($x) == 65 || ord($x) == 193, "ord('$x') is ".ord($x));
-print "not " unless ord(chr(500)) == 500;
-print "ok 5\n";
+ok(chr 65 eq 'A' || chr 193 eq 'A', "chr can produce 'A'");
$x = 500;
-print "not " unless ord(chr($x)) == $x;
-print "ok 6\n";
+is(ord(chr($x)), $x, "runtime chr $x");
-print "not " unless ord("\x{1234}") == 0x1234;
-print "ok 7\n";
+is(ord("\x{1234}"), 0x1234, 'compile time ord \x{....}');
$x = "\x{1234}";
-print "not " unless ord($x) == 0x1234;
-print "ok 8\n";
+is(ord($x), 0x1234, 'runtime ord \x{....}');
+
+{
+ eval 'my $surrogate = chr(0xD800)';
+
+ like($@, qr/^UTF-16 surrogate 0xd800 /, "surrogates bad");
+}
+