nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: node-nock/nock
Pull request #734 (2016-10-25 21:36:57)

Fixes regression introduced by #719
This adds a test for empty objects in the body and spec.

It also fixes a regression that would cause the library to throw an error if an empty object was passed in the body.

CC @vrinek


Patch:
diff --git a/lib/match_body.js b/lib/match_body.js
index e5346e0..be5215a 100644
--- a/lib/match_body.js
+++ b/lib/match_body.js
@@ -57,7 +57,7 @@ function deepEqualExtended(spec, body) {
   if (spec && spec.constructor === RegExp) {
     return spec.test(body);
   }
-  if (spec && spec.constructor === Object || spec.constructor === Array && body) {
+  if (spec && (spec.constructor === Object || spec.constructor === Array) && body) {
     var keys = Object.keys(spec);
     for (var i = 0; i < keys.length; i++) {
       if (!deepEqualExtended(spec[keys[i]], body[keys[i]])) {


Test patch:
diff --git a/tests/test_body_match.js b/tests/test_body_match.js
index 23f9225..25e5188 100644
--- a/tests/test_body_match.js
+++ b/tests/test_body_match.js
@@ -47,3 +47,22 @@ test('match body with regex inside array', function (t) {
     t.end();
   });
 })
+
+test('match body with empty object inside', function (t) {
+
+  nock('http://encodingsareus.com')
+    .post('/', { obj: {}})
+    .reply(200);
+
+  mikealRequest({
+    url: 'http://encodingsareus.com/',
+    method: 'post',
+    json: {
+      obj: {}
+    },
+  }, function(err, res) {
+    if (err) throw err;
+    assert.equal(res.statusCode, 200);
+    t.end();
+  });
+})
Repository: node-nock/nock
Pull request #769 (2016-12-08 00:05:48)

Fix this pointer on "socket" event
This makes behavior consistent with the Node.js HTTP module
(https://github.com/nodejs/node/blob/v6.0.0/lib/_http_client.js#L541).


Patch:
diff --git a/lib/request_overrider.js b/lib/request_overrider.js
index 85ceea9..59f8952 100644
--- a/lib/request_overrider.js
+++ b/lib/request_overrider.js
@@ -193,7 +193,7 @@ function RequestOverrider(req, options, interceptors, remove, cb) {
   req.once = req.on = function(event, listener) {
     // emit a fake socket.
     if (event == 'socket') {
-      listener(req.socket);
+      listener.call(req, req.socket);
       req.socket.emit('connect', req.socket);
       req.socket.emit('secureConnect', req.socket);
     }


Test patch:
diff --git a/tests/test_intercept.js b/tests/test_intercept.js
index 4e84d9b..0866b9f 100644
--- a/tests/test_intercept.js
+++ b/tests/test_intercept.js
@@ -4212,6 +4212,7 @@ test('request emits socket', function(t) {
 
   var req = http.get('http://gotzsocketz.com');
   req.once('socket', function(socket) {
+    t.equal(this, req);
     t.type(socket, Object);
     t.type(socket.getPeerCertificate(), 'string');
     t.end();
Repository: jprichardson/node-fs-extra
Pull request #682 (2019-05-13 16:55:38)

Add support for fs.realpath.native in envs that support it
Closes https://github.com/jprichardson/node-fs-extra/pull/650

coveralls: 
[![Coverage Status](https://coveralls.io/builds/23355138/badge)](https://coveralls.io/builds/23355138)

Coverage decreased (-0.07%) to 83.835% when pulling **4585044278bb35ff88da3c313cc1ef7de1d97c14 on realpath.native** into **32a65ffd9111829dbba15d79f1d27519c7dc96a6 on master**.

manidlou: good! so we don't need to do anything for `fs.realpathSync.native`?
RyanZim: I think that should work without anything special, since we don't have promises in the mix, but it wouldn't hurt to add a test.

Patch:
diff --git a/lib/fs/index.js b/lib/fs/index.js
index 8ffdf7b..a7b2292 100644
--- a/lib/fs/index.js
+++ b/lib/fs/index.js
@@ -102,3 +102,8 @@ exports.write = function (fd, buffer, ...args) {
     })
   })
 }
+
+// fs.realpath.native only available in Node v9.2+
+if (typeof fs.realpath.native === 'function') {
+  exports.realpath.native = u(fs.realpath.native)
+}


Test patch:
diff --git a/lib/fs/__tests__/realpath.test.js b/lib/fs/__tests__/realpath.test.js
new file mode 100644
index 0000000..59ee6fa
--- /dev/null
+++ b/lib/fs/__tests__/realpath.test.js
@@ -0,0 +1,33 @@
+'use strict'
+
+const fs = require('fs')
+const fse = require('../..')
+const assert = require('assert')
+
+/* eslint-env mocha */
+
+// fs.realpath.native only available in Node v9.2+
+if (typeof fs.realpath.native === 'function') {
+  describe('realpath.native', () => {
+    it('works with callbacks', () => {
+      fse.realpath.native(__dirname, (err, path) => {
+        assert.ifError(err)
+        assert.strictEqual(path, __dirname)
+      })
+    })
+
+    it('works with promises', (done) => {
+      fse.realpath.native(__dirname)
+        .then(path => {
+          assert.strictEqual(path, __dirname)
+          done()
+        })
+        .catch(done)
+    })
+
+    it('works with sync version', () => {
+      const path = fse.realpathSync.native(__dirname)
+      assert.strictEqual(path, __dirname)
+    })
+  })
+}