| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 // Flags: --harmony-proxies | 28 // Flags: --harmony-proxies |
| 29 | 29 |
| 30 | 30 |
| 31 // Helper. | 31 // Helper. |
| 32 | 32 |
| 33 function TestWithProxies(test, construct, handler) { | 33 function TestWithProxies(test, construct, handler) { |
| 34 test(construct, handler, function(h) { return new Proxy({}, h) }) | 34 test(construct, handler, function(h) { return new Proxy({}, h) }) |
| 35 test(construct, handler, function(h) { | 35 // TODO(cbruni): Adapt and enable once we have [[Call]] working. |
| 36 return Proxy.createFunction(h, function() {}) | 36 // test(construct, handler, function(h) { |
| 37 }) | 37 // return Proxy.createFunction(h, function() {}) |
| 38 // }) |
| 38 } | 39 } |
| 39 | 40 |
| 40 | 41 |
| 41 // Sets. | 42 // Sets. |
| 42 | 43 |
| 43 function TestSet(construct, fix) { | 44 function TestSet(construct, fix) { |
| 44 TestWithProxies(TestSet2, construct, fix) | 45 TestWithProxies(TestSet2, construct, fix) |
| 45 } | 46 } |
| 46 | 47 |
| 47 function TestSet2(construct, fix, create) { | 48 function TestSet2(construct, fix, create) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 63 assertTrue(s.has(p1)); | 64 assertTrue(s.has(p1)); |
| 64 assertTrue(s.has(p2)); | 65 assertTrue(s.has(p2)); |
| 65 assertFalse(s.has(p3)); | 66 assertFalse(s.has(p3)); |
| 66 | 67 |
| 67 s.delete(p2); | 68 s.delete(p2); |
| 68 assertTrue(s.has(p1)); | 69 assertTrue(s.has(p1)); |
| 69 assertFalse(s.has(p2)); | 70 assertFalse(s.has(p2)); |
| 70 assertFalse(s.has(p3)); | 71 assertFalse(s.has(p3)); |
| 71 } | 72 } |
| 72 | 73 |
| 73 // TODO(neis): Reenable once proxies properly support these operations. | 74 TestSet(Set, Object.seal) |
| 74 // TestSet(Set, Object.seal) | 75 TestSet(Set, Object.freeze) |
| 75 // TestSet(Set, Object.freeze) | 76 TestSet(Set, Object.preventExtensions) |
| 76 // TestSet(Set, Object.preventExtensions) | |
| 77 | 77 |
| 78 | 78 |
| 79 // Maps and weak maps. | 79 // Maps and weak maps. |
| 80 | 80 |
| 81 function TestMap(construct, fix) { | 81 function TestMap(construct, fix) { |
| 82 TestWithProxies(TestMap2, construct, fix) | 82 TestWithProxies(TestMap2, construct, fix) |
| 83 } | 83 } |
| 84 | 84 |
| 85 function TestMap2(construct, fix, create) { | 85 function TestMap2(construct, fix, create) { |
| 86 var handler = {fix: function() { return {} }} | 86 var handler = {fix: function() { return {} }} |
| (...skipping 20 matching lines...) Expand all Loading... |
| 107 assertSame(321, m.get(p2)); | 107 assertSame(321, m.get(p2)); |
| 108 | 108 |
| 109 m.delete(p2); | 109 m.delete(p2); |
| 110 assertTrue(m.has(p1)); | 110 assertTrue(m.has(p1)); |
| 111 assertFalse(m.has(p2)); | 111 assertFalse(m.has(p2)); |
| 112 assertFalse(m.has(p3)); | 112 assertFalse(m.has(p3)); |
| 113 assertSame(123, m.get(p1)); | 113 assertSame(123, m.get(p1)); |
| 114 assertSame(undefined, m.get(p2)); | 114 assertSame(undefined, m.get(p2)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 // TODO(neis): Reenable once proxies properly support these operations. | 117 TestMap(Map, Object.seal) |
| 118 // TestMap(Map, Object.seal) | 118 TestMap(Map, Object.freeze) |
| 119 // TestMap(Map, Object.freeze) | 119 TestMap(Map, Object.preventExtensions) |
| 120 // TestMap(Map, Object.preventExtensions) | |
| 121 | 120 |
| 122 // TODO(neis): Reenable once proxies properly support these operations. | 121 TestMap(WeakMap, Object.seal) |
| 123 // TestMap(WeakMap, Object.seal) | 122 TestMap(WeakMap, Object.freeze) |
| 124 // TestMap(WeakMap, Object.freeze) | 123 TestMap(WeakMap, Object.preventExtensions) |
| 125 // TestMap(WeakMap, Object.preventExtensions) | |
| OLD | NEW |