export_asserts.js 1.2 KB

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