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

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

Issue 8520001: Fix instanceof a function proxy. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('k') | 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 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 TestHasOwnThrow(Proxy.create({ 1430 TestHasOwnThrow(Proxy.create({
1431 get: function(pr, pk) { 1431 get: function(pr, pk) {
1432 return function(k) { throw "myexn" } 1432 return function(k) { throw "myexn" }
1433 } 1433 }
1434 })) 1434 }))
1435 1435
1436 1436
1437 1437
1438 // Instanceof (instanceof) 1438 // Instanceof (instanceof)
1439 1439
1440 function TestInstanceof() { 1440 function TestProxyInstanceof() {
1441 var o1 = {} 1441 var o1 = {}
1442 var p1 = Proxy.create({}) 1442 var p1 = Proxy.create({})
1443 var p2 = Proxy.create({}, o1) 1443 var p2 = Proxy.create({}, o1)
1444 var p3 = Proxy.create({}, p2) 1444 var p3 = Proxy.create({}, p2)
1445 var o2 = Object.create(p2) 1445 var o2 = Object.create(p2)
1446 1446
1447 var f0 = function() {} 1447 var f0 = function() {}
1448 f0.prototype = o1 1448 f0.prototype = o1
1449 var f1 = function() {} 1449 var f1 = function() {}
1450 f1.prototype = p1 1450 f1.prototype = p1
(...skipping 25 matching lines...) Expand all
1476 assertTrue(o2 instanceof Object) 1476 assertTrue(o2 instanceof Object)
1477 assertTrue(o2 instanceof f0) 1477 assertTrue(o2 instanceof f0)
1478 assertFalse(o2 instanceof f1) 1478 assertFalse(o2 instanceof f1)
1479 assertTrue(o2 instanceof f2) 1479 assertTrue(o2 instanceof f2)
1480 assertFalse(o2 instanceof f3) 1480 assertFalse(o2 instanceof f3)
1481 1481
1482 var f = Proxy.createFunction({}, function() {}) 1482 var f = Proxy.createFunction({}, function() {})
1483 assertTrue(f instanceof Function) 1483 assertTrue(f instanceof Function)
1484 } 1484 }
1485 1485
1486 TestInstanceof() 1486 TestProxyInstanceof()
1487
1488
1489 function TestInstanceofProxy() {
1490 var o0 = Object.create(null)
1491 var o1 = {}
1492 var o2 = Object.create(o0)
1493 var o3 = Object.create(o1)
1494 var o4 = Object.create(o2)
1495 var o5 = Object.create(o3)
1496
1497 function handler(o) { return {get: function() { return o } } }
1498 var f0 = Proxy.createFunction(handler(o0), function() {})
1499 var f1 = Proxy.createFunction(handler(o1), function() {})
1500 var f2 = Proxy.createFunction(handler(o2), function() {})
1501 var f3 = Proxy.createFunction(handler(o3), function() {})
1502 var f4 = Proxy.createFunction(handler(o4), function() {})
1503 var f5 = Proxy.createFunction(handler(o4), function() {})
1504
1505 assertFalse(null instanceof f0)
1506 assertFalse(o0 instanceof f0)
1507 assertFalse(o0 instanceof f1)
1508 assertFalse(o0 instanceof f2)
1509 assertFalse(o0 instanceof f3)
1510 assertFalse(o0 instanceof f4)
1511 assertFalse(o0 instanceof f5)
1512 assertFalse(o1 instanceof f0)
1513 assertFalse(o1 instanceof f1)
1514 assertFalse(o1 instanceof f2)
1515 assertFalse(o1 instanceof f3)
1516 assertFalse(o1 instanceof f4)
1517 assertFalse(o1 instanceof f5)
1518 assertTrue(o2 instanceof f0)
1519 assertFalse(o2 instanceof f1)
1520 assertFalse(o2 instanceof f2)
1521 assertFalse(o2 instanceof f3)
1522 assertFalse(o2 instanceof f4)
1523 assertFalse(o2 instanceof f5)
1524 assertFalse(o3 instanceof f0)
1525 assertTrue(o3 instanceof f1)
1526 assertFalse(o3 instanceof f2)
1527 assertFalse(o3 instanceof f3)
1528 assertFalse(o3 instanceof f4)
1529 assertFalse(o3 instanceof f5)
1530 assertTrue(o4 instanceof f0)
1531 assertFalse(o4 instanceof f1)
1532 assertTrue(o4 instanceof f2)
1533 assertFalse(o4 instanceof f3)
1534 assertFalse(o4 instanceof f4)
1535 assertFalse(o4 instanceof f5)
1536 assertFalse(o5 instanceof f0)
1537 assertTrue(o5 instanceof f1)
1538 assertFalse(o5 instanceof f2)
1539 assertTrue(o5 instanceof f3)
1540 assertFalse(o5 instanceof f4)
1541 assertFalse(o5 instanceof f5)
1542
1543 var f = Proxy.createFunction({}, function() {})
1544 var ff = Proxy.createFunction(handler(Function), function() {})
1545 assertTrue(f instanceof Function)
1546 assertFalse(f instanceof ff)
1547 }
1548
1549 TestInstanceofProxy()
1487 1550
1488 1551
1489 1552
1490 // Prototype (Object.getPrototypeOf, Object.prototype.isPrototypeOf). 1553 // Prototype (Object.getPrototypeOf, Object.prototype.isPrototypeOf).
1491 1554
1492 function TestPrototype() { 1555 function TestPrototype() {
1493 var o1 = {} 1556 var o1 = {}
1494 var p1 = Proxy.create({}) 1557 var p1 = Proxy.create({})
1495 var p2 = Proxy.create({}, o1) 1558 var p2 = Proxy.create({}, o1)
1496 var p3 = Proxy.create({}, p2) 1559 var p3 = Proxy.create({}, p2)
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
2187 2250
2188 TestIsEnumerableThrow(Proxy.create({ 2251 TestIsEnumerableThrow(Proxy.create({
2189 get: function(pr, pk) { throw "myexn" } 2252 get: function(pr, pk) { throw "myexn" }
2190 })) 2253 }))
2191 2254
2192 TestIsEnumerableThrow(Proxy.create({ 2255 TestIsEnumerableThrow(Proxy.create({
2193 get: function(pr, pk) { 2256 get: function(pr, pk) {
2194 return function(k) { throw "myexn" } 2257 return function(k) { throw "myexn" }
2195 } 2258 }
2196 })) 2259 }))
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698