OSDN Git Service

Fix: can't run test.
authorNARUSE, Yui <naruse@users.sourceforge.jp>
Wed, 21 Jan 2009 18:33:41 +0000 (03:33 +0900)
committerNARUSE, Yui <naruse@users.sourceforge.jp>
Wed, 21 Jan 2009 18:33:41 +0000 (03:33 +0900)
NKF.mod/test.pl
nkf_test.pl

index b3cb928..3350aef 100644 (file)
@@ -114,8 +114,35 @@ END {print "not ok 1\n" unless $loaded;}
     } else {
        print "no 5\n";
     }
+}
 
-
+sub command_tests {
+    my @tests = @_;
+    my ($in, $out, $ans);
+
+    for (my $i = 0; $i <= $#tests; $i += 3){
+       local (@nkf) = split(/ /,$tests[$i]);
+       shift(@nkf);
+       $in = $tests[$i+1];
+       $ans = $tests[$i+2];
+        $out = NKF::nkf(@nkf,$in);
+       $out =~ s/ //g if $nkf =~ /-\w+m[NS]/o;
+       $ans =~ s/ //g if $nkf =~ /-\w+m[NS]/o;
+        if ($out ne $ans) {
+           last;
+       }
+    }
+    if ($out eq $ans) {
+       print "Ok\n";
+       return;
+    }
+    print "Fail\n";
+    if ($diff) {
+       open(R,"|od -c >tmp.result.bad"); binmode R; print R $out; close(R);
+       open(R,"|od -c >tmp.expect.bad"); binmode R; print R $ans; close(R);
+       system "diff -c tmp.result.bad tmp.expect.bad";
+    }
+    return;
 }
 
 do "../nkf_test.pl";
index 0320256..9b0228d 100644 (file)
@@ -957,6 +957,7 @@ eofeof
 printf "%-40s", "test_data/bugs10904";
     &test("$nkf -Mj",$example{'test_data/bugs10904'},$example{'test_data/bugs10904.ans'});
 
+    if (!NKF) {
 printf "%-40s", "Guess NL";
 &command_tests(
        "$nkf --guess","none",      "ASCII\n",
@@ -980,6 +981,7 @@ printf "%-40s", "Guess NL";
        "$nkf --guess","\r\n.\n",   "ASCII (MIXED NL)\n",
        "$nkf --guess","\r\n.\r",   "ASCII (MIXED NL)\n",
        "$nkf --guess","\r\n.\r\n", "ASCII (CRLF)\n");
+    }
 
 printf "%-40s", "Convert NL to LF";
 &command_tests(