tor-browser

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

chainable.js (1476B)


      1 // Copyright (C) 2019 Leo Balter. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: >
      6    If the CoalesceExpressionHead is undefined or null, follow return the right-side value.
      7    Otherwise, return the left-side value.
      8 esid: sec-conditional-operator
      9 info: |
     10    ConditionalExpression :
     11        ShortCircuitExpression
     12        ShortCircuitExpression ? AssignmentExpression : AssignmentExpression
     13 
     14    ShortCircuitExpression :
     15        LogicalORExpression
     16        CoalesceExpression
     17 
     18    CoalesceExpression :
     19        CoalesceExpressionHead ?? BitwiseORExpression
     20 
     21    CoalesceExpressionHead :
     22        CoalesceExpression
     23        BitwiseORExpression
     24 
     25    Runtime Semantics: Evaluation
     26 
     27    CoalesceExpression:CoalesceExpressionHead??BitwiseORExpression
     28 
     29    1. Let lref be the result of evaluating CoalesceExpressionHead.
     30    2. Let lval be ? GetValue(lref).
     31    3. If lval is undefined or null,
     32        a. Let rref be the result of evaluating BitwiseORExpression.
     33        b. Return ? GetValue(rref).
     34    4. Otherwise, return lval.
     35 features: [coalesce-expression]
     36 ---*/
     37 
     38 var x;
     39 
     40 x = null ?? undefined ?? 42;
     41 assert.sameValue(x, 42, 'null ?? undefined ?? 42');
     42 
     43 x = undefined ?? null ?? 42;
     44 assert.sameValue(x, 42, 'undefined ?? null ?? 42');
     45 
     46 x = null ?? null ?? 42;
     47 assert.sameValue(x, 42, 'null ?? null ?? 42');
     48 
     49 x = undefined ?? undefined ?? 42;
     50 assert.sameValue(x, 42, 'null ?? null ?? 42');
     51 
     52 reportCompare(0, 0);