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

Side by Side Diff: test/mjsunit/es6/iteration-semantics.js

Issue 1417063011: [runtime] support new Proxy() instead of Proxy.create and install getPrototypeOf trap (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: adding proxy trap strings Created 5 years, 1 month 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 function() { return "break" })); 302 function() { return "break" }));
303 assertEquals(false, 303 assertEquals(false,
304 try_control(integers_until(10), 304 try_control(integers_until(10),
305 function() { return "continue" })); 305 function() { return "continue" }));
306 assertEquals(5, 306 assertEquals(5,
307 try_control(integers_until(10), 307 try_control(integers_until(10),
308 function(x) { return (x == 5) ? x : "continue" })); 308 function(x) { return (x == 5) ? x : "continue" }));
309 309
310 // Proxy results, with getters. 310 // Proxy results, with getters.
311 function transparent_proxy(x) { 311 function transparent_proxy(x) {
312 return Proxy.create({ 312 return new Proxy({}, {
313 get: function(receiver, name) { return x[name]; } 313 get: function(receiver, name) { return x[name]; }
314 }); 314 });
315 } 315 }
316 assertEquals([1, 2], 316 assertEquals([1, 2],
317 fold(append, [], 317 fold(append, [],
318 results([one_time_getter({ value: 1 }, 'done', false), 318 results([one_time_getter({ value: 1 }, 'done', false),
319 one_time_getter({ done: false }, 'value', 2), 319 one_time_getter({ done: false }, 'value', 2),
320 { value: 37, done: true }, 320 { value: 37, done: true },
321 never_getter(never_getter({}, 'done'), 'value')] 321 never_getter(never_getter({}, 'done'), 'value')]
322 .map(transparent_proxy)))); 322 .map(transparent_proxy))));
323 323
324 // Proxy iterators. 324 // Proxy iterators.
325 function poison_proxy_after(iterable, n) { 325 function poison_proxy_after(iterable, n) {
326 var iterator = iterable[Symbol.iterator](); 326 var iterator = iterable[Symbol.iterator]();
327 return wrap_iterator(Proxy.create({ 327 return wrap_iterator(new Proxy({}, {
328 get: function(receiver, name) { 328 get: function(receiver, name) {
329 if (name == 'next' && n-- < 0) throw "unreachable"; 329 if (name == 'next' && n-- < 0) throw "unreachable";
330 return iterator[name]; 330 return iterator[name];
331 }, 331 },
332 // Needed for integers_until(10)'s this.n++. 332 // Needed for integers_until(10)'s this.n++.
333 set: function(receiver, name, val) { 333 set: function(receiver, name, val) {
334 return iterator[name] = val; 334 return iterator[name] = val;
335 } 335 }
336 })); 336 }));
337 } 337 }
(...skipping 13 matching lines...) Expand all
351 assertInstanceof(ex, TypeError); 351 assertInstanceof(ex, TypeError);
352 assertEquals(message, ex.message); 352 assertEquals(message, ex.message);
353 assertArrayEquals([1, undefined], arr); 353 assertArrayEquals([1, undefined], arr);
354 } 354 }
355 test_iterator_result_object_non_object(null); 355 test_iterator_result_object_non_object(null);
356 test_iterator_result_object_non_object(undefined); 356 test_iterator_result_object_non_object(undefined);
357 test_iterator_result_object_non_object(42); 357 test_iterator_result_object_non_object(42);
358 test_iterator_result_object_non_object('abc'); 358 test_iterator_result_object_non_object('abc');
359 test_iterator_result_object_non_object(false); 359 test_iterator_result_object_non_object(false);
360 test_iterator_result_object_non_object(Symbol('x'), 'Symbol(x)'); 360 test_iterator_result_object_non_object(Symbol('x'), 'Symbol(x)');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698