Permalink
Browse files

Add concatenation tests for NFC to ensure concat is safe.

This commit was prompted by the improvements in logic when concatenating
strings in MoarVM. The logic on whether a string needs to be
renormalized when concat'd was improved. These tests were added to ensure
that the improvements did not cause any breakage with things that change
under NFC.

Luckily the MoarVM changes pass all the new tests. These tests will be useful
to have as concatenation is further worked on.
  • Loading branch information...
samcv committed Jul 13, 2017
1 parent ccef1af commit 88635564e5377757514b36be6867eb028e765a4d
Showing with 21 additions and 3 deletions.
  1. +21 −3 S15-normalization/test-gen.p6
@@ -41,11 +41,26 @@ use v6;
use Test;
plan @source.elems();
plan {$method eq 'NFC' ?? @source.elems * 2 !! @source.elems};
HEADER
if $method eq 'NFC' {
.say('my @list; my @result;');
}
for flat @source Z @expected -> $s, $e {
.say: "ok Uni.new(&hexy($s)).$method.list ~~ (&hexy($e),), '$s -> $e';";
if $method eq 'NFC' {
my @list = hexy-unjoined($s);
my $list-joined = @list.join(', ');
my $result-joined = &hexy($e);
.say("\@list = $list-joined; \@result = $result-joined; ");
.say((
"ok all(((Uni.new("
~ '@list[0..($_ - 1)]'
~ ') ~ Uni.new('
~ '@list[$_..*]'
~ ")).$method.list ~~ \@result " ~ "for 1..(\@list-1))), '$s -> $e CONCAT';"
));
}
}
.close;
@@ -89,5 +104,8 @@ HEADER
}
sub hexy($codes) {
$codes.split(' ').map('0x' ~ *).join(', ')
hexy-unjoined($codes).join(', ')
}
sub hexy-unjoined($codes) {
$codes.split(' ').map('0x' ~ *);
}

0 comments on commit 8863556

Please sign in to comment.