use std::cell::Cell;
use crate::codemap::FileSpanRef;
use crate::environment::Globals;
use crate::environment::Module;
use crate::eval::Evaluator;
use crate::syntax::AstModule;
use crate::syntax::Dialect;
#[test]
fn before_stmt() {
let module = Module::new();
let globals = Globals::new();
let counter = Cell::new(0);
let before_stmt = |_span: FileSpanRef, _eval: &mut Evaluator<'_, '_, '_>| {
counter.set(counter.get() + 1);
};
let mut evaluator = Evaluator::new(&module);
evaluator.before_stmt_fn(&before_stmt);
let program = "\
x = 1 # 0 + 1
def f(): # 1 + 1
return x + 1 # 3
f() # 2 + 1
";
let ast = AstModule::parse("a.star", program.to_owned(), &Dialect::AllOptionsInternal).unwrap();
evaluator.eval_module(ast, &globals).unwrap();
assert_eq!(7, counter.get());
}