Code coverage report for spec/env/common.js

Statements: 16.67% (5 / 30)      Branches: 0% (0 / 22)      Functions: 0% (0 / 5)      Lines: 16.67% (5 / 30)      Ignored: none     

All files » spec/env/ » common.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  1       1             1                                   1           1                                  
/*global CompilerContext, compileWithPartials, shouldCompileToWithPartials */
global.shouldCompileTo = function(string, hashOrArray, expected, message) {
  shouldCompileToWithPartials(string, hashOrArray, false, expected, message);
};
 
global.shouldCompileToWithPartials = function(string, hashOrArray, partials, expected, message) {
  var result = compileWithPartials(string, hashOrArray, partials);
  if (result !== expected) {
    throw new Error("'" + result + "' should === '" + expected + "': " + message);
  }
};
 
global.compileWithPartials = function(string, hashOrArray, partials) {
  var template,
      ary,
      options;
  if(Object.prototype.toString.call(hashOrArray) === "[object Array]") {
    ary = [];
    ary.push(hashOrArray[0]);
    ary.push({ helpers: hashOrArray[1], partials: hashOrArray[2] });
    options = {compat: hashOrArray[3]};
  } else {
    ary = [hashOrArray];
  }
 
  template = CompilerContext[partials ? 'compileWithPartial' : 'compile'](string, options);
  return template.apply(this, ary);
};
 
 
global.equals = global.equal = function(a, b, msg) {
  if (a !== b) {
    throw new Error("'" + a + "' should === '" + b + "'" + (msg ? ": " + msg : ''));
  }
};
 
global.shouldThrow = function(callback, type, msg) {
  var failed;
  try {
    callback();
    failed = true;
  } catch (err) {
    if (type && !(err instanceof type)) {
      throw new Error('Type failure');
    }
    if (msg && !(msg.test ? msg.test(err.message) : msg === err.message)) {
      throw new Error('Message failure');
    }
  }
  if (failed) {
    throw new Error('It failed to throw');
  }
};