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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 TestWithProxies(TestSet2, construct, fix) | 44 TestWithProxies(TestSet2, construct, fix) |
45 } | 45 } |
46 | 46 |
47 function TestSet2(construct, fix, create) { | 47 function TestSet2(construct, fix, create) { |
48 var handler = {fix: function() { return {} }} | 48 var handler = {fix: function() { return {} }} |
49 var p1 = create(handler) | 49 var p1 = create(handler) |
50 var p2 = create(handler) | 50 var p2 = create(handler) |
51 var p3 = create(handler) | 51 var p3 = create(handler) |
52 fix(p3) | 52 fix(p3) |
53 | 53 |
54 var s = construct(); | 54 var s = new construct(); |
55 s.add(p1); | 55 s.add(p1); |
56 s.add(p2); | 56 s.add(p2); |
57 assertTrue(s.has(p1)); | 57 assertTrue(s.has(p1)); |
58 assertTrue(s.has(p2)); | 58 assertTrue(s.has(p2)); |
59 assertFalse(s.has(p3)); | 59 assertFalse(s.has(p3)); |
60 | 60 |
61 fix(p1) | 61 fix(p1) |
62 fix(p2) | 62 fix(p2) |
63 assertTrue(s.has(p1)); | 63 assertTrue(s.has(p1)); |
64 assertTrue(s.has(p2)); | 64 assertTrue(s.has(p2)); |
(...skipping 16 matching lines...) Expand all Loading... |
81 TestWithProxies(TestMap2, construct, fix) | 81 TestWithProxies(TestMap2, construct, fix) |
82 } | 82 } |
83 | 83 |
84 function TestMap2(construct, fix, create) { | 84 function TestMap2(construct, fix, create) { |
85 var handler = {fix: function() { return {} }} | 85 var handler = {fix: function() { return {} }} |
86 var p1 = create(handler) | 86 var p1 = create(handler) |
87 var p2 = create(handler) | 87 var p2 = create(handler) |
88 var p3 = create(handler) | 88 var p3 = create(handler) |
89 fix(p3) | 89 fix(p3) |
90 | 90 |
91 var m = construct(); | 91 var m = new construct(); |
92 m.set(p1, 123); | 92 m.set(p1, 123); |
93 m.set(p2, 321); | 93 m.set(p2, 321); |
94 assertTrue(m.has(p1)); | 94 assertTrue(m.has(p1)); |
95 assertTrue(m.has(p2)); | 95 assertTrue(m.has(p2)); |
96 assertFalse(m.has(p3)); | 96 assertFalse(m.has(p3)); |
97 assertSame(123, m.get(p1)); | 97 assertSame(123, m.get(p1)); |
98 assertSame(321, m.get(p2)); | 98 assertSame(321, m.get(p2)); |
99 | 99 |
100 fix(p1) | 100 fix(p1) |
101 fix(p2) | 101 fix(p2) |
(...skipping 11 matching lines...) Expand all Loading... |
113 assertSame(undefined, m.get(p2)); | 113 assertSame(undefined, m.get(p2)); |
114 } | 114 } |
115 | 115 |
116 TestMap(Map, Object.seal) | 116 TestMap(Map, Object.seal) |
117 TestMap(Map, Object.freeze) | 117 TestMap(Map, Object.freeze) |
118 TestMap(Map, Object.preventExtensions) | 118 TestMap(Map, Object.preventExtensions) |
119 | 119 |
120 TestMap(WeakMap, Object.seal) | 120 TestMap(WeakMap, Object.seal) |
121 TestMap(WeakMap, Object.freeze) | 121 TestMap(WeakMap, Object.freeze) |
122 TestMap(WeakMap, Object.preventExtensions) | 122 TestMap(WeakMap, Object.preventExtensions) |
OLD | NEW |