mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-01-11 08:34:01 -05:00
chore: add tests for return values of a function (#634)
This commit is contained in:
parent
5927d6070c
commit
dcca57b986
1 changed files with 6 additions and 2 deletions
|
@ -1669,9 +1669,12 @@ fn function() {
|
|||
let lhs = function.creation_context(scope).global(scope);
|
||||
let rhs = context.global(scope);
|
||||
assert!(lhs.strict_equals(rhs.into()));
|
||||
function
|
||||
let value = function
|
||||
.call(scope, recv, &[])
|
||||
.expect("Function call failed");
|
||||
let value_str = value.to_string(scope).unwrap();
|
||||
let rust_str = value_str.to_rust_string_lossy(scope);
|
||||
assert_eq!(rust_str, "Hello callback!".to_string());
|
||||
|
||||
// create function without a template
|
||||
let function = v8::Function::new(scope, fn_callback2)
|
||||
|
@ -1691,9 +1694,10 @@ fn function() {
|
|||
.data(true_data.into())
|
||||
.build(scope)
|
||||
.expect("Unable to create function with data");
|
||||
function
|
||||
let value = function
|
||||
.call(scope, recv, &[])
|
||||
.expect("Function call failed");
|
||||
assert!(value.is_undefined());
|
||||
|
||||
// create a prototype-less function that throws on new
|
||||
let function = v8::Function::builder(fn_callback)
|
||||
|
|
Loading…
Reference in a new issue