Index: test/cctest/test-unscopables-hidden-prototype.cc |
diff --git a/test/cctest/test-unscopables-hidden-prototype.cc b/test/cctest/test-unscopables-hidden-prototype.cc |
index aef2ccf288c960de04c3a38687e451952f3e5ad2..2a66a647ee3caf0e6e9f46ab196b3dac6c3120a0 100644 |
--- a/test/cctest/test-unscopables-hidden-prototype.cc |
+++ b/test/cctest/test-unscopables-hidden-prototype.cc |
@@ -2,6 +2,9 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+// TODO(mythria): Remove this after this flag is turned on globally |
+#define V8_IMMINENT_DEPRECATION_WARNINGS |
+ |
#include <stdlib.h> |
#include "src/v8.h" |
@@ -23,81 +26,98 @@ TEST(Unscopables) { |
LocalContext context; |
v8::Isolate* isolate = context->GetIsolate(); |
v8::HandleScope handle_scope(isolate); |
+ v8::Local<v8::Context> curr_context = isolate->GetCurrentContext(); |
rmcilroy
2015/09/10 09:30:16
nit - please don't abbreviate - current_context.
mythria_google
2015/09/10 10:07:29
Done.
|
v8::Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate); |
v8::Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); |
t1->SetHiddenPrototype(true); |
- v8::Local<v8::Object> object = t0->GetFunction()->NewInstance(); |
- v8::Local<v8::Object> hidden_prototype = t1->GetFunction()->NewInstance(); |
- |
- object->SetPrototype(hidden_prototype); |
- |
- context->Global()->Set(v8_str("object"), object); |
- context->Global()->Set(v8_str("hidden_prototype"), hidden_prototype); |
- |
- CHECK_EQ(1, CompileRun( |
- "var result;" |
- "var x = 0;" |
- "object.x = 1;" |
- "with (object) {" |
- " result = x;" |
- "}" |
- "result")->Int32Value()); |
+ v8::Local<v8::Object> object = t0->GetFunction(curr_context) |
+ .ToLocalChecked() |
+ ->NewInstance(curr_context) |
+ .ToLocalChecked(); |
+ v8::Local<v8::Object> hidden_prototype = t1->GetFunction(curr_context) |
+ .ToLocalChecked() |
+ ->NewInstance(curr_context) |
+ .ToLocalChecked(); |
+ |
+ object->SetPrototype(curr_context, hidden_prototype).FromMaybe(false); |
rmcilroy
2015/09/10 09:30:16
Could you add a CHECK() around this to check the v
jochen (gone - plz use gerrit)
2015/09/10 09:33:24
Just use .FromJust() that checks internally.
mythria_google
2015/09/10 10:07:29
Done.
mythria_google
2015/09/10 10:07:29
Done.
|
+ |
+ context->Global() |
+ ->Set(curr_context, v8_str("object"), object) |
+ .FromMaybe(false); |
+ context->Global() |
+ ->Set(curr_context, v8_str("hidden_prototype"), hidden_prototype) |
+ .FromMaybe(false); |
+ |
+ CHECK_EQ(1, CompileRun("var result;" |
+ "var x = 0;" |
+ "object.x = 1;" |
+ "with (object) {" |
+ " result = x;" |
+ "}" |
+ "result") |
+ ->Int32Value(curr_context) |
+ .FromMaybe(-1)); |
rmcilroy
2015/09/10 09:30:16
nit - could .FromMaybe(-1) be on the same line as
jochen (gone - plz use gerrit)
2015/09/10 09:33:24
same here... FromJust()
mythria_google
2015/09/10 10:07:30
This is git cl format. I can move FromMaybe to the
mythria_google
2015/09/10 10:07:30
Done.
rmcilroy
2015/09/10 10:41:05
If this is what git cl format wants then I'm fine
|
Cleanup(); |
- CHECK_EQ(2, CompileRun( |
- "var result;" |
- "var x = 0;" |
- "hidden_prototype.x = 2;" |
- "with (object) {" |
- " result = x;" |
- "}" |
- "result")->Int32Value()); |
+ CHECK_EQ(2, CompileRun("var result;" |
+ "var x = 0;" |
+ "hidden_prototype.x = 2;" |
+ "with (object) {" |
+ " result = x;" |
+ "}" |
+ "result") |
+ ->Int32Value(curr_context) |
+ .FromMaybe(-1)); |
Cleanup(); |
- CHECK_EQ(0, CompileRun( |
- "var result;" |
- "var x = 0;" |
- "object.x = 3;" |
- "object[Symbol.unscopables] = {x: true};" |
- "with (object) {" |
- " result = x;" |
- "}" |
- "result")->Int32Value()); |
+ CHECK_EQ(0, CompileRun("var result;" |
+ "var x = 0;" |
+ "object.x = 3;" |
+ "object[Symbol.unscopables] = {x: true};" |
+ "with (object) {" |
+ " result = x;" |
+ "}" |
+ "result") |
+ ->Int32Value(curr_context) |
+ .FromMaybe(-1)); |
Cleanup(); |
- CHECK_EQ(0, CompileRun( |
- "var result;" |
- "var x = 0;" |
- "hidden_prototype.x = 4;" |
- "hidden_prototype[Symbol.unscopables] = {x: true};" |
- "with (object) {" |
- " result = x;" |
- "}" |
- "result")->Int32Value()); |
+ CHECK_EQ(0, CompileRun("var result;" |
+ "var x = 0;" |
+ "hidden_prototype.x = 4;" |
+ "hidden_prototype[Symbol.unscopables] = {x: true};" |
+ "with (object) {" |
+ " result = x;" |
+ "}" |
+ "result") |
+ ->Int32Value(curr_context) |
+ .FromMaybe(-1)); |
Cleanup(); |
- CHECK_EQ(0, CompileRun( |
- "var result;" |
- "var x = 0;" |
- "object.x = 5;" |
- "hidden_prototype[Symbol.unscopables] = {x: true};" |
- "with (object) {" |
- " result = x;" |
- "}" |
- "result;")->Int32Value()); |
+ CHECK_EQ(0, CompileRun("var result;" |
+ "var x = 0;" |
+ "object.x = 5;" |
+ "hidden_prototype[Symbol.unscopables] = {x: true};" |
+ "with (object) {" |
+ " result = x;" |
+ "}" |
+ "result;") |
+ ->Int32Value(curr_context) |
+ .FromMaybe(-1)); |
Cleanup(); |
- CHECK_EQ(0, CompileRun( |
- "var result;" |
- "var x = 0;" |
- "hidden_prototype.x = 6;" |
- "object[Symbol.unscopables] = {x: true};" |
- "with (object) {" |
- " result = x;" |
- "}" |
- "result")->Int32Value()); |
+ CHECK_EQ(0, CompileRun("var result;" |
+ "var x = 0;" |
+ "hidden_prototype.x = 6;" |
+ "object[Symbol.unscopables] = {x: true};" |
+ "with (object) {" |
+ " result = x;" |
+ "}" |
+ "result") |
+ ->Int32Value(curr_context) |
+ .FromMaybe(-1)); |
} |
} |