0
0
Fork 0
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:
Kohei Ueno 2021-02-26 00:18:06 +09:00 committed by GitHub
parent 5927d6070c
commit dcca57b986
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)