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

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

Issue 1543553002: [proxies] Adapt and reenable remaining tests in proxies.js (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 getOwnPropertyDescriptor(k) { throw "myexn" } 1318 getOwnPropertyDescriptor(k) { throw "myexn" }
1319 }) 1319 })
1320 1320
1321 1321
1322 1322
1323 // --------------------------------------------------------------------------- 1323 // ---------------------------------------------------------------------------
1324 // String conversion (Object.prototype.toString, 1324 // String conversion (Object.prototype.toString,
1325 // Object.prototype.toLocaleString, 1325 // Object.prototype.toLocaleString,
1326 // Function.prototype.toString) 1326 // Function.prototype.toString)
1327 1327
1328 //TODO(cbruni): enable once fixed.
1329 /*
1330 var key 1328 var key
1331 1329
1332 function TestToString(handler) { 1330 function TestToString(handler) {
1333 var p = new Proxy({}, handler) 1331 var p = new Proxy({}, handler)
1334 key = "" 1332 key = ""
1335 assertEquals("[object Object]", Object.prototype.toString.call(p)) 1333 assertEquals("[object Object]", Object.prototype.toString.call(p))
1336 assertEquals("", key) 1334 assertEquals(Symbol.toStringTag, key)
1337 assertEquals("my_proxy", Object.prototype.toLocaleString.call(p)) 1335 assertEquals("my_proxy", Object.prototype.toLocaleString.call(p))
1338 assertEquals("toString", key) 1336 assertEquals("toString", key)
1339 1337
1340 var f = new Proxy(handler, function() {}) 1338 var f = new Proxy(function() {}, handler)
1341 key = "" 1339 key = ""
1342 assertEquals("[object Function]", Object.prototype.toString.call(f)) 1340 assertEquals("[object Function]", Object.prototype.toString.call(f))
1343 assertEquals("", key) 1341 assertEquals(Symbol.toStringTag, key)
1344 assertEquals("my_proxy", Object.prototype.toLocaleString.call(f)) 1342 assertEquals("my_proxy", Object.prototype.toLocaleString.call(f))
1345 assertEquals("toString", key) 1343 assertEquals("toString", key)
1346 assertDoesNotThrow(function(){ Function.prototype.toString.call(f) }) 1344 assertThrows(function(){ Function.prototype.toString.call(f) })
1347 1345
1348 var o = Object.create(p) 1346 var o = Object.create(p)
1349 key = "" 1347 key = ""
1350 assertEquals("[object Object]", Object.prototype.toString.call(o)) 1348 assertEquals("[object Object]", Object.prototype.toString.call(o))
1351 assertEquals("", key) 1349 assertEquals(Symbol.toStringTag, key)
1352 assertEquals("my_proxy", Object.prototype.toLocaleString.call(o)) 1350 assertEquals("my_proxy", Object.prototype.toLocaleString.call(o))
1353 assertEquals("toString", key) 1351 assertEquals("toString", key)
1354 } 1352 }
1355 1353
1356 TestToString({ 1354 TestToString({
1357 get: function(r, k) { key = k; return function() { return "my_proxy" } } 1355 get: function(r, k) { key = k; return function() { return "my_proxy" } }
1358 }) 1356 })
1359 1357
1360 TestToString({ 1358 TestToString({
1361 get: function(r, k) { return this.get2(r, k) }, 1359 get: function(r, k) { return this.get2(r, k) },
1362 get2: function(r, k) { key = k; return function() { return "my_proxy" } } 1360 get2: function(r, k) { key = k; return function() { return "my_proxy" } }
1363 }) 1361 })
1364 1362
1365 TestToString(new Proxy({}, { 1363 TestToString(new Proxy({}, {
1366 get: function(pr, pk) { 1364 get: function(pr, pk) {
1367 return function(r, k) { key = k; return function() { return "my_proxy" } } 1365 return function(r, k) { key = k; return function() { return "my_proxy" } }
1368 } 1366 }
1369 })) 1367 }))
1370 1368
1371 1369
1372 function TestToStringThrow(handler) { 1370 function TestToStringThrow(handler) {
1373 var p = new Proxy({}, handler) 1371 var p = new Proxy({}, handler)
1374 assertEquals("[object Object]", Object.prototype.toString.call(p)) 1372 assertThrows(() => Object.prototype.toString.call(p))
Camillo Bruni 2015/12/21 12:50:04 Could you check explicitly for the thrown error?
1375 assertThrows(function(){ Object.prototype.toLocaleString.call(p) }, "myexn") 1373 assertThrows(function(){ Object.prototype.toLocaleString.call(p) }, "myexn")
1376 1374
1377 var f = new Proxy(function(){}, handler) 1375 var f = new Proxy(function(){}, handler)
1378 assertEquals("[object Function]", Object.prototype.toString.call(f)) 1376 assertThrows(() => Object.prototype.toString.call(f))
1379 assertThrows(function(){ Object.prototype.toLocaleString.call(f) }, "myexn") 1377 assertThrows(function(){ Object.prototype.toLocaleString.call(f) }, "myexn")
1380 1378
1381 var o = Object.create(p) 1379 var o = Object.create(p)
1382 assertEquals("[object Object]", Object.prototype.toString.call(o)) 1380 assertThrows(() => Object.prototype.toString.call(o))
1383 assertThrows(function(){ Object.prototype.toLocaleString.call(o) }, "myexn") 1381 assertThrows(function(){ Object.prototype.toLocaleString.call(o) }, "myexn")
1384 } 1382 }
1385 1383
1386 TestToStringThrow({ 1384 TestToStringThrow({
1387 get: function(r, k) { throw "myexn" } 1385 get: function(r, k) { throw "myexn" }
1388 }) 1386 })
1389 1387
1390 TestToStringThrow({ 1388 TestToStringThrow({
1391 get: function(r, k) { return function() { throw "myexn" } }
1392 })
1393
1394 TestToStringThrow({
1395 get: function(r, k) { return this.get2(r, k) }, 1389 get: function(r, k) { return this.get2(r, k) },
1396 get2: function(r, k) { throw "myexn" } 1390 get2: function(r, k) { throw "myexn" }
1397 }) 1391 })
1398 1392
1399 TestToStringThrow(new Proxy({}, { 1393 TestToStringThrow(new Proxy({}, {
1400 get: function(pr, pk) { throw "myexn" } 1394 get: function(pr, pk) { throw "myexn" }
1401 })) 1395 }))
1402 1396
1403 TestToStringThrow(new Proxy({}, { 1397 TestToStringThrow(new Proxy({}, {
1404 get: function(pr, pk) { 1398 get: function(pr, pk) {
1405 return function(r, k) { throw "myexn" } 1399 return function(r, k) { throw "myexn" }
1406 } 1400 }
1407 })) 1401 }))
1408 */
1409 1402
1410 1403
1411 // --------------------------------------------------------------------------- 1404 // ---------------------------------------------------------------------------
1412 // Value conversion (Object.prototype.toValue) 1405 // Value conversion (Object.prototype.toValue)
1413 1406
1414 function TestValueOf(handler) { 1407 function TestValueOf(handler) {
1415 TestWithProxies(TestValueOf2, handler) 1408 TestWithProxies(TestValueOf2, handler)
1416 } 1409 }
1417 1410
1418 function TestValueOf2(create, handler) { 1411 function TestValueOf2(create, handler) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 var o = new C(); 1545 var o = new C();
1553 1546
1554 function f() { 1547 function f() {
1555 return o.x; 1548 return o.x;
1556 } 1549 }
1557 assertEquals(10, f()); 1550 assertEquals(10, f());
1558 assertEquals(10, f()); 1551 assertEquals(10, f());
1559 %OptimizeFunctionOnNextCall(f); 1552 %OptimizeFunctionOnNextCall(f);
1560 assertEquals(10, f()); 1553 assertEquals(10, f());
1561 })(); 1554 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698