export_asserts.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * @fileoverview Exports symbols needed only by tests.
  3. *
  4. * This file exports several Closure Library symbols that are only
  5. * used by tests. It is used to generate a file
  6. * closure_asserts_commonjs.js that is only used at testing time.
  7. */
  8. goog.require('goog.testing.asserts');
  9. var global = Function('return this')();
  10. // All of the closure "assert" functions are exported at the global level.
  11. //
  12. // The Google Closure assert functions start with assert, eg.
  13. // assertThrows
  14. // assertNotThrows
  15. // assertTrue
  16. // ...
  17. //
  18. // The one exception is the "fail" function.
  19. function shouldExport(str) {
  20. return str.lastIndexOf('assert') === 0 || str == 'fail';
  21. }
  22. for (var key in global) {
  23. if ((typeof key == "string") && global.hasOwnProperty(key) &&
  24. shouldExport(key)) {
  25. exports[key] = global[key];
  26. }
  27. }
  28. // The COMPILED variable is set by Closure compiler to "true" when it compiles
  29. // JavaScript, so in practice this is equivalent to "exports.COMPILED = true".
  30. // This will disable some debugging functionality in debug.js. We could
  31. // investigate whether this can/should be enabled in CommonJS builds.
  32. exports.COMPILED = COMPILED