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

Statements: 90.7% (78 / 86)      Branches: 65% (13 / 20)      Functions: 88.89% (16 / 18)      Lines: 93.98% (78 / 83)      Ignored: none     

All files » 6to5/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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 1341   1 37 37 15   37     1 26 2 2   24 24       1 4 4 4 4 4 4 4     1 19 19 19 19 19 19       1 2     1 71     1 673 673 673 651     1             1 7 7 7 7 7       1 13     1 858 836     1     457 457 457     1 1048   1048 137 137 137   911 911       1       1 5 5     1 20     1 13   13 13 13   13 20   20 7 7 7       13    
var _ = require("lodash");
 
exports.UnaryExpression = function (node, print) {
  this.push(node.operator);
  if (/[a-z]$/.test(node.operator) || node.argument.type === "UpdateExpression") {
    this.push(" ");
  }
  print(node.argument);
};
 
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) {
  this.push("(");
  print(node.test);
  this.push(" ? ");
  print(node.consequent);
  this.push(" : ");
  print(node.alternate);
  this.push(")");
};
 
exports.NewExpression = function (node, print) {
  this.push("new ");
  print(node.callee);
  Eif (node.arguments) {
    this.push("(");
    this.printJoin(print, node.arguments, ", ");
    this.push(")");
  }
};
 
exports.SequenceExpression = function (node, print) {
  this.printJoin(print, node.expressions, ", ");
};
 
exports.ThisExpression = function () {
  this.push("this");
};
 
exports.CallExpression = function (node, print) {
  print(node.callee);
  this.push("(");
  this.printJoin(print, node.arguments, ", ");
  this.push(")");
};
 
exports._maybeParans = function (node, print) {
  var is = _.contains(["FunctionExpression", "BinaryExpression", "AssignmentExpression"], node.type);
  if (is) this.push("(");
  print(node);
  if (is) this.push(")");
};
 
exports.YieldExpression = function (node, print) {
  this.push("yield");
  Iif (node.delegate) this.push("*");
  Eif (node.argument) {
    this.push(" ");
    print(node.argument);
  }
};
 
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);
  }
};
 
exports.ParenthesizedExpression = function (node, print) {
  throw new Error("ParenthesizedExpression");
};
 
exports.TaggedTemplateExpression = function (node, print) {
  print(node.tag);
  print(node.quasi);
};
 
exports.TemplateElement = function (node, print) {
  this.push(node.value.raw);
};
 
exports.TemplateLiteral = function (node, print) {
  this.push("`");
 
  var quasis = node.quasis;
  var self   = this;
  var len    = quasis.length;
 
  _.each(quasis, function (quasi, i) {
    print(quasi);
 
    if (i + 1 < len) {
      self.push("${ ");
      print(node.expressions[i]);
      self.push(" }");
    }
  });
 
  this.push("`");
};