mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 21:50:00 -05:00
feat(core): native binding names (#12290)
Makes native builtin functions easier to recognize when debugging/profiling, they would otherwise appear as "(anonymous)" functions
This commit is contained in:
parent
678a881f63
commit
22328f8758
2 changed files with 15 additions and 0 deletions
|
@ -180,6 +180,7 @@ pub fn set_func(
|
|||
let key = v8::String::new(scope, name).unwrap();
|
||||
let tmpl = v8::FunctionTemplate::new(scope, callback);
|
||||
let val = tmpl.get_function(scope).unwrap();
|
||||
val.set_name(key);
|
||||
obj.set(scope, key.into(), val.into());
|
||||
}
|
||||
|
||||
|
|
|
@ -2303,4 +2303,18 @@ assertEquals(1, notify_return_value);
|
|||
let all_true = v8::Local::<v8::Value>::new(&mut scope, &all_true);
|
||||
assert!(all_true.is_true());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_binding_names() {
|
||||
let mut runtime = JsRuntime::new(RuntimeOptions::default());
|
||||
let all_true: v8::Global<v8::Value> = runtime
|
||||
.execute_script(
|
||||
"binding_names.js",
|
||||
"Deno.core.encode.toString() === 'function encode() { [native code] }'",
|
||||
)
|
||||
.unwrap();
|
||||
let mut scope = runtime.handle_scope();
|
||||
let all_true = v8::Local::<v8::Value>::new(&mut scope, &all_true);
|
||||
assert!(all_true.is_true());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue