#!/usr/bin/perl -w use strict; sub chk_repr ($) { my ($p) = @_; print "assert_eq($p, Bigfloats.pack(Bigfloats.unpack($p as any)));\n"; } my $sre = qr{\"[^"]+\"}; print <) { next unless m/^mod test/..0; my $l = $_; $l =~ s{bf\(($sre)\)}{ chk_repr($1) }ge; if (m{^ +fn addition}..m{^ +\#\[test\]}) { if (m{^ +mk\(($sre)\)}) { print "mk = $1;\n"; } elsif (m{^ +\.chk\((\w+),\s*($sre)\)\s*$}) { print "mk = Bigfloats.add(mk, $1); assert_eq(mk, $2);\n"; } } }