From 0d651f74ce99c271fb8b5019eb689ab11550461a Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Mon, 27 Sep 2021 11:13:48 +0800 Subject: [PATCH] Extract expected result. --- README.md | 5 +++-- scripts/fibonacci.rhai | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f3cef610..e11cf72f 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ Below is the standard _Fibonacci_ example for scripting languages: const TARGET = 28; const REPEAT = 5; +const ANSWER = 317_811; fn fib(n) { if n < 2 { @@ -107,8 +108,8 @@ print(`Finished. Run time = ${now.elapsed} seconds.`); print(`Fibonacci number #${TARGET} = ${result}`); -if result != 317_811 { - print("The answer is WRONG! Should be 317,811!"); +if result != ANSWER { + print(`The answer is WRONG! Should be ${ANSWER}!`); } ``` diff --git a/scripts/fibonacci.rhai b/scripts/fibonacci.rhai index dac77d22..8451c477 100644 --- a/scripts/fibonacci.rhai +++ b/scripts/fibonacci.rhai @@ -3,6 +3,7 @@ const TARGET = 28; const REPEAT = 5; +const ANSWER = 317_811; fn fib(n) { if n < 2 { @@ -26,6 +27,6 @@ print(`Finished. Run time = ${now.elapsed} seconds.`); print(`Fibonacci number #${TARGET} = ${result}`); -if result != 317_811 { - print("The answer is WRONG! Should be 317,811!"); +if result != ANSWER { + print(`The answer is WRONG! Should be ${ANSWER}!`); }