Skip to content

Instantly share code, notes, and snippets.

@samcv
Created May 10, 2017 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samcv/4f6da1fd8353ac59cd74771ef31a739d to your computer and use it in GitHub Desktop.
Save samcv/4f6da1fd8353ac59cd74771ef31a739d to your computer and use it in GitHub Desktop.
--- t/spec/S15-nfg/GraphemeBreakTest.t 2017-05-10 14:45:43.441677575 -0700
+++ t/spec/S15-nfg/GraphemeBreakTest.rakudo.moar 2017-05-10 14:45:47.998310047 -0700
@@ -55,69 +55,6 @@
}
class parser {
has @!ord-array;
- method TOP ($/) {
- my @list = $/.caps;
- my @stack;
- my @results;
- note $/ if $DEBUG;
- sub move-from-stack {
- if @stack {
- @results[@results.elems].append: @stack;
- @stack = [];
- }
- }
- for @list {
- if .key eq 'nobreak' {
- say 'nobreak' if $DEBUG;
- }
- elsif .key eq 'break' {
- note 'break' if $DEBUG;
- move-from-stack;
- }
- elsif .key eq 'hex' {
- @stack.push: :16(~.value);
- }
- }
- my $string = @results».List.flat.chrs;
- move-from-stack;
- note @results.perl if $DEBUG;
- make {
- string => $string,
- ord-array => @results
- }
- }
-}
-sub process-line (Str:D $line, @fail, :@only!) {
- state $line-no = 0;
- $line-no++;
- return if @only and $line-no ne @only.any;
- return if $line.starts-with('#');
- my Bool:D $fudge-b = %fudged-tests{$line-no}:exists ?? True !! False;
- note 'LINE: [' ~ $line ~ ']' if $DEBUG;
- my $list = GraphemeBreakTest.new.parse(
- $line,
- actions => parser.new
- ).made;
- die "line $line-no undefined parse" if $list.defined.not;
- if $fudge-b {
- # fudge is either set to ALL or set to 'C01234' woudl fudge character test
- # and graphemes 0 through 4. _01__4 would fudge character test, and graphemes 2 and 3
- if %fudged-tests{$line-no}.any eq 'ALL' {
- todo("line $line-no todo for {%fudged-tests{$line-no}.Str} tests", 1 + $list<ord-array>.elems);
- $fudge-b = False; # We already have todo'd don't attempt again
- }
- }
- is-deeply $list<ord-array>.elems, $list<string>.chars, "Line $line-no: right num of chars | {$list<string>.uninames.perl}" or @fail.push($line-no);
- for ^$list<ord-array>.elems -> $elem {
- if $fudge-b {
- # 6th index of fudge string <=> 5th string index (6th character)
- if %fudged-tests{$line-no}.chars < $elem {
- #don't check
- }
- else {
- todo "$elem grapheme line $line-no todo" if %fudged-tests{$line-no}.any eq $elem;
- }
- }
- is-deeply $list<string>.substr($elem, 1).ords.flat, $list<ord-array>[$elem].flat, "Line $line-no: grapheme $elem has correct codepoints" or @fail.push($line-no);
- }
-}
\ No newline at end of file
+
+say "# FUDGED!";
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment