mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-12-25 08:39:15 -05:00
Remove unnecessary 'DerefMut' impl from 'Local<T>' (#406)
Local handles never need to be mutable. This patch also rounds up the last few places where we were still asking the user to pass an `&mut T` to an API method.
This commit is contained in:
parent
b1a4dfea8b
commit
4e64cefc9c
9 changed files with 34 additions and 46 deletions
|
@ -90,7 +90,7 @@ impl<'cb> ReturnValue<'cb> {
|
||||||
/// Getter. Creates a new Local<> so it comes with a certain performance
|
/// Getter. Creates a new Local<> so it comes with a certain performance
|
||||||
/// hit. If the ReturnValue was not yet set, this will return the undefined
|
/// hit. If the ReturnValue was not yet set, this will return the undefined
|
||||||
/// value.
|
/// value.
|
||||||
pub fn get<'s>(&mut self, scope: &mut HandleScope<'s>) -> Local<'s, Value> {
|
pub fn get<'s>(&self, scope: &mut HandleScope<'s>) -> Local<'s, Value> {
|
||||||
unsafe { scope.cast_local(|_| v8__ReturnValue__Get(self)) }.unwrap()
|
unsafe { scope.cast_local(|_| v8__ReturnValue__Get(self)) }.unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::mem::transmute;
|
use std::mem::transmute;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::ops::DerefMut;
|
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
/// An object reference managed by the v8 garbage collector.
|
/// An object reference managed by the v8 garbage collector.
|
||||||
|
@ -82,12 +81,6 @@ impl<'s, T> Deref for Local<'s, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'s, T> DerefMut for Local<'s, T> {
|
|
||||||
fn deref_mut(&mut self) -> &mut T {
|
|
||||||
unsafe { self.0.as_mut() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_size_of_local() {
|
fn test_size_of_local() {
|
||||||
use crate::Value;
|
use crate::Value;
|
||||||
|
|
|
@ -204,7 +204,7 @@ impl Module {
|
||||||
/// exception is propagated.)
|
/// exception is propagated.)
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn instantiate_module<'a>(
|
pub fn instantiate_module<'a>(
|
||||||
&mut self,
|
&self,
|
||||||
scope: &mut HandleScope,
|
scope: &mut HandleScope,
|
||||||
callback: impl MapFnTo<ResolveCallback<'a>>,
|
callback: impl MapFnTo<ResolveCallback<'a>>,
|
||||||
) -> Option<bool> {
|
) -> Option<bool> {
|
||||||
|
|
|
@ -250,7 +250,7 @@ impl Object {
|
||||||
|
|
||||||
/// Note: SideEffectType affects the getter only, not the setter.
|
/// Note: SideEffectType affects the getter only, not the setter.
|
||||||
pub fn set_accessor(
|
pub fn set_accessor(
|
||||||
&mut self,
|
&self,
|
||||||
scope: &mut HandleScope,
|
scope: &mut HandleScope,
|
||||||
name: Local<Name>,
|
name: Local<Name>,
|
||||||
getter: impl for<'s> MapFnTo<AccessorNameGetterCallback<'s>>,
|
getter: impl for<'s> MapFnTo<AccessorNameGetterCallback<'s>>,
|
||||||
|
|
|
@ -31,24 +31,24 @@ impl Proxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_handler<'s>(
|
pub fn get_handler<'s>(
|
||||||
&mut self,
|
&self,
|
||||||
scope: &mut HandleScope<'s>,
|
scope: &mut HandleScope<'s>,
|
||||||
) -> Local<'s, Value> {
|
) -> Local<'s, Value> {
|
||||||
unsafe { scope.cast_local(|_| v8__Proxy__GetHandler(&*self)) }.unwrap()
|
unsafe { scope.cast_local(|_| v8__Proxy__GetHandler(&*self)) }.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_target<'s>(
|
pub fn get_target<'s>(
|
||||||
&mut self,
|
&self,
|
||||||
scope: &mut HandleScope<'s>,
|
scope: &mut HandleScope<'s>,
|
||||||
) -> Local<'s, Value> {
|
) -> Local<'s, Value> {
|
||||||
unsafe { scope.cast_local(|_| v8__Proxy__GetTarget(&*self)) }.unwrap()
|
unsafe { scope.cast_local(|_| v8__Proxy__GetTarget(&*self)) }.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_revoked(&mut self) -> bool {
|
pub fn is_revoked(&self) -> bool {
|
||||||
unsafe { v8__Proxy__IsRevoked(self) }
|
unsafe { v8__Proxy__IsRevoked(self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn revoke(&mut self) {
|
pub fn revoke(&self) {
|
||||||
unsafe { v8__Proxy__Revoke(self) };
|
unsafe { v8__Proxy__Revoke(self) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ impl Script {
|
||||||
/// context in which it was created (ScriptCompiler::CompileBound or
|
/// context in which it was created (ScriptCompiler::CompileBound or
|
||||||
/// UnboundScript::BindToCurrentContext()).
|
/// UnboundScript::BindToCurrentContext()).
|
||||||
pub fn run<'s>(
|
pub fn run<'s>(
|
||||||
&mut self,
|
&self,
|
||||||
scope: &mut HandleScope<'s>,
|
scope: &mut HandleScope<'s>,
|
||||||
) -> Option<Local<'s, Value>> {
|
) -> Option<Local<'s, Value>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -80,12 +80,12 @@ impl FunctionTemplate {
|
||||||
|
|
||||||
/// Returns the unique function instance in the current execution context.
|
/// Returns the unique function instance in the current execution context.
|
||||||
pub fn get_function<'s>(
|
pub fn get_function<'s>(
|
||||||
&mut self,
|
&self,
|
||||||
scope: &mut HandleScope<'s>,
|
scope: &mut HandleScope<'s>,
|
||||||
) -> Option<Local<'s, Function>> {
|
) -> Option<Local<'s, Function>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
scope.cast_local(|sd| {
|
scope.cast_local(|sd| {
|
||||||
v8__FunctionTemplate__GetFunction(&*self, sd.get_current_context())
|
v8__FunctionTemplate__GetFunction(self, sd.get_current_context())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,8 +93,8 @@ impl FunctionTemplate {
|
||||||
/// Set the class name of the FunctionTemplate. This is used for
|
/// Set the class name of the FunctionTemplate. This is used for
|
||||||
/// printing objects created with the function created from the
|
/// printing objects created with the function created from the
|
||||||
/// FunctionTemplate as its constructor.
|
/// FunctionTemplate as its constructor.
|
||||||
pub fn set_class_name(&mut self, name: Local<String>) {
|
pub fn set_class_name(&self, name: Local<String>) {
|
||||||
unsafe { v8__FunctionTemplate__SetClassName(&*self, &*name) };
|
unsafe { v8__FunctionTemplate__SetClassName(self, &*name) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl CoreIsolate {
|
||||||
let context = v8::Context::new(scope);
|
let context = v8::Context::new(scope);
|
||||||
let scope = &mut v8::ContextScope::new(scope, context);
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
let source = v8::String::new(scope, code).unwrap();
|
let source = v8::String::new(scope, code).unwrap();
|
||||||
let mut script = v8::Script::compile(scope, source, None).unwrap();
|
let script = v8::Script::compile(scope, source, None).unwrap();
|
||||||
let r = script.run(scope);
|
let r = script.run(scope);
|
||||||
r.is_some()
|
r.is_some()
|
||||||
}
|
}
|
||||||
|
|
|
@ -529,7 +529,7 @@ fn eval<'s>(
|
||||||
) -> Option<v8::Local<'s, v8::Value>> {
|
) -> Option<v8::Local<'s, v8::Value>> {
|
||||||
let scope = &mut v8::EscapableHandleScope::new(scope);
|
let scope = &mut v8::EscapableHandleScope::new(scope);
|
||||||
let source = v8::String::new(scope, code).unwrap();
|
let source = v8::String::new(scope, code).unwrap();
|
||||||
let mut script = v8::Script::compile(scope, source, None).unwrap();
|
let script = v8::Script::compile(scope, source, None).unwrap();
|
||||||
let r = script.run(scope);
|
let r = script.run(scope);
|
||||||
r.map(|v| scope.escape(v))
|
r.map(|v| scope.escape(v))
|
||||||
}
|
}
|
||||||
|
@ -689,7 +689,7 @@ fn terminate_execution() {
|
||||||
// Rn an infinite loop, which should be terminated.
|
// Rn an infinite loop, which should be terminated.
|
||||||
let source = v8::String::new(scope, "for(;;) {}").unwrap();
|
let source = v8::String::new(scope, "for(;;) {}").unwrap();
|
||||||
let r = v8::Script::compile(scope, source, None);
|
let r = v8::Script::compile(scope, source, None);
|
||||||
let mut script = r.unwrap();
|
let script = r.unwrap();
|
||||||
let result = script.run(scope);
|
let result = script.run(scope);
|
||||||
assert!(result.is_none());
|
assert!(result.is_none());
|
||||||
// TODO assert_eq!(e.to_string(), "Uncaught Error: execution terminated")
|
// TODO assert_eq!(e.to_string(), "Uncaught Error: execution terminated")
|
||||||
|
@ -774,7 +774,7 @@ fn add_message_listener() {
|
||||||
let context = v8::Context::new(scope);
|
let context = v8::Context::new(scope);
|
||||||
let scope = &mut v8::ContextScope::new(scope, context);
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
let source = v8::String::new(scope, "throw 'foo'").unwrap();
|
let source = v8::String::new(scope, "throw 'foo'").unwrap();
|
||||||
let mut script = v8::Script::compile(scope, source, None).unwrap();
|
let script = v8::Script::compile(scope, source, None).unwrap();
|
||||||
assert!(script.run(scope).is_none());
|
assert!(script.run(scope).is_none());
|
||||||
assert_eq!(CALL_COUNT.load(Ordering::SeqCst), 1);
|
assert_eq!(CALL_COUNT.load(Ordering::SeqCst), 1);
|
||||||
}
|
}
|
||||||
|
@ -814,8 +814,7 @@ fn set_host_initialize_import_meta_object_callback() {
|
||||||
let context = v8::Context::new(scope);
|
let context = v8::Context::new(scope);
|
||||||
let scope = &mut v8::ContextScope::new(scope, context);
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
let source = mock_source(scope, "google.com", "import.meta;");
|
let source = mock_source(scope, "google.com", "import.meta;");
|
||||||
let mut module =
|
let module = v8::script_compiler::compile_module(scope, source).unwrap();
|
||||||
v8::script_compiler::compile_module(scope, source).unwrap();
|
|
||||||
let result =
|
let result =
|
||||||
module.instantiate_module(scope, unexpected_module_resolve_callback);
|
module.instantiate_module(scope, unexpected_module_resolve_callback);
|
||||||
assert!(result.is_some());
|
assert!(result.is_some());
|
||||||
|
@ -839,7 +838,7 @@ fn script_compile_and_run() {
|
||||||
let context = v8::Context::new(scope);
|
let context = v8::Context::new(scope);
|
||||||
let scope = &mut v8::ContextScope::new(scope, context);
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
let source = v8::String::new(scope, "'Hello ' + 13 + 'th planet'").unwrap();
|
let source = v8::String::new(scope, "'Hello ' + 13 + 'th planet'").unwrap();
|
||||||
let mut script = v8::Script::compile(scope, source, None).unwrap();
|
let script = v8::Script::compile(scope, source, None).unwrap();
|
||||||
source.to_rust_string_lossy(scope);
|
source.to_rust_string_lossy(scope);
|
||||||
let result = script.run(scope).unwrap();
|
let result = script.run(scope).unwrap();
|
||||||
let result = result.to_string(scope).unwrap();
|
let result = result.to_string(scope).unwrap();
|
||||||
|
@ -880,7 +879,7 @@ fn script_origin() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let source = v8::String::new(scope, "1+2").unwrap();
|
let source = v8::String::new(scope, "1+2").unwrap();
|
||||||
let mut script =
|
let script =
|
||||||
v8::Script::compile(scope, source, Some(&script_origin)).unwrap();
|
v8::Script::compile(scope, source, Some(&script_origin)).unwrap();
|
||||||
source.to_rust_string_lossy(scope);
|
source.to_rust_string_lossy(scope);
|
||||||
let _result = script.run(scope).unwrap();
|
let _result = script.run(scope).unwrap();
|
||||||
|
@ -1090,8 +1089,7 @@ fn object_template_from_function_template() {
|
||||||
let isolate = &mut v8::Isolate::new(Default::default());
|
let isolate = &mut v8::Isolate::new(Default::default());
|
||||||
{
|
{
|
||||||
let scope = &mut v8::HandleScope::new(isolate);
|
let scope = &mut v8::HandleScope::new(isolate);
|
||||||
let mut function_templ =
|
let function_templ = v8::FunctionTemplate::new(scope, fortytwo_callback);
|
||||||
v8::FunctionTemplate::new(scope, fortytwo_callback);
|
|
||||||
let expected_class_name = v8::String::new(scope, "fortytwo").unwrap();
|
let expected_class_name = v8::String::new(scope, "fortytwo").unwrap();
|
||||||
function_templ.set_class_name(expected_class_name);
|
function_templ.set_class_name(expected_class_name);
|
||||||
let object_templ =
|
let object_templ =
|
||||||
|
@ -1240,7 +1238,7 @@ fn object_set_accessor() {
|
||||||
CALL_COUNT.fetch_add(1, Ordering::SeqCst);
|
CALL_COUNT.fetch_add(1, Ordering::SeqCst);
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut obj = v8::Object::new(scope);
|
let obj = v8::Object::new(scope);
|
||||||
|
|
||||||
let getter_key = v8::String::new(scope, "getter_key").unwrap();
|
let getter_key = v8::String::new(scope, "getter_key").unwrap();
|
||||||
obj.set_accessor(scope, getter_key.into(), getter);
|
obj.set_accessor(scope, getter_key.into(), getter);
|
||||||
|
@ -1334,7 +1332,7 @@ fn proxy() {
|
||||||
let handler = v8::Object::new(scope);
|
let handler = v8::Object::new(scope);
|
||||||
let maybe_proxy = v8::Proxy::new(scope, target, handler);
|
let maybe_proxy = v8::Proxy::new(scope, target, handler);
|
||||||
assert!(maybe_proxy.is_some());
|
assert!(maybe_proxy.is_some());
|
||||||
let mut proxy = maybe_proxy.unwrap();
|
let proxy = maybe_proxy.unwrap();
|
||||||
assert!(target == proxy.get_target(scope));
|
assert!(target == proxy.get_target(scope));
|
||||||
assert!(handler == proxy.get_handler(scope));
|
assert!(handler == proxy.get_handler(scope));
|
||||||
assert!(!proxy.is_revoked());
|
assert!(!proxy.is_revoked());
|
||||||
|
@ -1406,7 +1404,7 @@ fn function() {
|
||||||
let global = context.global(scope);
|
let global = context.global(scope);
|
||||||
let recv: v8::Local<v8::Value> = global.into();
|
let recv: v8::Local<v8::Value> = global.into();
|
||||||
// create function using template
|
// create function using template
|
||||||
let mut fn_template = v8::FunctionTemplate::new(scope, fn_callback);
|
let fn_template = v8::FunctionTemplate::new(scope, fn_callback);
|
||||||
let function = fn_template
|
let function = fn_template
|
||||||
.get_function(scope)
|
.get_function(scope)
|
||||||
.expect("Unable to create function");
|
.expect("Unable to create function");
|
||||||
|
@ -1547,8 +1545,7 @@ fn module_instantiation_failures1() {
|
||||||
let origin = mock_script_origin(scope, "foo.js");
|
let origin = mock_script_origin(scope, "foo.js");
|
||||||
let source = v8::script_compiler::Source::new(source_text, &origin);
|
let source = v8::script_compiler::Source::new(source_text, &origin);
|
||||||
|
|
||||||
let mut module =
|
let module = v8::script_compiler::compile_module(scope, source).unwrap();
|
||||||
v8::script_compiler::compile_module(scope, source).unwrap();
|
|
||||||
assert_eq!(v8::ModuleStatus::Uninstantiated, module.get_status());
|
assert_eq!(v8::ModuleStatus::Uninstantiated, module.get_status());
|
||||||
assert_eq!(2, module.get_module_requests_length());
|
assert_eq!(2, module.get_module_requests_length());
|
||||||
|
|
||||||
|
@ -1624,8 +1621,7 @@ fn module_evaluation() {
|
||||||
let origin = mock_script_origin(scope, "foo.js");
|
let origin = mock_script_origin(scope, "foo.js");
|
||||||
let source = v8::script_compiler::Source::new(source_text, &origin);
|
let source = v8::script_compiler::Source::new(source_text, &origin);
|
||||||
|
|
||||||
let mut module =
|
let module = v8::script_compiler::compile_module(scope, source).unwrap();
|
||||||
v8::script_compiler::compile_module(scope, source).unwrap();
|
|
||||||
assert_eq!(v8::ModuleStatus::Uninstantiated, module.get_status());
|
assert_eq!(v8::ModuleStatus::Uninstantiated, module.get_status());
|
||||||
|
|
||||||
let result = module
|
let result = module
|
||||||
|
@ -1710,7 +1706,7 @@ fn array_buffer_view() {
|
||||||
let scope = &mut v8::ContextScope::new(scope, context);
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
let source =
|
let source =
|
||||||
v8::String::new(scope, "new Uint8Array([23,23,23,23])").unwrap();
|
v8::String::new(scope, "new Uint8Array([23,23,23,23])").unwrap();
|
||||||
let mut script = v8::Script::compile(scope, source, None).unwrap();
|
let script = v8::Script::compile(scope, source, None).unwrap();
|
||||||
source.to_rust_string_lossy(scope);
|
source.to_rust_string_lossy(scope);
|
||||||
let result: v8::Local<v8::ArrayBufferView> =
|
let result: v8::Local<v8::ArrayBufferView> =
|
||||||
script.run(scope).unwrap().try_into().unwrap();
|
script.run(scope).unwrap().try_into().unwrap();
|
||||||
|
@ -1746,7 +1742,7 @@ fn snapshot_creator() {
|
||||||
let scope = &mut v8::ContextScope::new(scope, context);
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
|
|
||||||
let source = v8::String::new(scope, "a = 1 + 2").unwrap();
|
let source = v8::String::new(scope, "a = 1 + 2").unwrap();
|
||||||
let mut script = v8::Script::compile(scope, source, None).unwrap();
|
let script = v8::Script::compile(scope, source, None).unwrap();
|
||||||
script.run(scope).unwrap();
|
script.run(scope).unwrap();
|
||||||
|
|
||||||
snapshot_creator.set_default_context(context);
|
snapshot_creator.set_default_context(context);
|
||||||
|
@ -1767,7 +1763,7 @@ fn snapshot_creator() {
|
||||||
let context = v8::Context::new(scope);
|
let context = v8::Context::new(scope);
|
||||||
let scope = &mut v8::ContextScope::new(scope, context);
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
let source = v8::String::new(scope, "a === 3").unwrap();
|
let source = v8::String::new(scope, "a === 3").unwrap();
|
||||||
let mut script = v8::Script::compile(scope, source, None).unwrap();
|
let script = v8::Script::compile(scope, source, None).unwrap();
|
||||||
let result = script.run(scope).unwrap();
|
let result = script.run(scope).unwrap();
|
||||||
let true_val = v8::Boolean::new(scope, true).into();
|
let true_val = v8::Boolean::new(scope, true).into();
|
||||||
assert!(result.same_value(true_val));
|
assert!(result.same_value(true_val));
|
||||||
|
@ -1799,7 +1795,7 @@ fn external_references() {
|
||||||
let scope = &mut v8::ContextScope::new(scope, context);
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
|
|
||||||
// create function using template
|
// create function using template
|
||||||
let mut fn_template = v8::FunctionTemplate::new(scope, fn_callback);
|
let fn_template = v8::FunctionTemplate::new(scope, fn_callback);
|
||||||
let function = fn_template
|
let function = fn_template
|
||||||
.get_function(scope)
|
.get_function(scope)
|
||||||
.expect("Unable to create function");
|
.expect("Unable to create function");
|
||||||
|
@ -1863,7 +1859,7 @@ fn uint8_array() {
|
||||||
let scope = &mut v8::ContextScope::new(scope, context);
|
let scope = &mut v8::ContextScope::new(scope, context);
|
||||||
let source =
|
let source =
|
||||||
v8::String::new(scope, "new Uint8Array([23,23,23,23])").unwrap();
|
v8::String::new(scope, "new Uint8Array([23,23,23,23])").unwrap();
|
||||||
let mut script = v8::Script::compile(scope, source, None).unwrap();
|
let script = v8::Script::compile(scope, source, None).unwrap();
|
||||||
source.to_rust_string_lossy(scope);
|
source.to_rust_string_lossy(scope);
|
||||||
let result: v8::Local<v8::ArrayBufferView> =
|
let result: v8::Local<v8::ArrayBufferView> =
|
||||||
script.run(scope).unwrap().try_into().unwrap();
|
script.run(scope).unwrap().try_into().unwrap();
|
||||||
|
@ -1949,7 +1945,7 @@ fn shared_array_buffer() {
|
||||||
sharedBytes[5] + sharedBytes[12]",
|
sharedBytes[5] + sharedBytes[12]",
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut script = v8::Script::compile(scope, source, None).unwrap();
|
let script = v8::Script::compile(scope, source, None).unwrap();
|
||||||
|
|
||||||
let result: v8::Local<v8::Integer> =
|
let result: v8::Local<v8::Integer> =
|
||||||
script.run(scope).unwrap().try_into().unwrap();
|
script.run(scope).unwrap().try_into().unwrap();
|
||||||
|
@ -2897,8 +2893,7 @@ fn module_snapshot() {
|
||||||
let origin = mock_script_origin(scope, "foo.js");
|
let origin = mock_script_origin(scope, "foo.js");
|
||||||
let source = v8::script_compiler::Source::new(source_text, &origin);
|
let source = v8::script_compiler::Source::new(source_text, &origin);
|
||||||
|
|
||||||
let mut module =
|
let module = v8::script_compiler::compile_module(scope, source).unwrap();
|
||||||
v8::script_compiler::compile_module(scope, source).unwrap();
|
|
||||||
assert_eq!(v8::ModuleStatus::Uninstantiated, module.get_status());
|
assert_eq!(v8::ModuleStatus::Uninstantiated, module.get_status());
|
||||||
|
|
||||||
let result = module.instantiate_module(
|
let result = module.instantiate_module(
|
||||||
|
@ -2931,12 +2926,12 @@ fn module_snapshot() {
|
||||||
let true_val = v8::Boolean::new(scope, true).into();
|
let true_val = v8::Boolean::new(scope, true).into();
|
||||||
|
|
||||||
let source = v8::String::new(scope, "a === 3").unwrap();
|
let source = v8::String::new(scope, "a === 3").unwrap();
|
||||||
let mut script = v8::Script::compile(scope, source, None).unwrap();
|
let script = v8::Script::compile(scope, source, None).unwrap();
|
||||||
let result = script.run(scope).unwrap();
|
let result = script.run(scope).unwrap();
|
||||||
assert!(result.same_value(true_val));
|
assert!(result.same_value(true_val));
|
||||||
|
|
||||||
let source = v8::String::new(scope, "b === 42").unwrap();
|
let source = v8::String::new(scope, "b === 42").unwrap();
|
||||||
let mut script = v8::Script::compile(scope, source, None).unwrap();
|
let script = v8::Script::compile(scope, source, None).unwrap();
|
||||||
let result = script.run(scope).unwrap();
|
let result = script.run(scope).unwrap();
|
||||||
assert!(result.same_value(true_val));
|
assert!(result.same_value(true_val));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue