From: Jarkko Hietaniemi Date: Sat, 14 Jun 2003 08:50:16 +0000 (+0000) Subject: test.pl-ify and add a couple of tests. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1ae0ae1779f56be3f5008214f23d0e0a7f3dce42;p=p5sagit%2Fp5-mst-13.2.git test.pl-ify and add a couple of tests. p4raw-id: //depot/perl@19775 --- diff --git a/lib/bytes.t b/lib/bytes.t index dda2b87..28043ca 100644 --- a/lib/bytes.t +++ b/lib/bytes.t @@ -1,32 +1,34 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; + require './test.pl'; } -print "1..6\n"; +plan tests => 9; -my $a = chr(0x0100); +my $a = chr(0x100); -print ord($a) == 0x100 ? "ok 1\n" : "not ok 1\n"; -print length($a) == 1 ? "ok 2\n" : "not ok 2\n"; +is(ord($a), 0x100, "ord sanity check"); +is(length($a), 1, "length sanity check"); +is(bytes::length($a), 2, "bytes::length sanity check"); { use bytes; - my $b = chr(0x0100); - print ord($b) == 0 ? "ok 3\n" : "not ok 3\n"; + my $b = chr(0x100); # affected by 'use bytes' + is(ord($b), 0, "chr truncates under use bytes"); + is(length($b), 1, "length truncated under use bytes"); + is(bytes::length($b), 1, "bytes::length truncated under use bytes"); } -my $c = chr(0x0100); - -print ord($c) == 0x100 ? "ok 4\n" : "not ok 4\n"; +my $c = chr(0x100); { use bytes; - if (ord('A') == 193) { - print ord($c) == 0x8c ? "ok 5\n" : "not ok 5\n"; + if (ord('A') == 193) { # EBCDIC? + is(ord($c), 0x8c, "ord under use bytes looks at the 1st byte"); } else { - print ord($c) == 0xc4 ? "ok 5\n" : "not ok 5\n"; + is(ord($c), 0xc4, "ord under use bytes looks at the 1st byte"); } - print length($c) == 2 ? "ok 6\n" : "not ok 6\n"; + is(length($c), 2, "length under use bytes looks at bytes"); + is(bytes::length($c), 2, "bytes::length under use bytes looks at bytes"); } -