Arrays (local) now work!
This commit is contained in:
@@ -10,6 +10,7 @@ fn run_forge(src: &str) -> CPU {
|
||||
cpu
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn compiler_output(src: &str) -> Vec<String> {
|
||||
forge_core::compiler::build_boot(src).unwrap()
|
||||
}
|
||||
@@ -102,6 +103,29 @@ fn recursion_test() {
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn array_test() {
|
||||
// Declare an array and do things
|
||||
assert_eq!(
|
||||
main_return(
|
||||
"fn sum(arr) {
|
||||
var i = 0;
|
||||
var s = 0;
|
||||
while (arr[i] != -1) {
|
||||
s = arr[i] + s;
|
||||
i = i + 1;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
fn main() {
|
||||
var a = new(5);
|
||||
a[0] = 1; a[1] = 3; a[2] = 5; a[3] = -1; a[4] = 10;
|
||||
return sum(a);
|
||||
}"),
|
||||
9
|
||||
)
|
||||
}
|
||||
|
||||
//#[test]
|
||||
// This is no longer cursed, or a test. The revised calling convention with the pool pointer makes
|
||||
// it now perfectly sane. Left here for posterity.
|
||||
|
||||
Reference in New Issue
Block a user