Skip to content

Commit ad399db

Browse files
magicalcookieyouknowone
authored andcommitted
Add tested frozen module test
1 parent a3428a8 commit ad399db

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

vm/src/vm/mod.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,3 +823,30 @@ impl AsRef<Context> for VirtualMachine {
823823
&self.ctx
824824
}
825825
}
826+
827+
#[test]
828+
fn test_nested_frozen() {
829+
use rustpython_vm as vm;
830+
831+
vm::Interpreter::with_init(Default::default(), |vm| {
832+
// vm.add_native_modules(rustpython_stdlib::get_module_inits());
833+
vm.add_frozen(rustpython_vm::py_freeze!(dir = "../extra_tests/snippets"));
834+
})
835+
.enter(|vm| {
836+
let scope = vm.new_scope_with_builtins();
837+
838+
let code_obj = vm
839+
.compile(
840+
"from dir_module.dir_module_inner import value2",
841+
vm::compile::Mode::Exec,
842+
"<embedded>".to_owned(),
843+
)
844+
.map_err(|err| vm.new_syntax_error(&err))
845+
.unwrap();
846+
847+
if let Err(e) = vm.run_code_obj(code_obj, scope.clone()) {
848+
vm.print_exception(e.clone());
849+
assert!(false);
850+
}
851+
})
852+
}

0 commit comments

Comments
 (0)