Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: replace internal API test with public API test
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: #27588 (review)
  • Loading branch information
Trott committed Nov 30, 2019
commit 925f55c71b1e3a7ce9c47c831eb3192e2e0f49da
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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep this? The additions below also aren’t public API, so it’s not really guaranteed that they keep testing this here.

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);
}