Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 })(); | |
| OLD | NEW |