1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/addon-sdk/source/test/test-set-exports.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,37 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +let four = require("./modules/exportsEquals"); 1.9 +exports.testExportsEquals = function(assert) { 1.10 + assert.equal(four, 4); 1.11 +}; 1.12 + 1.13 +/* TODO: Discuss idea of dropping support for this feature that was alternative 1.14 + to `module.exports = ..` that failed. 1.15 +let five = require("./modules/setExports"); 1.16 +exports.testSetExports = function(assert) { 1.17 + assert.equal(five, 5); 1.18 +} 1.19 + 1.20 +exports.testDupeSetExports = function(assert) { 1.21 + var passed = false; 1.22 + try { 1.23 + var dupe = require('./modules/dupeSetExports'); 1.24 + } catch(e) { 1.25 + passed = /define\(\) was used, so module\.exports= and module\.setExports\(\) may not be used/.test(e.toString()); 1.26 + } 1.27 + assert.equal(passed, true, 'define() or setExports(), not both'); 1.28 +} 1.29 +*/ 1.30 + 1.31 +exports.testModule = function(assert) { 1.32 + // module.id is not cast in stone yet. In the future, it may include the 1.33 + // package name, or may possibly be a/ URL of some sort. For now, it's a 1.34 + // URL that starts with resource: and ends with this module name, but the 1.35 + // part in between varies depending upon how the test is run. 1.36 + var found = /test-set-exports$/.test(module.id); 1.37 + assert.equal(found, true, module.id+" ends with test-set-exports.js"); 1.38 +}; 1.39 + 1.40 +require('sdk/test').run(exports);