Skip to content

Commit

Permalink
更新了crossbeam和parking_lot
Browse files Browse the repository at this point in the history
增加了关于js抛出异常的测试
  • Loading branch information
vmosone committed Jan 19, 2020
1 parent 02ee4fe commit 484e7c1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
28 changes: 28 additions & 0 deletions tests/test_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,34 @@ fn js_test_process_close(js: Arc<JS>, args: Vec<JSType>) -> Option<CallResult> {
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();
Expand Down

0 comments on commit 484e7c1

Please sign in to comment.