export_asserts.js 1.13 KB
Newer Older
1
/**
2 3 4 5 6
 * @fileoverview Exports symbols needed only by tests.
 *
 * This file exports several Closure Library symbols that are only
 * used by tests.  It is used to generate a file
 * closure_asserts_commonjs.js that is only used at testing time.
7 8 9 10 11 12
 */

goog.require('goog.testing.asserts');

var global = Function('return this')();

13 14
// All of the closure "assert" functions are exported at the global level.
//
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
// The Google Closure assert functions start with assert, eg.
//   assertThrows
//   assertNotThrows
//   assertTrue
//   ...
//
// The one exception is the "fail" function.
function shouldExport(str) {
  return str.lastIndexOf('assert') === 0 || str == 'fail';
}

for (var key in global) {
  if ((typeof key == "string") && global.hasOwnProperty(key) &&
      shouldExport(key)) {
    exports[key] = global[key];
  }
}

33 34 35 36
// The COMPILED variable is set by Closure compiler to "true" when it compiles
// JavaScript, so in practice this is equivalent to "exports.COMPILED = true".
// This will disable some debugging functionality in debug.js.  We could
// investigate whether this can/should be enabled in CommonJS builds.
37
exports.COMPILED = COMPILED