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