From b7ee1f1b26ba715116fd8f66e83bf1ad8a95bcce Mon Sep 17 00:00:00 2001 From: "NARUSE, Yui" Date: Thu, 22 Jan 2009 03:33:41 +0900 Subject: [PATCH] Fix: can't run test. --- NKF.mod/test.pl | 29 ++++++++++++++++++++++++++++- nkf_test.pl | 2 ++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/NKF.mod/test.pl b/NKF.mod/test.pl index b3cb928..3350aef 100644 --- a/NKF.mod/test.pl +++ b/NKF.mod/test.pl @@ -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"; diff --git a/nkf_test.pl b/nkf_test.pl index 0320256..9b0228d 100644 --- a/nkf_test.pl +++ b/nkf_test.pl @@ -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( -- 2.11.0