<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/node-new.git/test/parallel/test-buffer-slice.js, branch cleanup-getnodeversion.py</title>
<subtitle>github.com: nodejs/node.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/'/>
<entry>
<title>test: fix strictEqual argument order</title>
<updated>2018-11-12T04:20:36+00:00</updated>
<author>
<name>Martin Kask</name>
<email>martin.kask@pipedrive.com</email>
</author>
<published>2018-11-06T14:59:38+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=8efad193a1deabf9ba70a636d2dfc15a6e00526b'/>
<id>8efad193a1deabf9ba70a636d2dfc15a6e00526b</id>
<content type='text'>
Fix the order of assert.strictEqual() arguments.
It should have first argument as the calculated/tested value.

PR-URL: https://github.com/nodejs/node/pull/24153
Reviewed-By: Ruben Bridgewater &lt;ruben@bridgewater.de&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Gireesh Punathil &lt;gpunathi@in.ibm.com&gt;
Reviewed-By: Trivikram Kamat &lt;trivikr.dev@gmail.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix the order of assert.strictEqual() arguments.
It should have first argument as the calculated/tested value.

PR-URL: https://github.com/nodejs/node/pull/24153
Reviewed-By: Ruben Bridgewater &lt;ruben@bridgewater.de&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Gireesh Punathil &lt;gpunathi@in.ibm.com&gt;
Reviewed-By: Trivikram Kamat &lt;trivikr.dev@gmail.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>test: minor refactoring</title>
<updated>2018-02-16T15:54:07+00:00</updated>
<author>
<name>Ruben Bridgewater</name>
<email>ruben@bridgewater.de</email>
</author>
<published>2018-02-10T01:33:08+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=644fdd60d4be49ffa66d0bda1702c4459f607635'/>
<id>644fdd60d4be49ffa66d0bda1702c4459f607635</id>
<content type='text'>
Add punctuation and comments about code that should not throw.
Also remove a obsolete test and refactor some tests.

PR-URL: https://github.com/nodejs/node/pull/18669
Reviewed-By: Ben Noordhuis &lt;info@bnoordhuis.nl&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Luigi Pinca &lt;luigipinca@gmail.com&gt;
Reviewed-By: Matteo Collina &lt;matteo.collina@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add punctuation and comments about code that should not throw.
Also remove a obsolete test and refactor some tests.

PR-URL: https://github.com/nodejs/node/pull/18669
Reviewed-By: Ben Noordhuis &lt;info@bnoordhuis.nl&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Luigi Pinca &lt;luigipinca@gmail.com&gt;
Reviewed-By: Matteo Collina &lt;matteo.collina@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>test: remove assert.doesNotThrow()</title>
<updated>2018-02-16T15:53:47+00:00</updated>
<author>
<name>Ruben Bridgewater</name>
<email>ruben@bridgewater.de</email>
</author>
<published>2018-02-09T01:32:04+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=caee112e52b64f4bc1118c4a5fa5ad7b4211efea'/>
<id>caee112e52b64f4bc1118c4a5fa5ad7b4211efea</id>
<content type='text'>
There is actually no reason to use `assert.doesNotThrow()` in the
tests. If a test throws, just let the error bubble up right away
instead of first catching it and then rethrowing it.

PR-URL: https://github.com/nodejs/node/pull/18669
Reviewed-By: Ben Noordhuis &lt;info@bnoordhuis.nl&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Luigi Pinca &lt;luigipinca@gmail.com&gt;
Reviewed-By: Matteo Collina &lt;matteo.collina@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There is actually no reason to use `assert.doesNotThrow()` in the
tests. If a test throws, just let the error bubble up right away
instead of first catching it and then rethrowing it.

PR-URL: https://github.com/nodejs/node/pull/18669
Reviewed-By: Ben Noordhuis &lt;info@bnoordhuis.nl&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Luigi Pinca &lt;luigipinca@gmail.com&gt;
Reviewed-By: Matteo Collina &lt;matteo.collina@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>test: simplify test-buffer-slice.js</title>
<updated>2018-01-05T00:13:03+00:00</updated>
<author>
<name>Weijia Wang</name>
<email>381152119@qq.com</email>
</author>
<published>2018-01-03T08:59:32+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=a2d0623fa8886553caceaed296bf53e7a1195b47'/>
<id>a2d0623fa8886553caceaed296bf53e7a1195b47</id>
<content type='text'>
Use forEach loop to reduce some redundant codes.

PR-URL: https://github.com/nodejs/node/pull/17962
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Gireesh Punathil &lt;gpunathi@in.ibm.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Jon Moss &lt;me@jonathanmoss.me&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Luigi Pinca &lt;luigipinca@gmail.com&gt;
Reviewed-By: Ruben Bridgewater &lt;ruben@bridgewater.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use forEach loop to reduce some redundant codes.

PR-URL: https://github.com/nodejs/node/pull/17962
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Gireesh Punathil &lt;gpunathi@in.ibm.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Jon Moss &lt;me@jonathanmoss.me&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Luigi Pinca &lt;luigipinca@gmail.com&gt;
Reviewed-By: Ruben Bridgewater &lt;ruben@bridgewater.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>meta: restore original copyright header</title>
<updated>2017-03-10T19:23:48+00:00</updated>
<author>
<name>James M Snell</name>
<email>jasnell@gmail.com</email>
</author>
<published>2017-01-03T21:16:48+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=98e54b0bd4854bdb3e2949d1b6b20d6777fb7cde'/>
<id>98e54b0bd4854bdb3e2949d1b6b20d6777fb7cde</id>
<content type='text'>
A prior io.js era commit inappropriately removed the
original copyright statements from the source. This
restores those in any files still remaining from that
edit.

Ref: https://github.com/nodejs/TSC/issues/174
Ref: https://github.com/nodejs/node/pull/10599
PR-URL: https://github.com/nodejs/node/pull/10155

Note: This PR was required, reviewed-by and approved
by the Node.js Foundation Legal Committee and the TSC.
There is no `Approved-By:` meta data.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A prior io.js era commit inappropriately removed the
original copyright statements from the source. This
restores those in any files still remaining from that
edit.

Ref: https://github.com/nodejs/TSC/issues/174
Ref: https://github.com/nodejs/node/pull/10599
PR-URL: https://github.com/nodejs/node/pull/10155

Note: This PR was required, reviewed-by and approved
by the Node.js Foundation Legal Committee and the TSC.
There is no `Approved-By:` meta data.
</pre>
</div>
</content>
</entry>
<entry>
<title>benchmark,lib,test: adjust for linting</title>
<updated>2017-01-06T22:36:01+00:00</updated>
<author>
<name>Rich Trott</name>
<email>rtrott@gmail.com</email>
</author>
<published>2017-01-01T05:39:57+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=a68987c154fbc041ea6d03ffdafa447e8c8a26f5'/>
<id>a68987c154fbc041ea6d03ffdafa447e8c8a26f5</id>
<content type='text'>
Formatting changes for upcoming linter update.

PR-URL: https://github.com/nodejs/node/pull/10561
Reviewed-By: Teddy Katz &lt;teddy.katz@gmail.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Sam Roberts &lt;vieuxtech@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Formatting changes for upcoming linter update.

PR-URL: https://github.com/nodejs/node/pull/10561
Reviewed-By: Teddy Katz &lt;teddy.katz@gmail.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Sam Roberts &lt;vieuxtech@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>test: strictCompare and explcit inputs mprovement to test-buffer-slice</title>
<updated>2016-12-05T22:33:21+00:00</updated>
<author>
<name>Michael Alexander</name>
<email>michael_alexander@us.ibm.com</email>
</author>
<published>2016-12-01T17:35:42+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=02a4c081e93e527c1cff163534364a8d488c3777'/>
<id>02a4c081e93e527c1cff163534364a8d488c3777</id>
<content type='text'>
* change implicit string equal() compares to strictEqual compares of
  buffer output (the slice output default)
* explicitly create buffers from utf8 inputs for the compare

PR-URL: https://github.com/nodejs/node/pull/10048
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* change implicit string equal() compares to strictEqual compares of
  buffer output (the slice output default)
* explicitly create buffers from utf8 inputs for the compare

PR-URL: https://github.com/nodejs/node/pull/10048
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>buffer: coerce offset using Math.trunc()</title>
<updated>2016-11-05T00:38:42+00:00</updated>
<author>
<name>cjihrig</name>
<email>cjihrig@gmail.com</email>
</author>
<published>2016-10-28T14:35:58+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=a02b13fe9bc13c59a2410c65ce13f7e68a36ccda'/>
<id>a02b13fe9bc13c59a2410c65ce13f7e68a36ccda</id>
<content type='text'>
This is a partial revert of
14d1a8a631a58408f1e85365a5f2aaa047cc0a5f, which coerced the offset
of Buffer#slice() using the | operator. This causes some edge
cases to be handled incorrectly. This commit restores the old
behavior, but converts offsets to integers using Math.trunc().
This commit does not revert any tests, and adds an additional
regression test.

Refs: https://github.com/nodejs/node/issues/9096
Refs: https://github.com/nodejs/node/pull/9101
PR-URL: https://github.com/nodejs/node/pull/9341
Reviewed-By: Sakthipriyan Vairamani &lt;thechargingvolcano@gmail.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Brian White &lt;mscdex@mscdex.net&gt;
Reviewed-By: Trevor Norris &lt;trev.norris@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is a partial revert of
14d1a8a631a58408f1e85365a5f2aaa047cc0a5f, which coerced the offset
of Buffer#slice() using the | operator. This causes some edge
cases to be handled incorrectly. This commit restores the old
behavior, but converts offsets to integers using Math.trunc().
This commit does not revert any tests, and adds an additional
regression test.

Refs: https://github.com/nodejs/node/issues/9096
Refs: https://github.com/nodejs/node/pull/9101
PR-URL: https://github.com/nodejs/node/pull/9341
Reviewed-By: Sakthipriyan Vairamani &lt;thechargingvolcano@gmail.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Brian White &lt;mscdex@mscdex.net&gt;
Reviewed-By: Trevor Norris &lt;trev.norris@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>buffer: coerce slice parameters consistently</title>
<updated>2016-10-18T22:51:44+00:00</updated>
<author>
<name>Sakthipriyan Vairamani (thefourtheye)</name>
<email>thechargingvolcano@gmail.com</email>
</author>
<published>2016-10-14T19:21:46+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=ee1469050385186168dc2ecaf816646e34c98000'/>
<id>ee1469050385186168dc2ecaf816646e34c98000</id>
<content type='text'>
As shown in https://github.com/nodejs/node/issues/9096, the offset and
end value of the `slice` call are coerced to numbers and then passed to
`FastBuffer`, which internally truncates the mantissa part if the number
is actually a floating point number. This actually affects the new
length of the slice calculation. For example,

    &gt; const original = Buffer.from('abcd');
    undefined
    &gt; original.slice(original.length / 3).toString()
    'bc'

This happens because, starting value of the slice is 4 / 3, which is
1.33 (approximately). Now, the length of the slice is calculated as
the difference between the actual length of the buffer and the starting
offset. So, it becomes 2.67 (4 - 1.33). Now, a new `FastBuffer` is
constructed, with the following values as parameters,

 1. actual buffer object,
 2. starting value, which is 1.33 and
 3. the length 2.67.

The underlying C++ code truncates the numbers and they become 1 and 2.
That is why the result is just `bc`.

This patch makes sure that all the offsets are coerced to integers
before any calculations are done.

Fixes: https://github.com/nodejs/node/issues/9096
PR-URL: https://github.com/nodejs/node/pull/9101
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Michaël Zasso &lt;targos@protonmail.com&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Franziska Hinkelmann &lt;franziska.hinkelmann@gmail.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Luigi Pinca &lt;luigipinca@gmail.com&gt;
Reviewed-By: Brian White &lt;mscdex@mscdex.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As shown in https://github.com/nodejs/node/issues/9096, the offset and
end value of the `slice` call are coerced to numbers and then passed to
`FastBuffer`, which internally truncates the mantissa part if the number
is actually a floating point number. This actually affects the new
length of the slice calculation. For example,

    &gt; const original = Buffer.from('abcd');
    undefined
    &gt; original.slice(original.length / 3).toString()
    'bc'

This happens because, starting value of the slice is 4 / 3, which is
1.33 (approximately). Now, the length of the slice is calculated as
the difference between the actual length of the buffer and the starting
offset. So, it becomes 2.67 (4 - 1.33). Now, a new `FastBuffer` is
constructed, with the following values as parameters,

 1. actual buffer object,
 2. starting value, which is 1.33 and
 3. the length 2.67.

The underlying C++ code truncates the numbers and they become 1 and 2.
That is why the result is just `bc`.

This patch makes sure that all the offsets are coerced to integers
before any calculations are done.

Fixes: https://github.com/nodejs/node/issues/9096
PR-URL: https://github.com/nodejs/node/pull/9101
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Michaël Zasso &lt;targos@protonmail.com&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Franziska Hinkelmann &lt;franziska.hinkelmann@gmail.com&gt;
Reviewed-By: Colin Ihrig &lt;cjihrig@gmail.com&gt;
Reviewed-By: Luigi Pinca &lt;luigipinca@gmail.com&gt;
Reviewed-By: Brian White &lt;mscdex@mscdex.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>test: add assertions to zero length buffer test</title>
<updated>2016-09-26T20:50:50+00:00</updated>
<author>
<name>Lauren Spiegel</name>
<email>lhspiegel@gmail.com</email>
</author>
<published>2016-09-23T03:13:00+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/node-new.git/commit/?id=927661f8ace022a0f77a35ea76dffb5bb21b188d'/>
<id>927661f8ace022a0f77a35ea76dffb5bb21b188d</id>
<content type='text'>
1) Add missing assertion that slicing a 0 length buffer does not throw
2) Add assertion that slicing a 0 length buffer has a length of 0

PR-URL: https://github.com/nodejs/node/pull/8729
Reviewed-By: Sakthipriyan Vairamani &lt;thechargingvolcano@gmail.com&gt;
Reviewed-By: Ilkka Myller &lt;ilkka.myller@nodefield.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Luigi Pinca &lt;luigipinca@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
1) Add missing assertion that slicing a 0 length buffer does not throw
2) Add assertion that slicing a 0 length buffer has a length of 0

PR-URL: https://github.com/nodejs/node/pull/8729
Reviewed-By: Sakthipriyan Vairamani &lt;thechargingvolcano@gmail.com&gt;
Reviewed-By: Ilkka Myller &lt;ilkka.myller@nodefield.com&gt;
Reviewed-By: James M Snell &lt;jasnell@gmail.com&gt;
Reviewed-By: Anna Henningsen &lt;anna@addaleax.net&gt;
Reviewed-By: Luigi Pinca &lt;luigipinca@gmail.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
