mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Began working on runner library
This commit is contained in:
12
test/scripts/compiler_sample_code.toy
Normal file
12
test/scripts/compiler_sample_code.toy
Normal file
@@ -0,0 +1,12 @@
|
||||
fn fib(n : int) {
|
||||
if (n < 2) {
|
||||
return n;
|
||||
}
|
||||
|
||||
return fib(n-1) + fib(n-2);
|
||||
}
|
||||
|
||||
for (var i = 0; i < 20; i++) {
|
||||
var res = fib(i);
|
||||
print string i + ": " + string res;
|
||||
}
|
||||
16
test/scripts/lib/runner.toy
Normal file
16
test/scripts/lib/runner.toy
Normal file
@@ -0,0 +1,16 @@
|
||||
import runner;
|
||||
|
||||
//test basic loading and freeing of code
|
||||
{
|
||||
var s = loadScript("scripts:/runner_sample_code.toy");
|
||||
|
||||
s.freeScript();
|
||||
}
|
||||
|
||||
//TODO: test running an external script
|
||||
//TODO: test resetting an external script
|
||||
//TODO: test retrieving a script variable
|
||||
//TODO: test calling a script function
|
||||
|
||||
|
||||
print "All good";
|
||||
12
test/scripts/parser_sample_code.toy
Normal file
12
test/scripts/parser_sample_code.toy
Normal file
@@ -0,0 +1,12 @@
|
||||
fn fib(n : int) {
|
||||
if (n < 2) {
|
||||
return n;
|
||||
}
|
||||
|
||||
return fib(n-1) + fib(n-2);
|
||||
}
|
||||
|
||||
for (var i = 0; i < 20; i++) {
|
||||
var res = fib(i);
|
||||
print string i + ": " + string res;
|
||||
}
|
||||
12
test/scripts/runner_sample_code.toy
Normal file
12
test/scripts/runner_sample_code.toy
Normal file
@@ -0,0 +1,12 @@
|
||||
fn fib(n : int) {
|
||||
if (n < 2) {
|
||||
return n;
|
||||
}
|
||||
|
||||
return fib(n-1) + fib(n-2);
|
||||
}
|
||||
|
||||
for (var i = 0; i < 20; i++) {
|
||||
var res = fib(i);
|
||||
print string i + ": " + string res;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
|
||||
|
||||
|
||||
var complex: type = astype [string: [int]];
|
||||
var deep: type = astype [[[ int ]]];
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user