diff --git a/scripts/README.md b/scripts/README.md index f3bf5b4a..d8a3bcb3 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -7,14 +7,8 @@ Testing scripts written in Rhai. How to Run ---------- -Compile the `rhai-run` example: +Run scripts using the `rhai-run` tool: -```bash -cargo build --example rhai-run -``` - -Run it: - -```bash -./target/debug/examples/rhai-run ./scripts/test_script_to_run.rhai +```sh +cargo run --bin rhai-run ./scripts/test_script_to_run.rhai ``` diff --git a/scripts/comments.rhai b/scripts/comments.rhai index dd3612fa..63b9f048 100644 --- a/scripts/comments.rhai +++ b/scripts/comments.rhai @@ -8,4 +8,4 @@ let /* I am a spy in a variable declaration! */ x = 5; /* look /* at /* that, /* multi-line */ comments */ can be */ nested */ -/* surrounded by */ this_is_not_a_comment = true // comments +/* surrounded by */ let this_is_not_a_comment = true // comments diff --git a/scripts/fibonacci.rhai b/scripts/fibonacci.rhai index fb40c64a..0787a350 100644 --- a/scripts/fibonacci.rhai +++ b/scripts/fibonacci.rhai @@ -1,7 +1,8 @@ // This script calculates the n-th Fibonacci number using a really dumb algorithm // to test the speed of the scripting engine. -const target = 28; +const TARGET = 28; +const REPEAT = 5; fn fib(n) { if n < 2 { @@ -11,19 +12,19 @@ fn fib(n) { } } -print("Running Fibonacci(28) x 5 times..."); +print(`Running Fibonacci(28) x ${REPEAT} times...`); print("Ready... Go!"); let result; let now = timestamp(); -for n in range(0, 5) { - result = fib(target); +for n in range(0, REPEAT) { + result = fib(TARGET); } print(`Finished. Run time = ${now.elapsed} seconds.`); -print(`Fibonacci number #${target} = ${result}`); +print(`Fibonacci number #${TARGET} = ${result}`); if result != 317_811 { print("The answer is WRONG! Should be 317,811!");