summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/fixtures/packages/missing-main/index.js22
-rw-r--r--test/fixtures/packages/missing-main/package.json4
-rw-r--r--test/fixtures/packages/unparseable/package.json3
-rw-r--r--test/sequential/test-module-loading.js7
4 files changed, 36 insertions, 0 deletions
diff --git a/test/fixtures/packages/missing-main/index.js b/test/fixtures/packages/missing-main/index.js
new file mode 100644
index 0000000000..c361a6dc8d
--- /dev/null
+++ b/test/fixtures/packages/missing-main/index.js
@@ -0,0 +1,22 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+exports.ok = 'ok';
diff --git a/test/fixtures/packages/missing-main/package.json b/test/fixtures/packages/missing-main/package.json
new file mode 100644
index 0000000000..feb846703f
--- /dev/null
+++ b/test/fixtures/packages/missing-main/package.json
@@ -0,0 +1,4 @@
+{
+ "name": "missingmain",
+ "main": "doesnotexist.js"
+}
diff --git a/test/fixtures/packages/unparseable/package.json b/test/fixtures/packages/unparseable/package.json
new file mode 100644
index 0000000000..2017a68ecc
--- /dev/null
+++ b/test/fixtures/packages/unparseable/package.json
@@ -0,0 +1,3 @@
+{
+ "main": "therain" "inspain"
+}
diff --git a/test/sequential/test-module-loading.js b/test/sequential/test-module-loading.js
index c71f9d1edf..42916a7903 100644
--- a/test/sequential/test-module-loading.js
+++ b/test/sequential/test-module-loading.js
@@ -104,6 +104,12 @@ const d2 = require('../fixtures/b/d');
assert.strictEqual(require('../fixtures/packages/index').ok, 'ok');
assert.strictEqual(require('../fixtures/packages/main').ok, 'ok');
assert.strictEqual(require('../fixtures/packages/main-index').ok, 'ok');
+assert.strictEqual(require('../fixtures/packages/missing-main').ok, 'ok');
+
+assert.throws(
+ function() { require('../fixtures/packages/unparseable'); },
+ /^SyntaxError: Error parsing/
+);
{
console.error('test cycles containing a .. path');
@@ -267,6 +273,7 @@ try {
'fixtures/packages/index/index.js': {},
'fixtures/packages/main/package-main-module.js': {},
'fixtures/packages/main-index/package-main-module/index.js': {},
+ 'fixtures/packages/missing-main/index.js': {},
'fixtures/cycles/root.js': {
'fixtures/cycles/folder/foo.js': {}
},