~ubuntu-branches/ubuntu/saucy/nodejs/saucy

« back to all changes in this revision

Viewing changes to test/simple/test-net-connect-buffer.js

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-08-14 00:16:46 UTC
  • mfrom: (7.1.40 sid)
  • Revision ID: package-import@ubuntu.com-20130814001646-bzlysfh8sd6mukbo
Tags: 0.10.15~dfsg1-4
* Update 2005 patch, adding a handful of tests that can fail on
  slow platforms.
* Add 1004 patch to fix test failures when writing NaN to buffer
  on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
  });
39
39
 
40
40
  s.on('end', function() {
 
41
    console.error('SERVER: end', buf.toString());
41
42
    assert.equal(buf, "L'État, c'est moi");
42
43
    console.log('tcp socket disconnect');
43
44
    s.end();
50
51
});
51
52
 
52
53
tcp.listen(common.PORT, function() {
53
 
  var socket = net.Stream();
 
54
  var socket = net.Stream({ highWaterMark: 0 });
54
55
 
55
56
  console.log('Connecting to socket ');
56
57
 
64
65
  assert.equal('opening', socket.readyState);
65
66
 
66
67
  // Make sure that anything besides a buffer or a string throws.
67
 
  [ null,
68
 
    true,
69
 
    false,
70
 
    undefined,
71
 
    1,
72
 
    1.0,
73
 
    1 / 0,
74
 
    +Infinity
75
 
    -Infinity,
76
 
    [],
77
 
    {}
 
68
  [null,
 
69
   true,
 
70
   false,
 
71
   undefined,
 
72
   1,
 
73
   1.0,
 
74
   1 / 0,
 
75
   +Infinity,
 
76
   -Infinity,
 
77
   [],
 
78
   {}
78
79
  ].forEach(function(v) {
79
80
    function f() {
 
81
      console.error('write', v);
80
82
      socket.write(v);
81
83
    }
82
84
    assert.throws(f, TypeError);
90
92
  // We're still connecting at this point so the datagram is first pushed onto
91
93
  // the connect queue. Make sure that it's not added to `bytesWritten` again
92
94
  // when the actual write happens.
93
 
  var r = socket.write(a, function() {
 
95
  var r = socket.write(a, function(er) {
 
96
    console.error('write cb');
94
97
    dataWritten = true;
95
98
    assert.ok(connectHappened);
96
 
    assert.equal(socket.bytesWritten, Buffer(a + b).length);
 
99
    console.error('socket.bytesWritten', socket.bytesWritten);
 
100
    //assert.equal(socket.bytesWritten, Buffer(a + b).length);
97
101
    console.error('data written');
98
102
  });
 
103
  console.error('socket.bytesWritten', socket.bytesWritten);
 
104
  console.error('write returned', r);
 
105
 
99
106
  assert.equal(socket.bytesWritten, Buffer(a).length);
100
107
 
101
108
  assert.equal(false, r);