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

Side by Side Diff: test/mjsunit/harmony/proxies-with-unscopables.js

Issue 384963002: ES6 Unscopables (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Changed tests to test multiple object types Created 6 years, 5 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 // Flags: --harmony-unscopables
6 // Flags: --harmony-proxies
rossberg 2014/07/17 15:12:13 Hm, shouldn't there also be some tests that actual
arv (Not doing code reviews) 2014/07/17 23:34:36 Like I said in a comment on the CL. Proxies cannot
7
8
9 (function TestBasics() {
10 var log = [];
11
12 var proxy = Proxy.create({
13 getPropertyDescriptor: function(key) {
14 log.push(key);
15 if (key === 'x') {
16 return {
17 value: 1,
18 configurable: true
19 };
20 }
21 return undefined;
22 }
23 });
24
25 var x = 'local';
26
27 with (proxy) {
28 assertEquals(1, x);
29 }
30
31 // One 'x' for HasBinding and two for GetBindingValue
32 assertEquals(['assertEquals', 'x', 'x', 'x'], log);
33 })();
34
35
36 (function TestInconsistent() {
37 var log = [];
38 var calls = 0;
39
40 var proxy = Proxy.create({
41 getPropertyDescriptor: function(key) {
42 log.push(key);
43 if (key === 'x' && calls < 2) {
44 calls++;
45 return {
46 value: 1,
47 configurable: true
48 };
49 }
50 return undefined;
51 }
52 });
53
54 var x = 'local';
55
56 with (proxy) {
57 assertEquals(void 0, x);
58 }
59
60 // One 'x' for HasBinding and two for GetBindingValue
61 assertEquals(['assertEquals', 'x', 'x', 'x'], log);
62 })();
63
64
65 (function TestInconsistent2() {
66 var log = [];
67 var calls = 0;
68
69 var proxy = Proxy.create({
70 getPropertyDescriptor: function(key) {
71 log.push(key);
72 if (key === 'x' && calls < 1) {
73 calls++;
74 return {
75 value: 1,
76 configurable: true
77 };
78 }
79 return undefined;
80 }
81 });
82
83 var x = 'local';
84
85 with (proxy) {
86 assertEquals(void 0, x);
87 }
88
89 // One 'x' for HasBinding and one for GetBindingValue, the second one from
90 // previous test is not called since the proxy reported that there is no 'x'
91 // property when we did GetBindingValue.
92 assertEquals(['assertEquals', 'x', 'x'], log);
93 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698