test-set-exports.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. let four = require("./modules/exportsEquals");
  5. exports.testExportsEquals = function(assert) {
  6. assert.equal(four, 4);
  7. };
  8. /* TODO: Discuss idea of dropping support for this feature that was alternative
  9. to `module.exports = ..` that failed.
  10. let five = require("./modules/setExports");
  11. exports.testSetExports = function(assert) {
  12. assert.equal(five, 5);
  13. }
  14. exports.testDupeSetExports = function(assert) {
  15. var passed = false;
  16. try {
  17. var dupe = require('./modules/dupeSetExports');
  18. } catch(e) {
  19. passed = /define\(\) was used, so module\.exports= and module\.setExports\(\) may not be used/.test(e.toString());
  20. }
  21. assert.equal(passed, true, 'define() or setExports(), not both');
  22. }
  23. */
  24. exports.testModule = function(assert) {
  25. // module.id is not cast in stone yet. In the future, it may include the
  26. // package name, or may possibly be a/ URL of some sort. For now, it's a
  27. // URL that starts with resource: and ends with this module name, but the
  28. // part in between varies depending upon how the test is run.
  29. var found = /test-set-exports$/.test(module.id);
  30. assert.equal(found, true, module.id+" ends with test-set-exports.js");
  31. };
  32. require('sdk/test').run(exports);