@@ -1527,46 +1527,107 @@ test('Detects differences in deeply nested arrays instead of seeing a new object
15271527 ) ;
15281528} ) ;
15291529
1530- // check URL
1531- {
1532- const a = new URL ( 'http://foo' ) ;
1533- const b = new URL ( 'http://bar' ) ;
1530+ test ( 'URLs' , ( ) => {
1531+ // check URL
1532+ {
1533+ const a = new URL ( 'http://foo' ) ;
1534+ const b = new URL ( 'http://bar' ) ;
15341535
1535- assertNotDeepOrStrict ( a , b ) ;
1536- }
1536+ assertNotDeepOrStrict ( a , b ) ;
1537+ }
15371538
1538- {
1539- const a = new URL ( 'http://foo' ) ;
1540- const b = new URL ( 'http://foo' ) ;
1539+ {
1540+ const a = new URL ( 'http://foo' ) ;
1541+ const b = new URL ( 'http://foo' ) ;
15411542
1543+ assertDeepAndStrictEqual ( a , b ) ;
1544+ }
1545+
1546+ {
1547+ const a = new URL ( 'http://foo' ) ;
1548+ const b = new URL ( 'http://foo' ) ;
1549+ a . bar = 1 ;
1550+ b . bar = 2 ;
1551+ assertNotDeepOrStrict ( a , b ) ;
1552+ }
1553+
1554+ {
1555+ const a = new URL ( 'http://foo' ) ;
1556+ const b = new URL ( 'http://foo' ) ;
1557+ a . bar = 1 ;
1558+ b . bar = 1 ;
1559+ assertDeepAndStrictEqual ( a , b ) ;
1560+ }
1561+
1562+ {
1563+ const a = new URL ( 'http://foo' ) ;
1564+ const b = new URL ( 'http://bar' ) ;
1565+ assert . throws (
1566+ ( ) => assert . deepStrictEqual ( a , b ) ,
1567+ {
1568+ code : 'ERR_ASSERTION' ,
1569+ name : 'AssertionError' ,
1570+ message : / h t t p : \/ \/ b a r /
1571+ }
1572+ ) ;
1573+ }
1574+ } ) ;
1575+
1576+ test ( 'Own property constructor properties should check against the original prototype' , ( ) => {
1577+ const a = { constructor : { name : 'Foo' } } ;
1578+ const b = { constructor : { name : 'Foo' } } ;
15421579 assertDeepAndStrictEqual ( a , b ) ;
1543- }
15441580
1545- {
1546- const a = new URL ( 'http://foo' ) ;
1547- const b = new URL ( 'http://foo' ) ;
1548- a . bar = 1 ;
1549- b . bar = 2 ;
1550- assertNotDeepOrStrict ( a , b ) ;
1551- }
1581+ let prototype = { } ;
1582+ Object . setPrototypeOf ( a , prototype ) ;
1583+ Object . setPrototypeOf ( b , prototype ) ;
1584+ assertDeepAndStrictEqual ( a , b ) ;
15521585
1553- {
1554- const a = new URL ( 'http://foo' ) ;
1555- const b = new URL ( 'http://foo' ) ;
1556- a . bar = 1 ;
1557- b . bar = 1 ;
1586+ Object . setPrototypeOf ( b , { } ) ;
1587+ assertNotDeepOrStrict ( a , { } ) ;
1588+
1589+ prototype = { __proto__ : null } ;
1590+ Object . setPrototypeOf ( a , prototype ) ;
1591+ Object . setPrototypeOf ( b , prototype ) ;
15581592 assertDeepAndStrictEqual ( a , b ) ;
1559- }
15601593
1561- {
1562- const a = new URL ( 'http://foo' ) ;
1563- const b = new URL ( 'http://bar' ) ;
1564- assert . throws (
1565- ( ) => assert . deepStrictEqual ( a , b ) ,
1566- {
1567- code : 'ERR_ASSERTION' ,
1568- name : 'AssertionError' ,
1569- message : / h t t p : \/ \/ b a r /
1570- }
1571- ) ;
1572- }
1594+ Object . setPrototypeOf ( b , { __proto__ : null } ) ;
1595+ assert . notDeepStrictEqual ( a , b ) ;
1596+ assert . notDeepStrictEqual ( b , a ) ;
1597+
1598+ // Turn off no-restricted-properties because we are testing deepEqual!
1599+ /* eslint-disable no-restricted-properties */
1600+ assert . deepEqual ( a , b ) ;
1601+ assert . deepEqual ( b , a ) ;
1602+ } ) ;
1603+
1604+ test ( 'Inherited null prototype without own constructor properties should check the correct prototype' , ( ) => {
1605+ const a = { foo : { name : 'Foo' } } ;
1606+ const b = { foo : { name : 'Foo' } } ;
1607+ assertDeepAndStrictEqual ( a , b ) ;
1608+
1609+ let prototype = { } ;
1610+ Object . setPrototypeOf ( a , prototype ) ;
1611+ Object . setPrototypeOf ( b , prototype ) ;
1612+ assertDeepAndStrictEqual ( a , b ) ;
1613+
1614+ Object . setPrototypeOf ( b , { } ) ;
1615+ assertNotDeepOrStrict ( a , { } ) ;
1616+
1617+ prototype = { __proto__ : null } ;
1618+ Object . setPrototypeOf ( a , prototype ) ;
1619+ Object . setPrototypeOf ( b , prototype ) ;
1620+ assertDeepAndStrictEqual ( a , b ) ;
1621+
1622+ Object . setPrototypeOf ( b , { __proto__ : null } ) ;
1623+ assert . notDeepStrictEqual ( a , b ) ;
1624+ assert . notDeepStrictEqual ( b , a ) ;
1625+
1626+ assert . notDeepStrictEqual ( { __proto__ : null } , { __proto__ : { __proto__ : null } } ) ;
1627+ assert . notDeepStrictEqual ( { __proto__ : { __proto__ : null } } , { __proto__ : null } ) ;
1628+
1629+ // Turn off no-restricted-properties because we are testing deepEqual!
1630+ /* eslint-disable no-restricted-properties */
1631+ assert . deepEqual ( a , b ) ;
1632+ assert . deepEqual ( b , a ) ;
1633+ } ) ;
0 commit comments