mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Added a utility to call toy functions from C
This commit is contained in:
23
scripts/test/call-from-host.toy
Normal file
23
scripts/test/call-from-host.toy
Normal file
@@ -0,0 +1,23 @@
|
||||
//create a bunch of toy functions as literals to be called from C
|
||||
|
||||
fn answer() {
|
||||
return 42;
|
||||
}
|
||||
|
||||
fn identity(x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
fn makeCounter() {
|
||||
var total = 0;
|
||||
|
||||
fn counter() {
|
||||
return ++total;
|
||||
}
|
||||
|
||||
return counter;
|
||||
}
|
||||
|
||||
fn fail() {
|
||||
assert false, "Failed correctly";
|
||||
}
|
||||
Reference in New Issue
Block a user