summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJon Moss <me@jonathanmoss.me>2018-01-17 20:36:25 -0500
committerRuben Bridgewater <ruben@bridgewater.de>2018-01-19 12:58:31 +0100
commit5e17f54d79a345cc66a2105201f25f38d6b8d9e3 (patch)
tree990ddcadbfbac811ddbe98e59696918718460bc1 /test
parentf576341dc28199cc1f92a4ac66b6aa82e22cb486 (diff)
downloadandroid-node-v8-5e17f54d79a345cc66a2105201f25f38d6b8d9e3.tar.gz
android-node-v8-5e17f54d79a345cc66a2105201f25f38d6b8d9e3.tar.bz2
android-node-v8-5e17f54d79a345cc66a2105201f25f38d6b8d9e3.zip
test: refactor test-http-parser
Use common's mustCall (for some reason was implementing its own?), and other small fixes. PR-URL: https://github.com/nodejs/node/pull/18219 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-http-parser.js27
1 files changed, 4 insertions, 23 deletions
diff --git a/test/parallel/test-http-parser.js b/test/parallel/test-http-parser.js
index 81aadf2616..df3a87f73c 100644
--- a/test/parallel/test-http-parser.js
+++ b/test/parallel/test-http-parser.js
@@ -20,15 +20,11 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
-const common = require('../common');
+const { mustCall, mustNotCall } = require('../common');
const assert = require('assert');
-const binding = process.binding('http_parser');
-const methods = binding.methods;
-const HTTPParser = binding.HTTPParser;
-
-const REQUEST = HTTPParser.REQUEST;
-const RESPONSE = HTTPParser.RESPONSE;
+const { methods, HTTPParser } = process.binding('http_parser');
+const { REQUEST, RESPONSE } = HTTPParser;
const kOnHeaders = HTTPParser.kOnHeaders | 0;
const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0;
@@ -55,7 +51,7 @@ function newParser(type) {
parser[kOnHeadersComplete] = function() {
};
- parser[kOnBody] = common.mustNotCall('kOnBody should not be called');
+ parser[kOnBody] = mustNotCall('kOnBody should not be called');
parser[kOnMessageComplete] = function() {
};
@@ -64,21 +60,6 @@ function newParser(type) {
}
-function mustCall(f, times) {
- let actual = 0;
-
- process.setMaxListeners(256);
- process.on('exit', function() {
- assert.strictEqual(actual, times || 1);
- });
-
- return function() {
- actual++;
- return f.apply(this, Array.prototype.slice.call(arguments));
- };
-}
-
-
function expectBody(expected) {
return mustCall(function(buf, start, len) {
const body = String(buf.slice(start, start + len));