Feat: script execution performance optimization
This commit is contained in:
@@ -55,13 +55,13 @@ pub fn forth_seeded(seed: u64) -> Forth {
|
||||
}
|
||||
|
||||
pub fn run(script: &str) -> Forth {
|
||||
let f = forth();
|
||||
let mut f = forth();
|
||||
f.evaluate(script, &default_ctx()).unwrap();
|
||||
f
|
||||
}
|
||||
|
||||
pub fn run_ctx(script: &str, ctx: &StepContext) -> Forth {
|
||||
let f = forth();
|
||||
let mut f = forth();
|
||||
f.evaluate(script, ctx).unwrap();
|
||||
f
|
||||
}
|
||||
@@ -124,7 +124,7 @@ pub fn expect_floats_close(script: &str, expected: f64, epsilon: f64) {
|
||||
}
|
||||
|
||||
pub fn expect_error(script: &str, expected_substr: &str) {
|
||||
let f = forth();
|
||||
let mut f = forth();
|
||||
let result = f.evaluate(script, &default_ctx());
|
||||
assert!(result.is_err(), "expected error for '{}'", script);
|
||||
let err = result.unwrap_err();
|
||||
@@ -137,14 +137,14 @@ pub fn expect_error(script: &str, expected_substr: &str) {
|
||||
}
|
||||
|
||||
pub fn expect_outputs(script: &str, count: usize) -> Vec<String> {
|
||||
let f = forth();
|
||||
let mut f = forth();
|
||||
let outputs = f.evaluate(script, &default_ctx()).unwrap();
|
||||
assert_eq!(outputs.len(), count, "expected {} outputs", count);
|
||||
outputs
|
||||
}
|
||||
|
||||
pub fn run_with_trace(script: &str) -> (Forth, ExecutionTrace) {
|
||||
let f = forth();
|
||||
let mut f = forth();
|
||||
let mut trace = ExecutionTrace::default();
|
||||
f.evaluate_with_trace(script, &default_ctx(), &mut trace)
|
||||
.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user