Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: test/cctest/test-unscopables-hidden-prototype.cc

Issue 384963002: ES6 Unscopables (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Updated to reflect the July 2014 consensus Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <stdlib.h>
6
7 #include "src/v8.h"
8 #include "test/cctest/cctest.h"
9
10 namespace {
11
12
13 static void Cleanup() {
14 CompileRun(
15 "delete object.x;"
16 "delete hidden_prototype.x;"
17 "delete object[Symbol.unscopables];"
18 "delete hidden_prototype[Symbol.unscopables];");
19 }
20
21
22 TEST(Unscopables) {
23 i::FLAG_harmony_unscopables = true;
24
25 LocalContext context;
26 v8::Isolate* isolate = context->GetIsolate();
27 v8::HandleScope handle_scope(isolate);
28
29 v8::Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
30 v8::Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
31
32 t1->SetHiddenPrototype(true);
33
34 v8::Local<v8::Object> object = t0->GetFunction()->NewInstance();
35 v8::Local<v8::Object> hidden_prototype = t1->GetFunction()->NewInstance();
36
37 object->SetPrototype(hidden_prototype);
38
39 context->Global()->Set(v8_str("object"), object);
40 context->Global()->Set(v8_str("hidden_prototype"), hidden_prototype);
41
42 CHECK_EQ(1, CompileRun(
43 "var result;"
44 "var x = 0;"
45 "object.x = 1;"
46 "with (object) {"
47 " result = x;"
48 "}"
49 "result")->Int32Value());
50
51 Cleanup();
52 CHECK_EQ(2, CompileRun(
53 "var result;"
54 "var x = 0;"
55 "hidden_prototype.x = 2;"
56 "with (object) {"
57 " result = x;"
58 "}"
59 "result")->Int32Value());
60
61 Cleanup();
62 CHECK_EQ(0, CompileRun(
63 "var result;"
64 "var x = 0;"
65 "object.x = 3;"
66 "object[Symbol.unscopables] = {x: true};"
67 "with (object) {"
68 " result = x;"
69 "}"
70 "result")->Int32Value());
71
72 Cleanup();
73 CHECK_EQ(0, CompileRun(
74 "var result;"
75 "var x = 0;"
76 "hidden_prototype.x = 4;"
77 "hidden_prototype[Symbol.unscopables] = {x: true};"
78 "with (object) {"
79 " result = x;"
80 "}"
81 "result")->Int32Value());
82
83 Cleanup();
84 CHECK_EQ(0, CompileRun(
85 "var result;"
86 "var x = 0;"
87 "object.x = 5;"
88 "hidden_prototype[Symbol.unscopables] = {x: true};"
89 "with (object) {"
90 " result = x;"
91 "}"
92 "result;")->Int32Value());
93
94 Cleanup();
95 CHECK_EQ(0, CompileRun(
96 "var result;"
97 "var x = 0;"
98 "hidden_prototype.x = 6;"
99 "object[Symbol.unscopables] = {x: true};"
100 "with (object) {"
101 " result = x;"
102 "}"
103 "result")->Int32Value());
104 }
105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698