mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-11-24 15:19:31 -05:00
compile_and_run is not needed because we have eval()
This commit is contained in:
parent
4cc07a5d5d
commit
a8a747a5e7
1 changed files with 21 additions and 60 deletions
|
@ -3578,15 +3578,6 @@ fn snapshot_creator() {
|
|||
|
||||
#[test]
|
||||
fn snapshot_creator_multiple_contexts() {
|
||||
fn compile_and_run<'s>(
|
||||
scope: &mut v8::HandleScope<'s>,
|
||||
source: &str,
|
||||
) -> Option<v8::Local<'s, v8::Value>> {
|
||||
let source = v8::String::new(scope, source).unwrap();
|
||||
let script = v8::Script::compile(scope, source, None).unwrap();
|
||||
script.run(scope)
|
||||
}
|
||||
|
||||
let _setup_guard = setup();
|
||||
let startup_data = {
|
||||
let mut snapshot_creator = v8::SnapshotCreator::new(None, None);
|
||||
|
@ -3595,15 +3586,11 @@ fn snapshot_creator_multiple_contexts() {
|
|||
let mut scope = v8::HandleScope::new(&mut isolate);
|
||||
let context = v8::Context::new(&mut scope);
|
||||
let scope = &mut v8::ContextScope::new(&mut scope, context);
|
||||
compile_and_run(
|
||||
scope,
|
||||
"globalThis.__bootstrap = { defaultContextProp: 1};",
|
||||
)
|
||||
.unwrap();
|
||||
eval(scope, "globalThis.__bootstrap = { defaultContextProp: 1};")
|
||||
.unwrap();
|
||||
{
|
||||
let value =
|
||||
compile_and_run(scope, "globalThis.__bootstrap.defaultContextProp")
|
||||
.unwrap();
|
||||
eval(scope, "globalThis.__bootstrap.defaultContextProp").unwrap();
|
||||
let one_val = v8::Number::new(scope, 1.0).into();
|
||||
assert!(value.same_value(one_val));
|
||||
}
|
||||
|
@ -3613,12 +3600,9 @@ fn snapshot_creator_multiple_contexts() {
|
|||
let scope = &mut v8::HandleScope::new(&mut isolate);
|
||||
let context = v8::Context::new(scope);
|
||||
let scope = &mut v8::ContextScope::new(scope, context);
|
||||
compile_and_run(scope, "globalThis.__bootstrap = { context0Prop: 2 };")
|
||||
.unwrap();
|
||||
eval(scope, "globalThis.__bootstrap = { context0Prop: 2 };").unwrap();
|
||||
{
|
||||
let value =
|
||||
compile_and_run(scope, "globalThis.__bootstrap.context0Prop")
|
||||
.unwrap();
|
||||
let value = eval(scope, "globalThis.__bootstrap.context0Prop").unwrap();
|
||||
let two_val = v8::Number::new(scope, 2.0).into();
|
||||
assert!(value.same_value(two_val));
|
||||
}
|
||||
|
@ -3641,26 +3625,18 @@ fn snapshot_creator_multiple_contexts() {
|
|||
let scope = &mut v8::ContextScope::new(scope, context);
|
||||
{
|
||||
let value =
|
||||
compile_and_run(scope, "globalThis.__bootstrap.defaultContextProp")
|
||||
.unwrap();
|
||||
eval(scope, "globalThis.__bootstrap.defaultContextProp").unwrap();
|
||||
let one_val = v8::Number::new(scope, 1.0).into();
|
||||
assert!(value.same_value(one_val));
|
||||
}
|
||||
{
|
||||
let value =
|
||||
compile_and_run(scope, "globalThis.__bootstrap.context0Prop")
|
||||
.unwrap();
|
||||
let value = eval(scope, "globalThis.__bootstrap.context0Prop").unwrap();
|
||||
assert!(value.is_undefined());
|
||||
}
|
||||
{
|
||||
compile_and_run(
|
||||
scope,
|
||||
"globalThis.__bootstrap.defaultContextProp2 = 3;",
|
||||
)
|
||||
.unwrap();
|
||||
eval(scope, "globalThis.__bootstrap.defaultContextProp2 = 3;").unwrap();
|
||||
let value =
|
||||
compile_and_run(scope, "globalThis.__bootstrap.defaultContextProp2")
|
||||
.unwrap();
|
||||
eval(scope, "globalThis.__bootstrap.defaultContextProp2").unwrap();
|
||||
let three_val = v8::Number::new(scope, 3.0).into();
|
||||
assert!(value.same_value(three_val));
|
||||
}
|
||||
|
@ -3672,23 +3648,18 @@ fn snapshot_creator_multiple_contexts() {
|
|||
let scope = &mut v8::ContextScope::new(scope, context);
|
||||
{
|
||||
let value =
|
||||
compile_and_run(scope, "globalThis.__bootstrap.defaultContextProp")
|
||||
.unwrap();
|
||||
eval(scope, "globalThis.__bootstrap.defaultContextProp").unwrap();
|
||||
assert!(value.is_undefined());
|
||||
}
|
||||
{
|
||||
let value =
|
||||
compile_and_run(scope, "globalThis.__bootstrap.context0Prop")
|
||||
.unwrap();
|
||||
let value = eval(scope, "globalThis.__bootstrap.context0Prop").unwrap();
|
||||
let two_val = v8::Number::new(scope, 2.0).into();
|
||||
assert!(value.same_value(two_val));
|
||||
}
|
||||
{
|
||||
compile_and_run(scope, "globalThis.__bootstrap.context0Prop2 = 4;")
|
||||
.unwrap();
|
||||
eval(scope, "globalThis.__bootstrap.context0Prop2 = 4;").unwrap();
|
||||
let value =
|
||||
compile_and_run(scope, "globalThis.__bootstrap.context0Prop2")
|
||||
.unwrap();
|
||||
eval(scope, "globalThis.__bootstrap.context0Prop2").unwrap();
|
||||
let four_val = v8::Number::new(scope, 4.0).into();
|
||||
assert!(value.same_value(four_val));
|
||||
}
|
||||
|
@ -3707,28 +3678,23 @@ fn snapshot_creator_multiple_contexts() {
|
|||
let context = v8::Context::new(scope);
|
||||
let scope = &mut v8::ContextScope::new(scope, context);
|
||||
{
|
||||
let value =
|
||||
compile_and_run(scope, "globalThis.__bootstrap.context0Prop")
|
||||
.unwrap();
|
||||
let value = eval(scope, "globalThis.__bootstrap.context0Prop").unwrap();
|
||||
assert!(value.is_undefined());
|
||||
}
|
||||
{
|
||||
let value =
|
||||
compile_and_run(scope, "globalThis.__bootstrap.context0Prop2")
|
||||
.unwrap();
|
||||
eval(scope, "globalThis.__bootstrap.context0Prop2").unwrap();
|
||||
assert!(value.is_undefined());
|
||||
}
|
||||
{
|
||||
let value =
|
||||
compile_and_run(scope, "globalThis.__bootstrap.defaultContextProp")
|
||||
.unwrap();
|
||||
eval(scope, "globalThis.__bootstrap.defaultContextProp").unwrap();
|
||||
let one_val = v8::Number::new(scope, 1.0).into();
|
||||
assert!(value.same_value(one_val));
|
||||
}
|
||||
{
|
||||
let value =
|
||||
compile_and_run(scope, "globalThis.__bootstrap.defaultContextProp2")
|
||||
.unwrap();
|
||||
eval(scope, "globalThis.__bootstrap.defaultContextProp2").unwrap();
|
||||
let three_val = v8::Number::new(scope, 3.0).into();
|
||||
assert!(value.same_value(three_val));
|
||||
}
|
||||
|
@ -3739,27 +3705,22 @@ fn snapshot_creator_multiple_contexts() {
|
|||
let scope = &mut v8::ContextScope::new(scope, context);
|
||||
{
|
||||
let value =
|
||||
compile_and_run(scope, "globalThis.__bootstrap.defaultContextProp")
|
||||
.unwrap();
|
||||
eval(scope, "globalThis.__bootstrap.defaultContextProp").unwrap();
|
||||
assert!(value.is_undefined());
|
||||
}
|
||||
{
|
||||
let value =
|
||||
compile_and_run(scope, "globalThis.__bootstrap.defaultContextProp2")
|
||||
.unwrap();
|
||||
eval(scope, "globalThis.__bootstrap.defaultContextProp2").unwrap();
|
||||
assert!(value.is_undefined());
|
||||
}
|
||||
{
|
||||
let value =
|
||||
compile_and_run(scope, "globalThis.__bootstrap.context0Prop")
|
||||
.unwrap();
|
||||
let value = eval(scope, "globalThis.__bootstrap.context0Prop").unwrap();
|
||||
let two_val = v8::Number::new(scope, 2.0).into();
|
||||
assert!(value.same_value(two_val));
|
||||
}
|
||||
{
|
||||
let value =
|
||||
compile_and_run(scope, "globalThis.__bootstrap.context0Prop2")
|
||||
.unwrap();
|
||||
eval(scope, "globalThis.__bootstrap.context0Prop2").unwrap();
|
||||
let four_val = v8::Number::new(scope, 4.0).into();
|
||||
assert!(value.same_value(four_val));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue