summaryrefslogtreecommitdiff
path: root/t/op
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-05-30 19:06:02 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-05-30 19:06:02 +0000
commitc39c4c4198cb4da57d3e414b8057d9d3eb62d051 (patch)
tree74038f8cd97b6c8914051953c7ebf8b0ccc9fec6 /t/op
parent7137b697ec555c9b289c3e73574e70805cde732d (diff)
downloadperl-c39c4c4198cb4da57d3e414b8057d9d3eb62d051.tar.gz
test.pl-isation.
p4raw-id: //depot/perl@19642
Diffstat (limited to 't/op')
-rwxr-xr-xt/op/index.t64
1 files changed, 32 insertions, 32 deletions
diff --git a/t/op/index.t b/t/op/index.t
index 2c69f93210..9e21e58e2b 100755
--- a/t/op/index.t
+++ b/t/op/index.t
@@ -1,71 +1,71 @@
#!./perl
-# $RCSfile: index.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:59 $
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
-print "1..28\n";
+require './test.pl';
+plan( tests => 28 );
$foo = 'Now is the time for all good men to come to the aid of their country.';
$first = substr($foo,0,index($foo,'the'));
-print ($first eq "Now is " ? "ok 1\n" : "not ok 1\n");
+is($first, "Now is ");
$last = substr($foo,rindex($foo,'the'),100);
-print ($last eq "their country." ? "ok 2\n" : "not ok 2\n");
+is($last, "their country.");
$last = substr($foo,index($foo,'Now'),2);
-print ($last eq "No" ? "ok 3\n" : "not ok 3\n");
+is($last, "No");
$last = substr($foo,rindex($foo,'Now'),2);
-print ($last eq "No" ? "ok 4\n" : "not ok 4\n");
+is($last, "No");
$last = substr($foo,index($foo,'.'),100);
-print ($last eq "." ? "ok 5\n" : "not ok 5\n");
+is($last, ".");
$last = substr($foo,rindex($foo,'.'),100);
-print ($last eq "." ? "ok 6\n" : "not ok 6\n");
+is($last, ".");
-print index("ababa","a",-1) == 0 ? "ok 7\n" : "not ok 7\n";
-print index("ababa","a",0) == 0 ? "ok 8\n" : "not ok 8\n";
-print index("ababa","a",1) == 2 ? "ok 9\n" : "not ok 9\n";
-print index("ababa","a",2) == 2 ? "ok 10\n" : "not ok 10\n";
-print index("ababa","a",3) == 4 ? "ok 11\n" : "not ok 11\n";
-print index("ababa","a",4) == 4 ? "ok 12\n" : "not ok 12\n";
-print index("ababa","a",5) == -1 ? "ok 13\n" : "not ok 13\n";
+is(index("ababa","a",-1), 0);
+is(index("ababa","a",0), 0);
+is(index("ababa","a",1), 2);
+is(index("ababa","a",2), 2);
+is(index("ababa","a",3), 4);
+is(index("ababa","a",4), 4);
+is(index("ababa","a",5), -1);
-print rindex("ababa","a",-1) == -1 ? "ok 14\n" : "not ok 14\n";
-print rindex("ababa","a",0) == 0 ? "ok 15\n" : "not ok 15\n";
-print rindex("ababa","a",1) == 0 ? "ok 16\n" : "not ok 16\n";
-print rindex("ababa","a",2) == 2 ? "ok 17\n" : "not ok 17\n";
-print rindex("ababa","a",3) == 2 ? "ok 18\n" : "not ok 18\n";
-print rindex("ababa","a",4) == 4 ? "ok 19\n" : "not ok 19\n";
-print rindex("ababa","a",5) == 4 ? "ok 20\n" : "not ok 20\n";
+is(rindex("ababa","a",-1), -1);
+is(rindex("ababa","a",0), 0);
+is(rindex("ababa","a",1), 0);
+is(rindex("ababa","a",2), 2);
+is(rindex("ababa","a",3), 2);
+is(rindex("ababa","a",4), 4);
+is(rindex("ababa","a",5), 4);
$a = "foo \x{1234}bar";
-print index($a, "\x{1234}") == 4 ? "ok 21\n" : "not ok 21\n";
-print index($a, "bar", ) == 5 ? "ok 22\n" : "not ok 22\n";
+is(index($a, "\x{1234}"), 4);
+is(index($a, "bar", ), 5);
-print rindex($a, "\x{1234}") == 4 ? "ok 23\n" : "not ok 23\n";
-print rindex($a, "foo", ) == 0 ? "ok 24\n" : "not ok 24\n";
+is(rindex($a, "\x{1234}"), 4);
+is(rindex($a, "foo", ), 0);
{
- # [perl #22375] 'split'/'index' problem for utf8
- my $t = 25;
my $needle = "\x{1230}\x{1270}";
my @needles = split ( //, $needle );
my $haystack = "\x{1228}\x{1228}\x{1230}\x{1270}";
foreach ( @needles ) {
my $a = index ( "\x{1228}\x{1228}\x{1230}\x{1270}", $_ );
my $b = index ( $haystack, $_ );
- print $a == $b ? "ok $t\n" : "not ok $t # - $a != $b\n";
- $t++;
+ is($a, $b, q{[perl #22375] 'split'/'index' problem for utf8});
}
$needle = "\x{1270}\x{1230}"; # Transpose them.
@needles = split ( //, $needle );
foreach ( @needles ) {
my $a = index ( "\x{1228}\x{1228}\x{1230}\x{1270}", $_ );
my $b = index ( $haystack, $_ );
- print $a == $b ? "ok $t\n" : "not ok $t # - $a != $b\n";
- $t++;
+ is($a, $b, q{[perl #22375] 'split'/'index' problem for utf8});
}
}