export_asserts.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. // Include a dummy provide statement so that closurebuilder.py does not skip over this
  9. // file.
  10. goog.provide('jspb.ExportAsserts');
  11. goog.require('goog.testing.asserts');
  12. var global = Function('return this')();
  13. // All of the closure "assert" functions are exported at the global level.
  14. //
  15. // The Google Closure assert functions start with assert, eg.
  16. // assertThrows
  17. // assertNotThrows
  18. // assertTrue
  19. // ...
  20. //
  21. // The one exception is the "fail" function.
  22. function shouldExport(str) {
  23. return str.lastIndexOf('assert') === 0 || str == 'fail';
  24. }
  25. for (var key in global) {
  26. if ((typeof key == "string") && global.hasOwnProperty(key) &&
  27. shouldExport(key)) {
  28. exports[key] = global[key];
  29. }
  30. }
  31. // The COMPILED variable is set by Closure compiler to "true" when it compiles
  32. // JavaScript, so in practice this is equivalent to "exports.COMPILED = true".
  33. // This will disable some debugging functionality in debug.js. We could
  34. // investigate whether this can/should be enabled in CommonJS builds.
  35. exports.COMPILED = COMPILED