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

Statements: 98.65% (73 / 74)      Branches: 88.46% (23 / 26)      Functions: 100% (14 / 14)      Lines: 98.61% (71 / 72)      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 112 113 114 115 116 117 1181 1   1 136 136   136 10     136 2     136 136 136     1 116 116 116     1 45 14 14   31 31       1 43 43 43 43 43     1 37 37 37 37 37 37       1 20     1 151     1 1741 1741 1741 1741     1 2 11 11 11 11 11         1 1   1 6     1 1784 1784     1     1278 1278 1278     1 2753   2753 243 243 243     2510       2510 2510      
var util = require("../../util");
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);
    if (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 {
    // 5..toFixed(2);
    Iif (t.isLiteral(node.object) && util.isInteger(node.object.value)) {
      this.push(".");
    }
 
    this.push(".");
    print(node.property);
  }
};