mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
Add cli test for false interpreter
This commit is contained in:
parent
0ca6a3d723
commit
b4be6da3a4
5 changed files with 103 additions and 11 deletions
|
@ -13,7 +13,7 @@ mod cli_run {
|
||||||
run_with_valgrind, ValgrindError, ValgrindErrorXWhat,
|
run_with_valgrind, ValgrindError, ValgrindErrorXWhat,
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
use std::path::Path;
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
use roc_collections::all::MutMap;
|
use roc_collections::all::MutMap;
|
||||||
|
@ -39,6 +39,7 @@ mod cli_run {
|
||||||
filename: &'a str,
|
filename: &'a str,
|
||||||
executable_filename: &'a str,
|
executable_filename: &'a str,
|
||||||
stdin: &'a [&'a str],
|
stdin: &'a [&'a str],
|
||||||
|
input_file: Option<&'a str>,
|
||||||
expected_ending: &'a str,
|
expected_ending: &'a str,
|
||||||
use_valgrind: bool,
|
use_valgrind: bool,
|
||||||
}
|
}
|
||||||
|
@ -48,6 +49,7 @@ mod cli_run {
|
||||||
stdin: &[&str],
|
stdin: &[&str],
|
||||||
executable_filename: &str,
|
executable_filename: &str,
|
||||||
flags: &[&str],
|
flags: &[&str],
|
||||||
|
input_file: Option<PathBuf>,
|
||||||
expected_ending: &str,
|
expected_ending: &str,
|
||||||
use_valgrind: bool,
|
use_valgrind: bool,
|
||||||
) {
|
) {
|
||||||
|
@ -59,10 +61,20 @@ mod cli_run {
|
||||||
assert!(compile_out.status.success(), "bad status {:?}", compile_out);
|
assert!(compile_out.status.success(), "bad status {:?}", compile_out);
|
||||||
|
|
||||||
let out = if use_valgrind && ALLOW_VALGRIND {
|
let out = if use_valgrind && ALLOW_VALGRIND {
|
||||||
let (valgrind_out, raw_xml) = run_with_valgrind(
|
let (valgrind_out, raw_xml) = if let Some(input_file) = input_file {
|
||||||
stdin,
|
run_with_valgrind(
|
||||||
&[file.with_file_name(executable_filename).to_str().unwrap()],
|
stdin,
|
||||||
);
|
&[
|
||||||
|
file.with_file_name(executable_filename).to_str().unwrap(),
|
||||||
|
input_file.to_str().unwrap(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
run_with_valgrind(
|
||||||
|
stdin,
|
||||||
|
&[file.with_file_name(executable_filename).to_str().unwrap()],
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
if valgrind_out.status.success() {
|
if valgrind_out.status.success() {
|
||||||
let memory_errors = extract_valgrind_errors(&raw_xml).unwrap_or_else(|err| {
|
let memory_errors = extract_valgrind_errors(&raw_xml).unwrap_or_else(|err| {
|
||||||
|
@ -100,11 +112,19 @@ mod cli_run {
|
||||||
|
|
||||||
valgrind_out
|
valgrind_out
|
||||||
} else {
|
} else {
|
||||||
run_cmd(
|
if let Some(input_file) = input_file {
|
||||||
file.with_file_name(executable_filename).to_str().unwrap(),
|
run_cmd(
|
||||||
stdin,
|
file.with_file_name(executable_filename).to_str().unwrap(),
|
||||||
&[],
|
stdin,
|
||||||
)
|
&[input_file.to_str().unwrap()],
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
run_cmd(
|
||||||
|
file.with_file_name(executable_filename).to_str().unwrap(),
|
||||||
|
stdin,
|
||||||
|
&[],
|
||||||
|
)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if !&out.stdout.ends_with(expected_ending) {
|
if !&out.stdout.ends_with(expected_ending) {
|
||||||
panic!(
|
panic!(
|
||||||
|
@ -121,8 +141,10 @@ mod cli_run {
|
||||||
stdin: &[&str],
|
stdin: &[&str],
|
||||||
executable_filename: &str,
|
executable_filename: &str,
|
||||||
flags: &[&str],
|
flags: &[&str],
|
||||||
|
input_file: Option<PathBuf>,
|
||||||
expected_ending: &str,
|
expected_ending: &str,
|
||||||
) {
|
) {
|
||||||
|
assert_eq!(input_file, None, "Wasm does not support input files");
|
||||||
let mut flags = flags.to_vec();
|
let mut flags = flags.to_vec();
|
||||||
flags.push("--backend=wasm32");
|
flags.push("--backend=wasm32");
|
||||||
|
|
||||||
|
@ -178,6 +200,7 @@ mod cli_run {
|
||||||
example.stdin,
|
example.stdin,
|
||||||
example.executable_filename,
|
example.executable_filename,
|
||||||
&[],
|
&[],
|
||||||
|
example.input_file.and_then(|file| Some(example_file(dir_name, file))),
|
||||||
example.expected_ending,
|
example.expected_ending,
|
||||||
example.use_valgrind,
|
example.use_valgrind,
|
||||||
);
|
);
|
||||||
|
@ -187,6 +210,7 @@ mod cli_run {
|
||||||
example.stdin,
|
example.stdin,
|
||||||
example.executable_filename,
|
example.executable_filename,
|
||||||
&["--optimize"],
|
&["--optimize"],
|
||||||
|
example.input_file.and_then(|file| Some(example_file(dir_name, file))),
|
||||||
example.expected_ending,
|
example.expected_ending,
|
||||||
example.use_valgrind,
|
example.use_valgrind,
|
||||||
);
|
);
|
||||||
|
@ -199,6 +223,7 @@ mod cli_run {
|
||||||
example.stdin,
|
example.stdin,
|
||||||
example.executable_filename,
|
example.executable_filename,
|
||||||
&["--roc-linker"],
|
&["--roc-linker"],
|
||||||
|
example.input_file.and_then(|file| Some(example_file(dir_name, file))),
|
||||||
example.expected_ending,
|
example.expected_ending,
|
||||||
example.use_valgrind,
|
example.use_valgrind,
|
||||||
);
|
);
|
||||||
|
@ -235,6 +260,7 @@ mod cli_run {
|
||||||
filename: "Hello.roc",
|
filename: "Hello.roc",
|
||||||
executable_filename: "hello-world",
|
executable_filename: "hello-world",
|
||||||
stdin: &[],
|
stdin: &[],
|
||||||
|
input_file: None,
|
||||||
expected_ending:"Hello, World!\n",
|
expected_ending:"Hello, World!\n",
|
||||||
use_valgrind: true,
|
use_valgrind: true,
|
||||||
},
|
},
|
||||||
|
@ -242,6 +268,7 @@ mod cli_run {
|
||||||
filename: "Hello.roc",
|
filename: "Hello.roc",
|
||||||
executable_filename: "hello-world",
|
executable_filename: "hello-world",
|
||||||
stdin: &[],
|
stdin: &[],
|
||||||
|
input_file: None,
|
||||||
expected_ending:"Hello, World!\n",
|
expected_ending:"Hello, World!\n",
|
||||||
use_valgrind: true,
|
use_valgrind: true,
|
||||||
},
|
},
|
||||||
|
@ -249,6 +276,7 @@ mod cli_run {
|
||||||
filename: "Hello.roc",
|
filename: "Hello.roc",
|
||||||
executable_filename: "hello-rust",
|
executable_filename: "hello-rust",
|
||||||
stdin: &[],
|
stdin: &[],
|
||||||
|
input_file: None,
|
||||||
expected_ending:"Hello, World!\n",
|
expected_ending:"Hello, World!\n",
|
||||||
use_valgrind: true,
|
use_valgrind: true,
|
||||||
},
|
},
|
||||||
|
@ -256,6 +284,7 @@ mod cli_run {
|
||||||
filename: "Hello.roc",
|
filename: "Hello.roc",
|
||||||
executable_filename: "hello-web",
|
executable_filename: "hello-web",
|
||||||
stdin: &[],
|
stdin: &[],
|
||||||
|
input_file: None,
|
||||||
expected_ending:"Hello, World!\n",
|
expected_ending:"Hello, World!\n",
|
||||||
use_valgrind: true,
|
use_valgrind: true,
|
||||||
},
|
},
|
||||||
|
@ -263,6 +292,7 @@ mod cli_run {
|
||||||
filename: "Fib.roc",
|
filename: "Fib.roc",
|
||||||
executable_filename: "fib",
|
executable_filename: "fib",
|
||||||
stdin: &[],
|
stdin: &[],
|
||||||
|
input_file: None,
|
||||||
expected_ending:"55\n",
|
expected_ending:"55\n",
|
||||||
use_valgrind: true,
|
use_valgrind: true,
|
||||||
},
|
},
|
||||||
|
@ -270,6 +300,7 @@ mod cli_run {
|
||||||
filename: "Quicksort.roc",
|
filename: "Quicksort.roc",
|
||||||
executable_filename: "quicksort",
|
executable_filename: "quicksort",
|
||||||
stdin: &[],
|
stdin: &[],
|
||||||
|
input_file: None,
|
||||||
expected_ending: "[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n",
|
expected_ending: "[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n",
|
||||||
use_valgrind: true,
|
use_valgrind: true,
|
||||||
},
|
},
|
||||||
|
@ -277,6 +308,7 @@ mod cli_run {
|
||||||
// filename: "Quicksort.roc",
|
// filename: "Quicksort.roc",
|
||||||
// executable_filename: "quicksort",
|
// executable_filename: "quicksort",
|
||||||
// stdin: &[],
|
// stdin: &[],
|
||||||
|
// input_file: None,
|
||||||
// expected_ending: "[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n",
|
// expected_ending: "[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n",
|
||||||
// use_valgrind: true,
|
// use_valgrind: true,
|
||||||
// },
|
// },
|
||||||
|
@ -284,6 +316,7 @@ mod cli_run {
|
||||||
filename: "Main.roc",
|
filename: "Main.roc",
|
||||||
executable_filename: "effect-example",
|
executable_filename: "effect-example",
|
||||||
stdin: &["hi there!"],
|
stdin: &["hi there!"],
|
||||||
|
input_file: None,
|
||||||
expected_ending: "hi there!\nIt is known\n",
|
expected_ending: "hi there!\nIt is known\n",
|
||||||
use_valgrind: true,
|
use_valgrind: true,
|
||||||
},
|
},
|
||||||
|
@ -291,6 +324,7 @@ mod cli_run {
|
||||||
// filename: "Main.roc",
|
// filename: "Main.roc",
|
||||||
// executable_filename: "tea-example",
|
// executable_filename: "tea-example",
|
||||||
// stdin: &[],
|
// stdin: &[],
|
||||||
|
// input_file: None,
|
||||||
// expected_ending: "",
|
// expected_ending: "",
|
||||||
// use_valgrind: true,
|
// use_valgrind: true,
|
||||||
// },
|
// },
|
||||||
|
@ -298,6 +332,7 @@ mod cli_run {
|
||||||
filename: "Echo.roc",
|
filename: "Echo.roc",
|
||||||
executable_filename: "echo",
|
executable_filename: "echo",
|
||||||
stdin: &["Giovanni\n", "Giorgio\n"],
|
stdin: &["Giovanni\n", "Giorgio\n"],
|
||||||
|
input_file: None,
|
||||||
expected_ending: "Hi, Giovanni Giorgio!\n",
|
expected_ending: "Hi, Giovanni Giorgio!\n",
|
||||||
use_valgrind: true,
|
use_valgrind: true,
|
||||||
},
|
},
|
||||||
|
@ -305,6 +340,7 @@ mod cli_run {
|
||||||
// filename: "Main.roc",
|
// filename: "Main.roc",
|
||||||
// executable_filename: "custom-malloc-example",
|
// executable_filename: "custom-malloc-example",
|
||||||
// stdin: &[],
|
// stdin: &[],
|
||||||
|
// input_file: None,
|
||||||
// expected_ending: "ms!\nThe list was small!\n",
|
// expected_ending: "ms!\nThe list was small!\n",
|
||||||
// use_valgrind: true,
|
// use_valgrind: true,
|
||||||
// },
|
// },
|
||||||
|
@ -312,9 +348,20 @@ mod cli_run {
|
||||||
// filename: "Main.roc",
|
// filename: "Main.roc",
|
||||||
// executable_filename: "task-example",
|
// executable_filename: "task-example",
|
||||||
// stdin: &[],
|
// stdin: &[],
|
||||||
|
// input_file: None,
|
||||||
// expected_ending: "successfully wrote to file\n",
|
// expected_ending: "successfully wrote to file\n",
|
||||||
// use_valgrind: true,
|
// use_valgrind: true,
|
||||||
// },
|
// },
|
||||||
|
false_interpreter:"false-interpreter" => {
|
||||||
|
Example {
|
||||||
|
filename: "False.roc",
|
||||||
|
executable_filename: "false",
|
||||||
|
stdin: &[],
|
||||||
|
input_file: Some("examples/hello.false"),
|
||||||
|
expected_ending:"Hello, World!\n",
|
||||||
|
use_valgrind: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! benchmarks {
|
macro_rules! benchmarks {
|
||||||
|
@ -341,6 +388,7 @@ mod cli_run {
|
||||||
benchmark.stdin,
|
benchmark.stdin,
|
||||||
benchmark.executable_filename,
|
benchmark.executable_filename,
|
||||||
&[],
|
&[],
|
||||||
|
benchmark.input_file.and_then(|file| Some(examples_dir("benchmarks").join(file))),
|
||||||
benchmark.expected_ending,
|
benchmark.expected_ending,
|
||||||
benchmark.use_valgrind,
|
benchmark.use_valgrind,
|
||||||
);
|
);
|
||||||
|
@ -350,6 +398,7 @@ mod cli_run {
|
||||||
benchmark.stdin,
|
benchmark.stdin,
|
||||||
benchmark.executable_filename,
|
benchmark.executable_filename,
|
||||||
&["--optimize"],
|
&["--optimize"],
|
||||||
|
benchmark.input_file.and_then(|file| Some(examples_dir("benchmarks").join(file))),
|
||||||
benchmark.expected_ending,
|
benchmark.expected_ending,
|
||||||
benchmark.use_valgrind,
|
benchmark.use_valgrind,
|
||||||
);
|
);
|
||||||
|
@ -382,6 +431,7 @@ mod cli_run {
|
||||||
benchmark.stdin,
|
benchmark.stdin,
|
||||||
benchmark.executable_filename,
|
benchmark.executable_filename,
|
||||||
&[],
|
&[],
|
||||||
|
benchmark.input_file.and_then(|file| Some(examples_dir("benchmarks").join(file))),
|
||||||
benchmark.expected_ending,
|
benchmark.expected_ending,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -390,6 +440,7 @@ mod cli_run {
|
||||||
benchmark.stdin,
|
benchmark.stdin,
|
||||||
benchmark.executable_filename,
|
benchmark.executable_filename,
|
||||||
&["--optimize"],
|
&["--optimize"],
|
||||||
|
benchmark.input_file.and_then(|file| Some(examples_dir("benchmarks").join(file))),
|
||||||
benchmark.expected_ending,
|
benchmark.expected_ending,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -421,6 +472,7 @@ mod cli_run {
|
||||||
benchmark.stdin,
|
benchmark.stdin,
|
||||||
benchmark.executable_filename,
|
benchmark.executable_filename,
|
||||||
&["--backend=x86_32"],
|
&["--backend=x86_32"],
|
||||||
|
benchmark.input_file.and_then(|file| Some(examples_dir("benchmarks").join(file))),
|
||||||
benchmark.expected_ending,
|
benchmark.expected_ending,
|
||||||
benchmark.use_valgrind,
|
benchmark.use_valgrind,
|
||||||
);
|
);
|
||||||
|
@ -430,6 +482,7 @@ mod cli_run {
|
||||||
benchmark.stdin,
|
benchmark.stdin,
|
||||||
benchmark.executable_filename,
|
benchmark.executable_filename,
|
||||||
&["--backend=x86_32", "--optimize"],
|
&["--backend=x86_32", "--optimize"],
|
||||||
|
benchmark.input_file.and_then(|file| Some(examples_dir("benchmarks").join(file))),
|
||||||
benchmark.expected_ending,
|
benchmark.expected_ending,
|
||||||
benchmark.use_valgrind,
|
benchmark.use_valgrind,
|
||||||
);
|
);
|
||||||
|
@ -458,6 +511,7 @@ mod cli_run {
|
||||||
filename: "NQueens.roc",
|
filename: "NQueens.roc",
|
||||||
executable_filename: "nqueens",
|
executable_filename: "nqueens",
|
||||||
stdin: &["6"],
|
stdin: &["6"],
|
||||||
|
input_file: None,
|
||||||
expected_ending: "4\n",
|
expected_ending: "4\n",
|
||||||
use_valgrind: true,
|
use_valgrind: true,
|
||||||
},
|
},
|
||||||
|
@ -465,6 +519,7 @@ mod cli_run {
|
||||||
filename: "CFold.roc",
|
filename: "CFold.roc",
|
||||||
executable_filename: "cfold",
|
executable_filename: "cfold",
|
||||||
stdin: &["3"],
|
stdin: &["3"],
|
||||||
|
input_file: None,
|
||||||
expected_ending: "11 & 11\n",
|
expected_ending: "11 & 11\n",
|
||||||
use_valgrind: true,
|
use_valgrind: true,
|
||||||
},
|
},
|
||||||
|
@ -472,6 +527,7 @@ mod cli_run {
|
||||||
filename: "Deriv.roc",
|
filename: "Deriv.roc",
|
||||||
executable_filename: "deriv",
|
executable_filename: "deriv",
|
||||||
stdin: &["2"],
|
stdin: &["2"],
|
||||||
|
input_file: None,
|
||||||
expected_ending: "1 count: 6\n2 count: 22\n",
|
expected_ending: "1 count: 6\n2 count: 22\n",
|
||||||
use_valgrind: true,
|
use_valgrind: true,
|
||||||
},
|
},
|
||||||
|
@ -479,6 +535,7 @@ mod cli_run {
|
||||||
filename: "RBTreeCk.roc",
|
filename: "RBTreeCk.roc",
|
||||||
executable_filename: "rbtree-ck",
|
executable_filename: "rbtree-ck",
|
||||||
stdin: &["100"],
|
stdin: &["100"],
|
||||||
|
input_file: None,
|
||||||
expected_ending: "10\n",
|
expected_ending: "10\n",
|
||||||
use_valgrind: true,
|
use_valgrind: true,
|
||||||
},
|
},
|
||||||
|
@ -486,6 +543,7 @@ mod cli_run {
|
||||||
filename: "RBTreeInsert.roc",
|
filename: "RBTreeInsert.roc",
|
||||||
executable_filename: "rbtree-insert",
|
executable_filename: "rbtree-insert",
|
||||||
stdin: &[],
|
stdin: &[],
|
||||||
|
input_file: None,
|
||||||
expected_ending: "Node Black 0 {} Empty Empty\n",
|
expected_ending: "Node Black 0 {} Empty Empty\n",
|
||||||
use_valgrind: true,
|
use_valgrind: true,
|
||||||
},
|
},
|
||||||
|
@ -493,6 +551,7 @@ mod cli_run {
|
||||||
// filename: "RBTreeDel.roc",
|
// filename: "RBTreeDel.roc",
|
||||||
// executable_filename: "rbtree-del",
|
// executable_filename: "rbtree-del",
|
||||||
// stdin: &["420"],
|
// stdin: &["420"],
|
||||||
|
// input_file: None,
|
||||||
// expected_ending: "30\n",
|
// expected_ending: "30\n",
|
||||||
// use_valgrind: true,
|
// use_valgrind: true,
|
||||||
// },
|
// },
|
||||||
|
@ -500,6 +559,7 @@ mod cli_run {
|
||||||
filename: "TestAStar.roc",
|
filename: "TestAStar.roc",
|
||||||
executable_filename: "test-astar",
|
executable_filename: "test-astar",
|
||||||
stdin: &[],
|
stdin: &[],
|
||||||
|
input_file: None,
|
||||||
expected_ending: "True\n",
|
expected_ending: "True\n",
|
||||||
use_valgrind: false,
|
use_valgrind: false,
|
||||||
},
|
},
|
||||||
|
@ -507,6 +567,7 @@ mod cli_run {
|
||||||
filename: "TestBase64.roc",
|
filename: "TestBase64.roc",
|
||||||
executable_filename: "test-base64",
|
executable_filename: "test-base64",
|
||||||
stdin: &[],
|
stdin: &[],
|
||||||
|
input_file: None,
|
||||||
expected_ending: "encoded: SGVsbG8gV29ybGQ=\ndecoded: Hello World\n",
|
expected_ending: "encoded: SGVsbG8gV29ybGQ=\ndecoded: Hello World\n",
|
||||||
use_valgrind: true,
|
use_valgrind: true,
|
||||||
},
|
},
|
||||||
|
@ -514,6 +575,7 @@ mod cli_run {
|
||||||
filename: "Closure.roc",
|
filename: "Closure.roc",
|
||||||
executable_filename: "closure",
|
executable_filename: "closure",
|
||||||
stdin: &[],
|
stdin: &[],
|
||||||
|
input_file: None,
|
||||||
expected_ending: "",
|
expected_ending: "",
|
||||||
use_valgrind: true,
|
use_valgrind: true,
|
||||||
},
|
},
|
||||||
|
@ -521,6 +583,7 @@ mod cli_run {
|
||||||
filename: "QuicksortApp.roc",
|
filename: "QuicksortApp.roc",
|
||||||
executable_filename: "quicksortapp",
|
executable_filename: "quicksortapp",
|
||||||
stdin: &[],
|
stdin: &[],
|
||||||
|
input_file: None,
|
||||||
expected_ending: "todo put the correct quicksort answer here",
|
expected_ending: "todo put the correct quicksort answer here",
|
||||||
use_valgrind: true,
|
use_valgrind: true,
|
||||||
},
|
},
|
||||||
|
@ -600,6 +663,7 @@ mod cli_run {
|
||||||
&[],
|
&[],
|
||||||
"multi-dep-str",
|
"multi-dep-str",
|
||||||
&[],
|
&[],
|
||||||
|
None,
|
||||||
"I am Dep2.str2\n",
|
"I am Dep2.str2\n",
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
@ -613,6 +677,7 @@ mod cli_run {
|
||||||
&[],
|
&[],
|
||||||
"multi-dep-str",
|
"multi-dep-str",
|
||||||
&["--optimize"],
|
&["--optimize"],
|
||||||
|
None,
|
||||||
"I am Dep2.str2\n",
|
"I am Dep2.str2\n",
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
@ -626,6 +691,7 @@ mod cli_run {
|
||||||
&[],
|
&[],
|
||||||
"multi-dep-thunk",
|
"multi-dep-thunk",
|
||||||
&[],
|
&[],
|
||||||
|
None,
|
||||||
"I am Dep2.value2\n",
|
"I am Dep2.value2\n",
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
@ -639,6 +705,7 @@ mod cli_run {
|
||||||
&[],
|
&[],
|
||||||
"multi-dep-thunk",
|
"multi-dep-thunk",
|
||||||
&["--optimize"],
|
&["--optimize"],
|
||||||
|
None,
|
||||||
"I am Dep2.value2\n",
|
"I am Dep2.value2\n",
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
|
@ -5,8 +5,16 @@ authors = ["The Roc Contributors"]
|
||||||
license = "UPL-1.0"
|
license = "UPL-1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
links = "app"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["staticlib"]
|
name = "host"
|
||||||
|
path = "src/lib.rs"
|
||||||
|
crate-type = ["staticlib", "rlib"]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "host"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
roc_std = { path = "../../../roc_std" }
|
roc_std = { path = "../../../roc_std" }
|
||||||
|
|
4
examples/false-interpreter/platform/build.rs
Normal file
4
examples/false-interpreter/platform/build.rs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
fn main() {
|
||||||
|
println!("cargo:rustc-link-lib=dylib=app");
|
||||||
|
println!("cargo:rustc-link-search=.");
|
||||||
|
}
|
|
@ -62,6 +62,16 @@ pub unsafe fn roc_panic(c_ptr: *mut c_void, tag_id: u32) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn roc_memcpy(dst: *mut c_void, src: *mut c_void, n: usize) -> *mut c_void {
|
||||||
|
libc::memcpy(dst, src, n)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn roc_memset(dst: *mut c_void, c: i32, n: usize) -> *mut c_void {
|
||||||
|
libc::memset(dst, c, n)
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn rust_main() -> i32 {
|
pub fn rust_main() -> i32 {
|
||||||
let arg = env::args().skip(1).next().unwrap();
|
let arg = env::args().skip(1).next().unwrap();
|
||||||
|
|
3
examples/false-interpreter/platform/src/main.rs
Normal file
3
examples/false-interpreter/platform/src/main.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
fn main() {
|
||||||
|
std::process::exit(host::rust_main());
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue