diff options
author | ariel faigon <ariel.git@yendor.com> | 2011-06-30 12:22:24 +0400 |
---|---|---|
committer | ariel faigon <ariel.git@yendor.com> | 2011-06-30 12:22:24 +0400 |
commit | 73cbef040fef848a72096a11b8b5294905aa3ee7 (patch) | |
tree | 613a8bf1fe345f7d7cdabe3894665194d9f70571 /test | |
parent | 78972c0e5c0eb6412f02edf27b8afc9371d50e86 (diff) |
RunTests: Add abs() on delta in fuzzy compare
RunTests: Add -E <epsilon> fuzzy compare option
Diffstat (limited to 'test')
-rwxr-xr-x | test/RunTests | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/test/RunTests b/test/RunTests index 29a764f8..0956777b 100755 --- a/test/RunTests +++ b/test/RunTests @@ -8,7 +8,7 @@ # See __DATA__ below for how to add more tests # use Getopt::Std; -use vars qw($opt_d $opt_c $opt_e $opt_f $opt_o); +use vars qw($opt_d $opt_c $opt_e $opt_f $opt_E $opt_o); my $Epsilon = 1e-4; @@ -26,11 +26,12 @@ sub usage(@) { . .. \$PATH Options: - -c print commands before running them - -d print diff output on diff-failure - -e Abort on first diff error - -f Ignore small (< $Epsilon) floating-point differences (fuzzy compare) - -o Overwrite reference file with new/different result + -c print commands before running them + -d print diff output on diff-failure + -e Abort on first diff error + -f Ignore small (< $Epsilon) floating-point differences (fuzzy compare) + -E<e> Set epsilon <e> for fuzzy floating-point compares (default $Epsilon) + -o Overwrite reference file with new/different result "; } @@ -81,7 +82,8 @@ sub which_lda() { sub init() { $0 =~ s{.*/}{}; - getopts('cdefo') || usage(); + getopts('cdefE:o') || usage(); + $Epsilon = $opt_E if ($opt_E); $VW = which_vw(); $LDA = which_lda(); } @@ -183,7 +185,7 @@ sub lenient_array_compare($$) { # There's some difference, is it significant? return 1 unless (looks_like_number($w1[$i])); return 1 unless (looks_like_number($w2[$i])); - my $delta = $w1[$i] - $w2[$i]; + my $delta = abs($w1[$i] - $w2[$i]); return 1 if ($delta > $Epsilon); } |