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

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

Issue 19384004: Proxies: Make 'with' work, plus minor other fixes (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 TestForIn(["null", "a"], { 56 TestForIn(["null", "a"], {
57 enumerate: function() { return this.enumerate2() }, 57 enumerate: function() { return this.enumerate2() },
58 enumerate2: function() { return [null, "a"] } 58 enumerate2: function() { return [null, "a"] }
59 }) 59 })
60 60
61 TestForIn(["b", "d"], { 61 TestForIn(["b", "d"], {
62 getPropertyNames: function() { return ["a", "b", "c", "d", "e"] }, 62 getPropertyNames: function() { return ["a", "b", "c", "d", "e"] },
63 getPropertyDescriptor: function(k) { 63 getPropertyDescriptor: function(k) {
64 switch (k) { 64 switch (k) {
65 case "a": return {enumerable: false, value: "3"}; 65 case "a": return {enumerable: false, value: "3", configurable: true};
66 case "b": return {enumerable: true, get get() {}}; 66 case "b": return {enumerable: true, get get() {}, configurable: true};
67 case "c": return {value: 4}; 67 case "c": return {value: 4, configurable: true};
68 case "d": return {get enumerable() { return true }}; 68 case "d": return {get enumerable() { return true }, configurable: true};
69 default: return undefined; 69 default: return undefined;
70 } 70 }
71 } 71 }
72 }) 72 })
73 73
74 TestForIn(["b", "a", "0", "c"], Proxy.create({ 74 TestForIn(["b", "a", "0", "c"], Proxy.create({
75 get: function(pr, pk) { 75 get: function(pr, pk) {
76 return function() { return ["b", "a", 0, "c"] } 76 return function() { return ["b", "a", 0, "c"] }
77 } 77 }
78 })) 78 }))
(...skipping 17 matching lines...) Expand all
96 var oo = Object.create(o) 96 var oo = Object.create(o)
97 oo.y = 0 97 oo.y = 0
98 var found = [] 98 var found = []
99 for (var x in oo) found.push(x) 99 for (var x in oo) found.push(x)
100 assertArrayEquals(["y", "z"].concat(properties), found) 100 assertArrayEquals(["y", "z"].concat(properties), found)
101 } 101 }
102 102
103 TestForInDerived(["0", "a"], { 103 TestForInDerived(["0", "a"], {
104 enumerate: function() { return [0, "a"] }, 104 enumerate: function() { return [0, "a"] },
105 getPropertyDescriptor: function(k) { 105 getPropertyDescriptor: function(k) {
106 return k == "0" || k == "a" ? {} : undefined 106 return k == "0" || k == "a" ? {configurable: true} : undefined
107 } 107 }
108 }) 108 })
109 109
110 TestForInDerived(["null", "a"], { 110 TestForInDerived(["null", "a"], {
111 enumerate: function() { return this.enumerate2() }, 111 enumerate: function() { return this.enumerate2() },
112 enumerate2: function() { return [null, "a"] }, 112 enumerate2: function() { return [null, "a"] },
113 getPropertyDescriptor: function(k) { 113 getPropertyDescriptor: function(k) {
114 return k == "null" || k == "a" ? {} : undefined 114 return k == "null" || k == "a" ? {configurable: true} : undefined
115 } 115 }
116 }) 116 })
117 117
118 TestForInDerived(["b", "d"], { 118 TestForInDerived(["b", "d"], {
119 getPropertyNames: function() { return ["a", "b", "c", "d", "e"] }, 119 getPropertyNames: function() { return ["a", "b", "c", "d", "e"] },
120 getPropertyDescriptor: function(k) { 120 getPropertyDescriptor: function(k) {
121 switch (k) { 121 switch (k) {
122 case "a": return {enumerable: false, value: "3"}; 122 case "a": return {enumerable: false, value: "3", configurable: true};
123 case "b": return {enumerable: true, get get() {}}; 123 case "b": return {enumerable: true, get get() {}, configurable: true};
124 case "c": return {value: 4}; 124 case "c": return {value: 4, configurable: true};
125 case "d": return {get enumerable() { return true }}; 125 case "d": return {get enumerable() { return true }, configurable: true};
126 default: return undefined; 126 default: return undefined;
127 } 127 }
128 } 128 }
129 }) 129 })
130 130
131 131
132 132
133 // Throw exception in enumerate trap. 133 // Throw exception in enumerate trap.
134 134
135 function TestForInThrow(handler) { 135 function TestForInThrow(handler) {
(...skipping 23 matching lines...) Expand all
159 TestForInThrow({ 159 TestForInThrow({
160 getPropertyNames: function() { return ["a"] }, 160 getPropertyNames: function() { return ["a"] },
161 getPropertyDescriptor: function() { throw "myexn" } 161 getPropertyDescriptor: function() { throw "myexn" }
162 }) 162 })
163 163
164 TestForInThrow(Proxy.create({ 164 TestForInThrow(Proxy.create({
165 get: function(pr, pk) { 165 get: function(pr, pk) {
166 return function() { throw "myexn" } 166 return function() { throw "myexn" }
167 } 167 }
168 })) 168 }))
OLDNEW
« src/proxy.js ('K') | « src/runtime.cc ('k') | test/mjsunit/harmony/proxies-with.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698