diff options
Diffstat (limited to 'addon-sdk/source/test/modules')
25 files changed, 234 insertions, 0 deletions
diff --git a/addon-sdk/source/test/modules/add.js b/addon-sdk/source/test/modules/add.js new file mode 100644 index 000000000..54729340d --- /dev/null +++ b/addon-sdk/source/test/modules/add.js @@ -0,0 +1,9 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +define('modules/add', function () { + return function (a, b) { + return a + b; + }; +}); diff --git a/addon-sdk/source/test/modules/async1.js b/addon-sdk/source/test/modules/async1.js new file mode 100644 index 000000000..b7b60fdc2 --- /dev/null +++ b/addon-sdk/source/test/modules/async1.js @@ -0,0 +1,14 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +define(['./traditional2', './async2'], function () { + var traditional2 = require('./traditional2'); + return { + name: 'async1', + traditional1Name: traditional2.traditional1Name, + traditional2Name: traditional2.name, + async2Name: require('./async2').name, + async2Traditional2Name: require('./async2').traditional2Name + }; +}); diff --git a/addon-sdk/source/test/modules/async2.js b/addon-sdk/source/test/modules/async2.js new file mode 100644 index 000000000..802fb2504 --- /dev/null +++ b/addon-sdk/source/test/modules/async2.js @@ -0,0 +1,8 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +define(['./traditional2', 'exports'], function (traditional2, exports) { + exports.name = 'async2'; + exports.traditional2Name = traditional2.name; +}); diff --git a/addon-sdk/source/test/modules/badExportAndReturn.js b/addon-sdk/source/test/modules/badExportAndReturn.js new file mode 100644 index 000000000..35a5359f6 --- /dev/null +++ b/addon-sdk/source/test/modules/badExportAndReturn.js @@ -0,0 +1,10 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// This is a bad module, it asks for exports but also returns a value from +// the define defintion function. +define(['exports'], function (exports) { + return 'badExportAndReturn'; +}); + diff --git a/addon-sdk/source/test/modules/badFirst.js b/addon-sdk/source/test/modules/badFirst.js new file mode 100644 index 000000000..fdb03bd4d --- /dev/null +++ b/addon-sdk/source/test/modules/badFirst.js @@ -0,0 +1,9 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +define(['./badSecond'], function (badSecond) { + return { + name: 'badFirst' + }; +}); diff --git a/addon-sdk/source/test/modules/badSecond.js b/addon-sdk/source/test/modules/badSecond.js new file mode 100644 index 000000000..8321a8542 --- /dev/null +++ b/addon-sdk/source/test/modules/badSecond.js @@ -0,0 +1,8 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +var first = require('./badFirst'); + +exports.name = 'badSecond'; +exports.badFirstName = first.name; diff --git a/addon-sdk/source/test/modules/blue.js b/addon-sdk/source/test/modules/blue.js new file mode 100644 index 000000000..14ab14933 --- /dev/null +++ b/addon-sdk/source/test/modules/blue.js @@ -0,0 +1,9 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +define(function () { + return { + name: 'blue' + }; +}); diff --git a/addon-sdk/source/test/modules/castor.js b/addon-sdk/source/test/modules/castor.js new file mode 100644 index 000000000..9209623b5 --- /dev/null +++ b/addon-sdk/source/test/modules/castor.js @@ -0,0 +1,10 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +define(['exports', './pollux'], function(exports, pollux) { + exports.name = 'castor'; + exports.getPolluxName = function () { + return pollux.name; + }; +}); diff --git a/addon-sdk/source/test/modules/cheetah.js b/addon-sdk/source/test/modules/cheetah.js new file mode 100644 index 000000000..37d12bfc1 --- /dev/null +++ b/addon-sdk/source/test/modules/cheetah.js @@ -0,0 +1,9 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +define(function () { + return function () { + return 'cheetah'; + }; +}); diff --git a/addon-sdk/source/test/modules/color.js b/addon-sdk/source/test/modules/color.js new file mode 100644 index 000000000..0d946bd99 --- /dev/null +++ b/addon-sdk/source/test/modules/color.js @@ -0,0 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +define({ + type: 'color' +}); diff --git a/addon-sdk/source/test/modules/dupe.js b/addon-sdk/source/test/modules/dupe.js new file mode 100644 index 000000000..f87fa555a --- /dev/null +++ b/addon-sdk/source/test/modules/dupe.js @@ -0,0 +1,15 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +define({ + name: 'dupe' +}); + +// This is wrong and should not be allowed. Only one call to +// define per file. +define([], function () { + return { + name: 'dupe2' + }; +}); diff --git a/addon-sdk/source/test/modules/dupeNested.js b/addon-sdk/source/test/modules/dupeNested.js new file mode 100644 index 000000000..703948ca7 --- /dev/null +++ b/addon-sdk/source/test/modules/dupeNested.js @@ -0,0 +1,15 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +define(function () { + // This is wrong and should not be allowed. + define('dupeNested2', { + name: 'dupeNested2' + }); + + return { + name: 'dupeNested' + }; +}); diff --git a/addon-sdk/source/test/modules/dupeSetExports.js b/addon-sdk/source/test/modules/dupeSetExports.js new file mode 100644 index 000000000..12a1be22b --- /dev/null +++ b/addon-sdk/source/test/modules/dupeSetExports.js @@ -0,0 +1,8 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +define({name: "dupeSetExports"}); + +// so this should cause a failure +module.setExports("no no no"); diff --git a/addon-sdk/source/test/modules/exportsEquals.js b/addon-sdk/source/test/modules/exportsEquals.js new file mode 100644 index 000000000..e176316f4 --- /dev/null +++ b/addon-sdk/source/test/modules/exportsEquals.js @@ -0,0 +1,5 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +module.exports = 4; diff --git a/addon-sdk/source/test/modules/green.js b/addon-sdk/source/test/modules/green.js new file mode 100644 index 000000000..ce2d134b9 --- /dev/null +++ b/addon-sdk/source/test/modules/green.js @@ -0,0 +1,10 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +define('modules/green', ['./color'], function (color) { + return { + name: 'green', + parentType: color.type + }; +}); diff --git a/addon-sdk/source/test/modules/lion.js b/addon-sdk/source/test/modules/lion.js new file mode 100644 index 000000000..9c3ac3bfe --- /dev/null +++ b/addon-sdk/source/test/modules/lion.js @@ -0,0 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +define(function(require) { + return 'lion'; +}); diff --git a/addon-sdk/source/test/modules/orange.js b/addon-sdk/source/test/modules/orange.js new file mode 100644 index 000000000..900a32b08 --- /dev/null +++ b/addon-sdk/source/test/modules/orange.js @@ -0,0 +1,10 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +define(['./color'], function (color) { + return { + name: 'orange', + parentType: color.type + }; +}); diff --git a/addon-sdk/source/test/modules/pollux.js b/addon-sdk/source/test/modules/pollux.js new file mode 100644 index 000000000..61cf66f9c --- /dev/null +++ b/addon-sdk/source/test/modules/pollux.js @@ -0,0 +1,10 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +define(['exports', './castor'], function(exports, castor) { + exports.name = 'pollux'; + exports.getCastorName = function () { + return castor.name; + }; +}); diff --git a/addon-sdk/source/test/modules/red.js b/addon-sdk/source/test/modules/red.js new file mode 100644 index 000000000..c47b8e924 --- /dev/null +++ b/addon-sdk/source/test/modules/red.js @@ -0,0 +1,16 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +define(function (require) { + // comment fake-outs for require finding. + // require('bad1'); + return { + name: 'red', + parentType: require('./color').type + }; + + /* + require('bad2'); + */ +}); diff --git a/addon-sdk/source/test/modules/setExports.js b/addon-sdk/source/test/modules/setExports.js new file mode 100644 index 000000000..495c301cd --- /dev/null +++ b/addon-sdk/source/test/modules/setExports.js @@ -0,0 +1,5 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +module.setExports(5); diff --git a/addon-sdk/source/test/modules/subtract.js b/addon-sdk/source/test/modules/subtract.js new file mode 100644 index 000000000..06e1053ab --- /dev/null +++ b/addon-sdk/source/test/modules/subtract.js @@ -0,0 +1,9 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +define(function () { + return function (a, b) { + return a - b; + } +}); diff --git a/addon-sdk/source/test/modules/tiger.js b/addon-sdk/source/test/modules/tiger.js new file mode 100644 index 000000000..80479d019 --- /dev/null +++ b/addon-sdk/source/test/modules/tiger.js @@ -0,0 +1,8 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +define(function (require, exports) { + exports.name = 'tiger'; + exports.type = require('./types/cat').type; +}); diff --git a/addon-sdk/source/test/modules/traditional1.js b/addon-sdk/source/test/modules/traditional1.js new file mode 100644 index 000000000..28af8ef30 --- /dev/null +++ b/addon-sdk/source/test/modules/traditional1.js @@ -0,0 +1,12 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +exports.name = 'traditional1' + +var async1 = require('./async1'); + +exports.traditional2Name = async1.traditional2Name; +exports.traditional1Name = async1.traditional1Name; +exports.async2Name = async1.async2Name; +exports.async2Traditional2Name = async1.async2Traditional2Name; diff --git a/addon-sdk/source/test/modules/traditional2.js b/addon-sdk/source/test/modules/traditional2.js new file mode 100644 index 000000000..67b64eecb --- /dev/null +++ b/addon-sdk/source/test/modules/traditional2.js @@ -0,0 +1,6 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +exports.name = 'traditional2'; +exports.traditional1Name = require('./traditional1').name; diff --git a/addon-sdk/source/test/modules/types/cat.js b/addon-sdk/source/test/modules/types/cat.js new file mode 100644 index 000000000..41513d682 --- /dev/null +++ b/addon-sdk/source/test/modules/types/cat.js @@ -0,0 +1,5 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +exports.type = 'cat'; |