summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJulien Gilli <julien.gilli@joyent.com>2015-03-16 15:55:17 -0700
committerJulien Gilli <julien.gilli@joyent.com>2015-03-16 15:55:17 -0700
commitae58fc407f916b2abb164453a5b09273c543dbc3 (patch)
tree4a16fe73f996a54f34cfb553b2995d16c1375b7f /test
parent2b64132101f179c30957e3c5f16fc47a8ec942e1 (diff)
parenteb2764a9452baa7cba2d98dc34fa00fc776b0a12 (diff)
downloadnode-merge-review.tar.gz
Merge remote-tracking branch 'upstream/v0.12'merge-review
Diffstat (limited to 'test')
-rw-r--r--test/simple/simple.status1
-rw-r--r--test/simple/test-domain-top-level-error-handler-clears-stack.js41
-rw-r--r--test/simple/test-net-create-connection.js82
-rw-r--r--test/simple/test-net-localerror.js30
-rw-r--r--test/simple/test-url.js8
5 files changed, 126 insertions, 36 deletions
diff --git a/test/simple/simple.status b/test/simple/simple.status
index 8a0cbfb3c..4915a029b 100644
--- a/test/simple/simple.status
+++ b/test/simple/simple.status
@@ -14,5 +14,6 @@ test-stdin-script-child : PASS,FLAKY
test-util-debug : PASS,FLAKY
[$system==macos]
+test-fs-watch : PASS,FLAKY
[$system==solaris]
diff --git a/test/simple/test-domain-top-level-error-handler-clears-stack.js b/test/simple/test-domain-top-level-error-handler-clears-stack.js
new file mode 100644
index 000000000..f95864da6
--- /dev/null
+++ b/test/simple/test-domain-top-level-error-handler-clears-stack.js
@@ -0,0 +1,41 @@
+// 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.
+
+var assert = require('assert');
+var domain = require('domain');
+
+/*
+ * Make sure that the domains stack is cleared after a top-level domain
+ * error handler exited gracefully.
+ */
+var d = domain.create();
+
+d.on('error', function() {
+ process.nextTick(function() {
+ if (domain._stack.length !== 1) {
+ process.exit(1);
+ }
+ });
+});
+
+d.run(function() {
+ throw new Error('Error from domain');
+});
diff --git a/test/simple/test-net-create-connection.js b/test/simple/test-net-create-connection.js
index 12f7f0be6..2dee02966 100644
--- a/test/simple/test-net-create-connection.js
+++ b/test/simple/test-net-create-connection.js
@@ -24,33 +24,99 @@ var assert = require('assert');
var net = require('net');
var tcpPort = common.PORT;
+var expectedConnections = 7;
var clientConnected = 0;
var serverConnected = 0;
var server = net.createServer(function(socket) {
socket.end();
- if (++serverConnected === 4) {
+ if (++serverConnected === expectedConnections) {
server.close();
}
});
+
server.listen(tcpPort, 'localhost', function() {
function cb() {
++clientConnected;
}
+ function fail(opts, errtype, msg) {
+ assert.throws(function() {
+ var client = net.createConnection(opts, cb);
+ }, function (err) {
+ return err instanceof errtype && msg === err.message;
+ });
+ }
+
net.createConnection(tcpPort).on('connect', cb);
net.createConnection(tcpPort, 'localhost').on('connect', cb);
net.createConnection(tcpPort, cb);
net.createConnection(tcpPort, 'localhost', cb);
+ net.createConnection(tcpPort + '', 'localhost', cb);
+ net.createConnection({port: tcpPort + ''}).on('connect', cb);
+ net.createConnection({port: '0x' + tcpPort.toString(16)}, cb);
+
+ fail({
+ port: true
+ }, TypeError, 'port should be a number or string: true');
+
+ fail({
+ port: false
+ }, TypeError, 'port should be a number or string: false');
+
+ fail({
+ port: []
+ }, TypeError, 'port should be a number or string: ');
+
+ fail({
+ port: {}
+ }, TypeError, 'port should be a number or string: [object Object]');
+
+ fail({
+ port: null
+ }, TypeError, 'port should be a number or string: null');
+
+ fail({
+ port: ''
+ }, RangeError, 'port should be >= 0 and < 65536: ');
+
+ fail({
+ port: ' '
+ }, RangeError, 'port should be >= 0 and < 65536: ');
- assert.throws(function () {
- net.createConnection({
- port: 'invalid!'
- }, cb);
- });
+ fail({
+ port: '0x'
+ }, RangeError, 'port should be >= 0 and < 65536: 0x');
+
+ fail({
+ port: '-0x1'
+ }, RangeError, 'port should be >= 0 and < 65536: -0x1');
+
+ fail({
+ port: NaN
+ }, RangeError, 'port should be >= 0 and < 65536: NaN');
+
+ fail({
+ port: Infinity
+ }, RangeError, 'port should be >= 0 and < 65536: Infinity');
+
+ fail({
+ port: -1
+ }, RangeError, 'port should be >= 0 and < 65536: -1');
+
+ fail({
+ port: 65536
+ }, RangeError, 'port should be >= 0 and < 65536: 65536');
});
-process.on('exit', function() {
- assert.equal(clientConnected, 4);
+// Try connecting to random ports, but do so once the server is closed
+server.on('close', function() {
+ function nop() {}
+
+ net.createConnection({port: 0}).on('error', nop);
+ net.createConnection({port: undefined}).on('error', nop);
});
+process.on('exit', function() {
+ assert.equal(clientConnected, expectedConnections);
+});
diff --git a/test/simple/test-net-localerror.js b/test/simple/test-net-localerror.js
index d04d9c707..cf113d499 100644
--- a/test/simple/test-net-localerror.js
+++ b/test/simple/test-net-localerror.js
@@ -23,27 +23,17 @@ var common = require('../common');
var assert = require('assert');
var net = require('net');
- connect({
- host: 'localhost',
- port: common.PORT,
- localPort: 'foobar',
- }, 'localPort should be a number: foobar');
+connect({
+ host: 'localhost',
+ port: common.PORT,
+ localPort: 'foobar',
+}, 'localPort should be a number: foobar');
- connect({
- host: 'localhost',
- port: common.PORT,
- localAddress: 'foobar',
- }, 'localAddress should be a valid IP: foobar');
-
- connect({
- host: 'localhost',
- port: 65536
- }, 'port should be > 0 and < 65536: 65536');
-
- connect({
- host: 'localhost',
- port: 0
- }, 'port should be > 0 and < 65536: 0');
+connect({
+ host: 'localhost',
+ port: common.PORT,
+ localAddress: 'foobar',
+}, 'localAddress should be a valid IP: foobar');
function connect(opts, msg) {
assert.throws(function() {
diff --git a/test/simple/test-url.js b/test/simple/test-url.js
index d0ddaf203..e81908a88 100644
--- a/test/simple/test-url.js
+++ b/test/simple/test-url.js
@@ -1178,14 +1178,6 @@ var relativeTests = [
['/foo/bar/baz/', 'quux/baz', '/foo/bar/baz/quux/baz'],
['/foo/bar/baz', '../../../../../../../../quux/baz', '/quux/baz'],
['/foo/bar/baz', '../../../../../../../quux/baz', '/quux/baz'],
- ['/foo', '.', '/'],
- ['/foo', '..', '/'],
- ['/foo/', '.', '/foo/'],
- ['/foo/', '..', '/'],
- ['/foo/bar', '.', '/foo/'],
- ['/foo/bar', '..', '/'],
- ['/foo/bar/', '.', '/foo/bar/'],
- ['/foo/bar/', '..', '/foo/'],
['foo/bar', '../../../baz', '../../baz'],
['foo/bar/', '../../../baz', '../baz'],
['http://example.com/b//c//d;p?q#blarg', 'https:#hash2', 'https:///#hash2'],