tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ident-name-reserved-word-literal-accessor.js (1080B)


      1 // Copyright (c) 2012 Ecma International.  All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 es5id: 7.6.1-4-1
      6 description: >
      7    Allow reserved words as property names by accessor function within an object.
      8 ---*/
      9 
     10 var test;
     11 
     12 var tokenCodes = {
     13    set null(value) { test = 'null'; },
     14    get null() { return 'null'; },
     15    set true(value) { test = 'true'; },
     16    get true() { return 'true'; },
     17    set false(value) { test = 'false'; },
     18    get false() { return 'false'; },
     19 };
     20 
     21 var arr = [
     22        'null',
     23        'true',
     24        'false',
     25 ];
     26 
     27 for (var i = 0; i < arr.length; ++i) {
     28    var propertyName = arr[i];
     29 
     30    assert(tokenCodes.hasOwnProperty(propertyName),
     31           'Property "' + propertyName + '" found');
     32 
     33    assert.sameValue(tokenCodes[propertyName], propertyName,
     34                     'Property "' + propertyName + '" has correct value');
     35 
     36    tokenCodes[propertyName] = 0;
     37    assert.sameValue(test, propertyName,
     38                     'Property "' + propertyName + '" sets correct value');
     39 }
     40 
     41 reportCompare(0, 0);