Skip to content

Commit

Permalink
fixed tests in old nodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Mar 1, 2018
1 parent bb4cfc9 commit d737770
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
7 changes: 5 additions & 2 deletions build/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ module.exports['string_decoder.js'] = [
]

, [
/const Buffer = require\('buffer'\).Buffer;/
, 'var Buffer = require(\'safe-buffer\').Buffer;\n'
/(?:var|const) (?:{ )Buffer(?: }) = require\('buffer'\)(?:\.Buffer)?;/,
`/*<replacement>*/
var Buffer = require('safe-buffer').Buffer;
/*</replacement>*/
`
]

// add Buffer.isEncoding where missing
Expand Down
16 changes: 15 additions & 1 deletion build/test-replacements.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,21 @@ module.exports['common.js'] = [
module.exports['test-string-decoder.js'] = [
// test removed because it is V8-version dependant.
[
/test\('utf-8', bufferShim.from\('EDA0B5EDB08D'.*\n.*\n/
/test\('utf-8', bufferShim\.from\('EDA0B5EDB08D'.*\n.*\n/
, ''
],
, [
/test\('utf-8', bufferShim\.from\('F0B841', 'hex'.*\n/
, ''
]
, [
/test\('utf-8', bufferShim\.from\('CCE2B8B8', 'hex'.*\n/
, ''
]
, [
/test\('utf-8', bufferShim\.from\('E2B8CCB8', 'hex'.*\n/
, ''
]
, [
/assert\.strictEqual\(decoder\.end(), '\ufffd'\);\n/
]
6 changes: 4 additions & 2 deletions lib/string_decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@

'use strict';

var _require = require('buffer'),
Buffer = _require.Buffer;
/*<replacement>*/

var Buffer = require('safe-buffer').Buffer;
/*</replacement>*/

var isEncoding = Buffer.isEncoding || function (encoding) {
encoding = '' + encoding;
Expand Down

0 comments on commit d737770

Please sign in to comment.