aboutsummaryrefslogtreecommitdiff
path: root/tools/addon-sdk-1.5/packages/api-utils/tests/modules
diff options
context:
space:
mode:
Diffstat (limited to 'tools/addon-sdk-1.5/packages/api-utils/tests/modules')
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/add.js9
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/async1.js14
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/async2.js8
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/badExportAndReturn.js10
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/badFirst.js9
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/badSecond.js8
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/blue.js9
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/castor.js10
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/cheetah.js9
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/color.js7
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/dupe.js15
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/dupeNested.js15
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/dupeSetExports.js8
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/exportsEquals.js5
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/green.js10
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/lion.js7
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/orange.js10
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/pollux.js10
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/red.js16
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/setExports.js5
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/subtract.js9
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/tiger.js8
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/traditional1.js12
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/traditional2.js6
-rw-r--r--tools/addon-sdk-1.5/packages/api-utils/tests/modules/types/cat.js5
25 files changed, 234 insertions, 0 deletions
diff --git a/tools/addon-sdk-1.5/packages/api-utils/tests/modules/add.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/add.js
new file mode 100644
index 0000000..5472934
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/async1.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/async1.js
new file mode 100644
index 0000000..b7b60fd
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/async2.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/async2.js
new file mode 100644
index 0000000..802fb25
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/badExportAndReturn.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/badExportAndReturn.js
new file mode 100644
index 0000000..35a5359
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/badFirst.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/badFirst.js
new file mode 100644
index 0000000..fdb03bd
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/badSecond.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/badSecond.js
new file mode 100644
index 0000000..8321a85
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/blue.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/blue.js
new file mode 100644
index 0000000..14ab149
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/castor.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/castor.js
new file mode 100644
index 0000000..9209623
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/cheetah.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/cheetah.js
new file mode 100644
index 0000000..37d12bf
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/color.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/color.js
new file mode 100644
index 0000000..0d946bd
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/dupe.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/dupe.js
new file mode 100644
index 0000000..f87fa55
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/dupeNested.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/dupeNested.js
new file mode 100644
index 0000000..703948c
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/dupeSetExports.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/dupeSetExports.js
new file mode 100644
index 0000000..12a1be2
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/exportsEquals.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/exportsEquals.js
new file mode 100644
index 0000000..e176316
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/green.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/green.js
new file mode 100644
index 0000000..ce2d134
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/lion.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/lion.js
new file mode 100644
index 0000000..9c3ac3b
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/orange.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/orange.js
new file mode 100644
index 0000000..900a32b
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/pollux.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/pollux.js
new file mode 100644
index 0000000..61cf66f
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/red.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/red.js
new file mode 100644
index 0000000..c47b8e9
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/setExports.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/setExports.js
new file mode 100644
index 0000000..495c301
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/subtract.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/subtract.js
new file mode 100644
index 0000000..06e1053
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/tiger.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/tiger.js
new file mode 100644
index 0000000..e332deb
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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('modules/types/cat').type;
+});
diff --git a/tools/addon-sdk-1.5/packages/api-utils/tests/modules/traditional1.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/traditional1.js
new file mode 100644
index 0000000..28af8ef
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/traditional2.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/traditional2.js
new file mode 100644
index 0000000..67b64ee
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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/tools/addon-sdk-1.5/packages/api-utils/tests/modules/types/cat.js b/tools/addon-sdk-1.5/packages/api-utils/tests/modules/types/cat.js
new file mode 100644
index 0000000..41513d6
--- /dev/null
+++ b/tools/addon-sdk-1.5/packages/api-utils/tests/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';