export_asserts.js 856 B

123456789101112131415161718192021222324252627282930313233
  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. exports.COMPILED = COMPILED