Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e2279e2

Browse filesBrowse files
aqrlnMylesBorins
authored andcommitted
test: fix broken tests in test-buffer-includes
Some of the tests for `buffer.includes()` functionality introduced in #3567 have been broken in a way that caused them to always pass regardless of the result of the tested method. This behavior was caused by two reasons: * These tests were written as though `buffer.includes()` was supposed to return the same value that `buffer.indexOf()` does, i.e., used indices or -1 as expected return values instead of true and false. * `assert()` was used as the assertion function to do that instead of `assert.strictEqual()`. Thus `assert()` was called with a non-zero number as the first argument effectively causing these tests to pass. This commit changes the tests to use `assert.ok()` and removes redundant indices. PR-URL: #12040 Ref: #3567 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 81f561b commit e2279e2
Copy full SHA for e2279e2

File tree

Expand file treeCollapse file tree

1 file changed

+10
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-12
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-buffer-includes.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-includes.js
+10-12Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,12 @@ assert(mixedByteStringUcs2.includes('bc', 0, 'ucs2'));
155155
assert(mixedByteStringUcs2.includes('\u03a3', 0, 'ucs2'));
156156
assert(!mixedByteStringUcs2.includes('\u0396', 0, 'ucs2'));
157157

158-
assert(
159-
6, mixedByteStringUcs2.includes(Buffer.from('bc', 'ucs2'), 0, 'ucs2'));
160-
assert(
161-
10, mixedByteStringUcs2.includes(Buffer.from('\u03a3', 'ucs2'),
162-
0, 'ucs2'));
163-
assert(
164-
-1, mixedByteStringUcs2.includes(Buffer.from('\u0396', 'ucs2'),
165-
0, 'ucs2'));
158+
assert.ok(
159+
mixedByteStringUcs2.includes(Buffer.from('bc', 'ucs2'), 0, 'ucs2'));
160+
assert.ok(
161+
mixedByteStringUcs2.includes(Buffer.from('\u03a3', 'ucs2'), 0, 'ucs2'));
162+
assert.ok(
163+
!mixedByteStringUcs2.includes(Buffer.from('\u0396', 'ucs2'), 0, 'ucs2'));
166164

167165
twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2');
168166

@@ -266,12 +264,12 @@ for (let lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) {
266264

267265
const patternBufferUcs2 =
268266
allCharsBufferUcs2.slice(index, index + length);
269-
assert(
270-
index, allCharsBufferUcs2.includes(patternBufferUcs2, 0, 'ucs2'));
267+
assert.ok(
268+
allCharsBufferUcs2.includes(patternBufferUcs2, 0, 'ucs2'));
271269

272270
const patternStringUcs2 = patternBufferUcs2.toString('ucs2');
273-
assert(
274-
index, allCharsBufferUcs2.includes(patternStringUcs2, 0, 'ucs2'));
271+
assert.ok(
272+
allCharsBufferUcs2.includes(patternStringUcs2, 0, 'ucs2'));
275273
}
276274
}
277275

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.