Fix scripts.
This commit is contained in:
parent
8da4c0c2b2
commit
c5128e15d5
@ -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
|
||||
```
|
||||
|
@ -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
|
||||
|
@ -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!");
|
||||
|
Loading…
Reference in New Issue
Block a user