diff --git a/Cargo.toml b/Cargo.toml index 1870ea3..1feb577 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,8 +8,8 @@ libc = "0.2" rand = "0.6" lazy_static = "1.3" kernel32-sys = "0.2" -crossbeam-channel = "0.3" -parking_lot = "0.9" +crossbeam-channel = "0.4" +parking_lot = "0.10" log = "0.4" flame = "0.2" flamer = "0.3" diff --git a/tests/test_vm.rs b/tests/test_vm.rs index e289ab4..a0d31cc 100644 --- a/tests/test_vm.rs +++ b/tests/test_vm.rs @@ -773,6 +773,34 @@ fn js_test_process_close(js: Arc, args: Vec) -> Option { Some(CallResult::Ok) } +#[test] +fn test_catch_execption() { + env_logger::builder() + .format_timestamp_millis() + .init(); + TIMER.run(); + TASK_POOL_TIMER.run(); + let worker_pool = Box::new(WorkerPool::new("js test".to_string(), WorkerType::Js, 8, 1024 * 1024, 30000, JS_WORKER_WALKER.clone())); + worker_pool.run(JS_TASK_POOL.clone()); + set_max_alloced_limit(1073741824); + set_vm_timeout(30000); + + let auth = Arc::new(NativeObjsAuth::new(None, None)); + let opts = JS::new(1, Atom::from("test vm"), auth.clone(), None); + assert!(opts.is_some()); + let js = opts.unwrap(); + let opts = js.compile("test_catch_execption.js".to_string(), "try { throw new Error(\"test execption\"); } catch(e) { console.log(\"e:\", e.stack); throw e;}".to_string()); + assert!(opts.is_some()); + let code = opts.unwrap(); + + if let Some(vm) = JS::new(3, Atom::from("test catch execption"), auth.clone(), None) { + if vm.load(&code) { + println!("!!!!!!vm load ok"); + thread::sleep(Duration::from_millis(3000)); + } + } +} + #[test] fn test_vm_collect() { let mut rng = SmallRng::from_entropy();