This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In ReTest.pl, provide is(), isnt(), like() and unlike(), equivalent to test.pl
authorNicholas Clark <nick@ccl4.org>
Thu, 3 Mar 2011 14:44:31 +0000 (14:44 +0000)
committerNicholas Clark <nick@ccl4.org>
Sat, 5 Mar 2011 20:26:08 +0000 (20:26 +0000)
This will ease the migration of the users of ReTest.pl to test.pl

t/re/ReTest.pl

index ee147aa..561c36b 100644 (file)
@@ -156,6 +156,28 @@ sub isneq ($$;$) {
     _ok $pass, $name, $error;
 }   
 
+*is = \&iseq;
+*isnt = \&isneq;
+
+sub like ($$$) {
+    my (undef, $expected, $name) = @_;
+    my ($pass, $error);
+    $pass = $_[0] =~ /$expected/;
+    unless ($pass) {
+       $error = "#      got '$_[0]'\n# expected /$expected/";
+    }
+    _ok($pass, $name, $error);
+}
+
+sub unlike ($$$) {
+    my (undef, $expected, $name) = @_;
+    my ($pass, $error);
+    $pass = $_[0] !~ /$expected/;
+    unless ($pass) {
+       $error = "#      got '$_[0]'\n# expected !~ /$expected/";
+    }
+    _ok($pass, $name, $error);
+}
 
 sub eval_ok ($;$) {
     my ($code, $name) = @_;