diff --git a/lib/node_modules/@stdlib/_tools/repl-txt/rules/doctest/lib/main.js b/lib/node_modules/@stdlib/_tools/repl-txt/rules/doctest/lib/main.js index 64b64e6151ee..4cadcb83661c 100644 --- a/lib/node_modules/@stdlib/_tools/repl-txt/rules/doctest/lib/main.js +++ b/lib/node_modules/@stdlib/_tools/repl-txt/rules/doctest/lib/main.js @@ -25,6 +25,7 @@ var dirname = require( 'path' ).dirname; var replace = require( '@stdlib/string/replace' ); var namespace = require( '@stdlib/namespace' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var copy = require( '@stdlib/utils/copy' ); var compareValues = require( '@stdlib/_tools/doctest/compare-values' ); @@ -135,9 +136,12 @@ function main( context ) { expected.push( current.output ); match = code.match( RE_ASSIGNMENT ); if ( match && match[ 1 ] ) { - actual.push( scope[ match[ 1 ] ] ); + // Snapshot the value, as accumulator-style examples may return + // a shared, mutable reference (e.g., a stateful output array) + // that later statements overwrite in place: + actual.push( copy( scope[ match[ 1 ] ] ) ); } else { - actual.push( out ); + actual.push( copy( out ) ); } } } catch ( err ) { diff --git a/package.json b/package.json index 00fe02e17211..8be468eb4ff8 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "clean": "make clean", "check-deps": "make check-deps", "check-licenses": "make check-licenses", - "postinstall": "tools/scripts/apply_patches" + "postinstall": "if test -f tools/scripts/apply_patches; then tools/scripts/apply_patches; fi" }, "homepage": "https://github.com/stdlib-js/stdlib", "repository": {