Skip to content

Commit

Permalink
Fix unicode tests so they aren't TODO'd anymore
Browse files Browse the repository at this point in the history
Fix some of the expected failures. This should result in the tests now
all passing, instead of having some of them pass with TODO's.

I have also made the debug mode much better. It will now tell you what
it expected and what it actually got for that codepoint.

Fixed some <= that should have been <, and vice versa.
  • Loading branch information
samcv committed Nov 4, 2020
1 parent 53b558f commit 68196c9
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions t/09-moar/UnipropCheck.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ my %prop-data =
my %expected-loses =
"extracted/DerivedGeneralCategory.txt" => {
General_Category => {
Cn => 78,
Cn => 27,
},
},
# Many codepoints return XX instead of ID. These codepoints are undefined, but unicode
# spec has specified that they should regardless be ID
"LineBreak.txt" => {
Line_Break => {
ID => 72079,
ID => 66841,
PR => 16
}
}
Expand Down Expand Up @@ -53,7 +55,13 @@ sub test-file (IO::Path $folder is copy, Str:D $file-name, Str:D $uniprop, :$ans
correct($value, $_, $uniprop, $file-name);
}
else {
wrong($value, $_, $uniprop, $file-name);
if $*DEBUG {
my $actual = $call eq 'str' ?? nqp::getuniprop_str($_, $propcode) !! nqp::getuniprop_int($_, $propcode);
wrong($value, "cp $_ expected $value actually $actual", $uniprop, $file-name);
}
else {
wrong($value, $_, $uniprop, $file-name);
}
}
}
}
Expand All @@ -67,17 +75,17 @@ sub test-file (IO::Path $folder is copy, Str:D $file-name, Str:D $uniprop, :$ans
$has-tested = True;
%expected-loses{$file-name}{$uniprop}{$pvalue} = 0 if %expected-loses{$file-name}{$uniprop}:!exists or %expected-loses{$file-name}{$uniprop}{$pvalue}:!exists;
todo "Expecting %expected-loses{$file-name}{$uniprop}{$pvalue} failures from $uniprop=$pvalue", 1
if %expected-loses{$file-name}{$uniprop}{$pvalue} >= %LOSES{$file-name}{$uniprop}{$pvalue};
ok %LOSES{$file-name}{$uniprop}{$pvalue} < %expected-loses{$file-name}{$uniprop}{$pvalue},
if %LOSES{$file-name}{$uniprop}{$pvalue} < %expected-loses{$file-name}{$uniprop}{$pvalue};
ok %LOSES{$file-name}{$uniprop}{$pvalue} <= %expected-loses{$file-name}{$uniprop}{$pvalue},
format-test-text($uniprop, $file-name, %WINS{$file-name}{$uniprop}{$pvalue}, %LOSES{$file-name}{$uniprop}{$pvalue}, $pvalue, %expected-loses{$file-name}{$uniprop}{$pvalue});
}
for %expected-loses{$file-name}{$uniprop}.keys.sort -> $pvalue {
next if %LOSES{$file-name}{$uniprop}{$pvalue}:exists;
$has-tested = True;
%LOSES{$file-name}{$uniprop}{$pvalue} = 0 if %LOSES{$file-name}{$uniprop}{$pvalue}:!exists;
todo "Expecting %expected-loses{$file-name}{$uniprop}{$pvalue} failures from $uniprop=$pvalue", 1
if %expected-loses{$file-name}{$uniprop}{$pvalue} > %LOSES{$file-name}{$uniprop}{$pvalue};
ok(%LOSES{$file-name}{$uniprop}{$pvalue} < %expected-loses{$file-name}{$uniprop}{$pvalue},
if %LOSES{$file-name}{$uniprop}{$pvalue} < %expected-loses{$file-name}{$uniprop}{$pvalue};
ok(%LOSES{$file-name}{$uniprop}{$pvalue} <= %expected-loses{$file-name}{$uniprop}{$pvalue},
format-test-text($uniprop, $file-name,
%WINS{$file-name}{$uniprop}{$pvalue},
%LOSES{$file-name}{$uniprop}{$pvalue}, $pvalue,
Expand All @@ -87,17 +95,20 @@ sub test-file (IO::Path $folder is copy, Str:D $file-name, Str:D $uniprop, :$ans
ok True, format-test-text($uniprop, $file-name, %WIN-NUM{$file-name}{$uniprop}, %LOSE-NUM{$file-name}{$uniprop});
}
if $*DEBUG {
dd %FAILED{$file-name}{$uniprop};
#dd %LOSES{$file-name}{$uniprop};
#dd %WINS{$file-name}{$uniprop};
my @list = %FAILED{$file-name}{$uniprop}.list;
my @debug-out;
while @list {
@debug-out.push: @list.splice(0, 10).join(', ');
}
note "\%FAILED\{$file-name\}\{$uniprop\}:\n", @debug-out.join("\n").indent(4);
note "Property: $uniprop win %WIN-NUM{$file-name}{$uniprop} lose %LOSE-NUM{$file-name}{$uniprop} percent: " ~ (%LOSE-NUM{$file-name}{$uniprop} == 0 ?? 1 !! %LOSE-NUM{$file-name}{$uniprop}/%WIN-NUM{$file-name}{$uniprop}) * 100;
}
}
sub format-test-text ($uniprop, $file-name, $correct, $wrong, Str:D $pvalue = "", Int $looking-for?) {
"Property: $uniprop"
~ ($pvalue ?? "=$pvalue" !! "")
~ " from file: $file-name (Correct: $correct Wrong: $wrong)"
~ ($looking-for ?? ". Todo'd if <= $looking-for failures." !! "")
~ ($looking-for ?? ". Todo'd if < $looking-for failures." !! "")
}
sub ends-with (\a, \b) {
nqp::eqat(a, b, nqp::chars(a) - nqp::chars(b))
Expand Down

0 comments on commit 68196c9

Please sign in to comment.