From: Ian Jackson Date: Mon, 5 Oct 2020 19:10:25 +0000 (+0100) Subject: addition tests copy X-Git-Tag: otter-0.2.0~736 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=630937c39288e3dbed46c1f8714e458616931e95;p=otter.git addition tests copy Signed-off-by: Ian Jackson --- diff --git a/extract-bf-tests b/extract-bf-tests index 492f3011..c13dda73 100755 --- a/extract-bf-tests +++ b/extract-bf-tests @@ -8,9 +8,21 @@ sub chk_repr ($) { 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"; + } + } } diff --git a/templates/bigfloat.ts b/templates/bigfloat.ts index 790dc5dd..a9b07b56 100644 --- a/templates/bigfloat.ts +++ b/templates/bigfloat.ts @@ -146,7 +146,7 @@ namespace Bigfloats { export function add(p: Bigfloat, step: number): Bigfloat { let v = unpack(p); - add_to_limb(v, 0, step * 0x10000); + add_to_limb(v, v.exponent, step * 0x10000); return pack(v); }