Skip to content

Commit

Permalink
test: replace internal API test with public API test
Browse files Browse the repository at this point in the history
The internal freelist `hasItems()` test use the internal API directly.
This commit changes them to use the API as it is exposed publicly. It
tests the same code paths, but does it without needing
`--expose-internals`.

Refs: nodejs#27588 (review)
  • Loading branch information
Trott committed Nov 30, 2019
1 parent 5961161 commit 925f55c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
10 changes: 0 additions & 10 deletions test/parallel/test-freelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,3 @@ assert.strictEqual(flist1.free({ id: 'test5' }), false);
assert.strictEqual(flist1.alloc().id, 'test3');
assert.strictEqual(flist1.alloc().id, 'test2');
assert.strictEqual(flist1.alloc().id, 'test1');

// Check list has elements
const flist2 = new FreeList('flist2', 2, Object);
assert.strictEqual(flist2.hasItems(), false);

flist2.free({ id: 'test1' });
assert.strictEqual(flist2.hasItems(), true);

flist2.alloc();
assert.strictEqual(flist2.hasItems(), false);
18 changes: 15 additions & 3 deletions test/parallel/test-http-common.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
'use strict';
require('../common');
const assert = require('assert');
const httpCommon = require('_http_common');
const checkIsHttpToken = httpCommon._checkIsHttpToken;
const checkInvalidHeaderChar = httpCommon._checkInvalidHeaderChar;
const {
_checkInvalidHeaderChar: checkInvalidHeaderChar,
_checkIsHttpToken: checkIsHttpToken,
parsers
} = require('_http_common');

// checkIsHttpToken
assert(checkIsHttpToken('t'));
Expand Down Expand Up @@ -31,3 +33,13 @@ assert.strictEqual(checkInvalidHeaderChar('tt'), false);
assert.strictEqual(checkInvalidHeaderChar('ttt'), false);
assert.strictEqual(checkInvalidHeaderChar('tttt'), false);
assert.strictEqual(checkInvalidHeaderChar('ttttt'), false);

// parsers
{
const dummyParser = { id: 'fhqwhgads' };
assert.strictEqual(parsers.hasItems(), false);
assert.strictEqual(parsers.free(dummyParser), true);
assert.strictEqual(parsers.hasItems(), true);
assert.strictEqual(parsers.alloc(), dummyParser);
assert.strictEqual(parsers.hasItems(), false);
}

0 comments on commit 925f55c

Please sign in to comment.