1
0
Fork 0
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:
Aaron O'Mullan 2021-10-05 22:55:51 +02:00 committed by GitHub
parent 678a881f63
commit 22328f8758
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View file

@ -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());
}

View file

@ -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());
}
}