From d19f9ddb866ac2415cbfe66966897a8efe8ddb63 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Fri, 16 Oct 2026 20:53:55 +0800 Subject: test(compiler): add seeded C++ differential tests across seven groups Generate 10000 random records per group plus boundary inputs using a portable SHA-256 stream. Compare native and runner output independently. Co-Authored-By: Claude Fable 5.1 --- tests/ii/Random.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/ii/Random.pm (limited to 'tests/ii/Random.pm') diff --git a/tests/ii/Random.pm b/tests/ii/Random.pm new file mode 100644 index 0000000..a7a95e5 --- /dev/null +++ b/tests/ii/Random.pm @@ -0,0 +1,25 @@ +package Random; +use strict; +use warnings; +use Digest::SHA qw(sha256); + +# Fixed byte order and decimal counter: independent of Perl's rand and hash seed. +sub new { + my ($class, $seed, $group) = @_; + return bless { seed => $seed, group => $group, counter => 0 }, $class; +} +sub integer { + my ($self, $low, $high) = @_; + die "invalid random range\n" if $high < $low || $high - $low >= 4294967296; + my $bytes = sha256($self->{seed} . "\0" . $self->{group} . "\0" . $self->{counter}++); + return $low + unpack('N', substr($bytes, 0, 4)) % ($high - $low + 1); +} +sub emit { + my ($self, $count, $edges, $make) = @_; + die "positive count required\n" unless defined($count) && $count =~ /^[1-9][0-9]*$/; + binmode STDOUT; # Identical input bytes on every platform. + print scalar(@$edges) + $count, "\n"; + print "$_\n" for @$edges; + print $make->(), "\n" for 1 .. $count; +} +1; -- cgit v1.3.1-4-g156e