Code coverage report for 6to5/generation/generators/expressions.js

Statements: 98.59% (70 / 71)      Branches: 86.36% (19 / 22)      Functions: 100% (14 / 14)      Lines: 100% (69 / 69)      Ignored: none     

All files » 6to5/generation/generators/ » expressions.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 1121   1 54 54   54 5     54 1     54 54 54     1 100 100 100     1 26 2 2   24 24       1 5 5 5 5 5     1 16 16 16 16 16 16       1 3     1 36     1 476 476 476 476     1 2 7 7 7 7 7         1 1   1 3     1 644 644     1     390 390 390     1 719   719 85 85 85   634 634      
var t = require("../../types");
 
exports.UnaryExpression = function (node, print) {
  var hasSpace = /[a-z]$/.test(node.operator);
  var arg = node.argument;
 
  if (t.isUpdateExpression(arg) || t.isUnaryExpression(arg)) {
    hasSpace = true;
  }
 
  if (t.isUnaryExpression(arg) && arg.operator === "!") {
    hasSpace = false;
  }
 
  this.push(node.operator);
  if (hasSpace) this.space();
  print(node.argument);
};
 
exports.ParenthesizedExpression = function (node, print) {
  this.push("(");
  print(node.expression);
  this.push(")");
};
 
exports.UpdateExpression = function (node, print) {
  if (node.prefix) {
    this.push(node.operator);
    print(node.argument);
  } else {
    print(node.argument);
    this.push(node.operator);
  }
};
 
exports.ConditionalExpression = function (node, print) {
  print(node.test);
  this.push(" ? ");
  print(node.consequent);
  this.push(" : ");
  print(node.alternate);
};
 
exports.NewExpression = function (node, print) {
  this.push("new ");
  print(node.callee);
  Eif (node.arguments.length || this.format.parentheses) {
    this.push("(");
    print.join(node.arguments, { separator: ", " });
    this.push(")");
  }
};
 
exports.SequenceExpression = function (node, print) {
  print.join(node.expressions, { separator: ", " });
};
 
exports.ThisExpression = function () {
  this.push("this");
};
 
exports.CallExpression = function (node, print) {
  print(node.callee);
  this.push("(");
  print.join(node.arguments, { separator: ", " });
  this.push(")");
};
 
var buildYieldAwait = function (keyword) {
  return function (node, print) {
    this.push(keyword);
    Iif (node.delegate) this.push("*");
    Eif (node.argument) {
      this.space();
      print(node.argument);
    }
  };
};
 
exports.YieldExpression = buildYieldAwait("yield");
exports.AwaitExpression = buildYieldAwait("await");
 
exports.EmptyStatement = function () {
  this.semicolon();
};
 
exports.ExpressionStatement = function (node, print) {
  print(node.expression);
  this.semicolon();
};
 
exports.BinaryExpression =
exports.LogicalExpression =
exports.AssignmentExpression = function (node, print) {
  print(node.left);
  this.push(" " + node.operator + " ");
  print(node.right);
};
 
exports.MemberExpression = function (node, print) {
  print(node.object);
 
  if (node.computed) {
    this.push("[");
    print(node.property);
    this.push("]");
  } else {
    this.push(".");
    print(node.property);
  }
};