Add DebuggingPackage.

This commit is contained in:
Stephen Chung
2022-01-25 14:32:42 +08:00
parent 0e5f62574d
commit aee35e5f20
5 changed files with 121 additions and 0 deletions

34
tests/debugging.rs Normal file
View File

@@ -0,0 +1,34 @@
#![cfg(feature = "debugging")]
use rhai::{Engine, EvalAltResult, INT};
#[cfg(not(feature = "no_index"))]
use rhai::Array;
#[test]
fn test_debugging() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new();
#[cfg(not(feature = "no_function"))]
#[cfg(not(feature = "no_index"))]
{
let r = engine.eval::<Array>(
"
fn foo(x) {
if x >= 5 {
stack_trace()
} else {
foo(x+1)
}
}
foo(0)
",
)?;
assert_eq!(r.len(), 6);
assert_eq!(engine.eval::<INT>("len(stack_trace())")?, 0);
}
Ok(())
}