use Test;
plan 4;

use lib $*PROGRAM.parent.add('lib');
use Rainbow;
use HtmlHighlight;

my $data-dir = $*PROGRAM.parent.add('test-data');

my @test-data =
    'rakudoc-lang', 'rakudoc-lang.html',   -> $s { Rainbow::tokenize-rakudoc($s) },
    'regex-lang',   'regex-lang.html',     -> $s { Rainbow::tokenize-regex($s) },
    'string-lang',  'string-lang.html',    -> $s { Rainbow::tokenize-string($s) },
    'string-lang',  'string-lang-ah.html', -> $s { Rainbow::tokenize-string($s, :a, :h) },
;

for @test-data -> $file, $html, &make-token {
    my $input-file = $data-dir.add: $file;
    my $expect-file = $data-dir.add: $html;
    my @tokens = make-token($input-file.IO.slurp);
    my $generated = HtmlHighlight::make-html(@tokens, $input-file.basename);
    my $expected = $expect-file.slurp;
#    $expect-file.spurt: $generated;
    ok $generated eq $expected, "$input-file";
}
