From 10cc5e6e89bd971ff604849a1582aa1dc4039566 Mon Sep 17 00:00:00 2001 From: nazrin Date: Sun, 1 Jun 2025 21:17:25 +0000 Subject: [PATCH] Add fib21 test --- test/all.d | 20 ++++++++++++++++++++ test/fib21.lox | 10 ++++++++++ 2 files changed, 30 insertions(+) create mode 100755 test/all.d create mode 100644 test/fib21.lox diff --git a/test/all.d b/test/all.d new file mode 100755 index 0000000..14ca0b7 --- /dev/null +++ b/test/all.d @@ -0,0 +1,20 @@ +#!/bin/env rdmd + +import std.process; +import std.conv; + +void main(){ + string fib21(){ + string r = ""; + double a = 0; + double temp; + for(double b = 1; a < 10000; b = temp + b){ + r ~= a.to!string ~ "\n"; + temp = a; + a = b; + } + return r; + } + assert([ "./lox", "test/fib21.lox" ].execute.output == fib21()); +} + diff --git a/test/fib21.lox b/test/fib21.lox new file mode 100644 index 0000000..534d25e --- /dev/null +++ b/test/fib21.lox @@ -0,0 +1,10 @@ + +var a = 0; +var temp; + +for(var b = 1; a < 10000; b = temp + b){ + print a; + temp = a; + a = b; +} +