From 254c5b558dad605faaeaadee18811aea02649d33 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Tue, 10 Feb 2015 00:46:46 -0800 Subject: [PATCH] don't run "iojs buffer iterator" test in browsers most don't support iterators --- bin/download-node-tests.js | 23 ++++++++----------- package.json | 11 +++++---- test/es6/README.txt | 1 + .../test-buffer-iterator.js} | 2 +- test/node/README.txt | 1 + .../test-buffer-ascii.js} | 3 +-- .../test-buffer-big.js} | 2 +- .../test-buffer-concat.js} | 2 +- .../test-buffer-inspect.js} | 4 ++-- .../test-buffer-slice.js} | 4 ++-- .../test-buffer.js} | 7 +++--- 11 files changed, 29 insertions(+), 31 deletions(-) create mode 100644 test/es6/README.txt rename test/{node-test-buffer-iterator.js => es6/test-buffer-iterator.js} (96%) create mode 100644 test/node/README.txt rename test/{node-test-buffer-ascii.js => node/test-buffer-ascii.js} (96%) rename test/{node-test-buffer-big.js => node/test-buffer-big.js} (93%) rename test/{node-test-buffer-concat.js => node/test-buffer-concat.js} (94%) rename test/{node-test-buffer-inspect.js => node/test-buffer-inspect.js} (91%) rename test/{node-test-buffer-slice.js => node/test-buffer-slice.js} (82%) rename test/{node-test-buffer.js => node/test-buffer.js} (99%) diff --git a/bin/download-node-tests.js b/bin/download-node-tests.js index b5a854c..c7e14d6 100755 --- a/bin/download-node-tests.js +++ b/bin/download-node-tests.js @@ -34,10 +34,16 @@ function downloadBufferTests (dir, files) { files.forEach(function (file) { if (!/test-buffer.*/.test(file.name)) return + var path + if (file.name !== 'test-buffer-iterator.js') + path = __dirname + '/../test/node/' + file.name + else + path = __dirname + '/../test/es6/' + file.name + hyperquest(file.download_url, httpOpts) .pipe(split()) .pipe(testfixer(file.name)) - .pipe(fs.createWriteStream(__dirname + '/../test/node-' + file.name)) + .pipe(fs.createWriteStream(path)) }) } @@ -48,19 +54,8 @@ function testfixer (filename) { line = line.toString() if (firstline) { - var originalLine = line // require buffer explicitly - line = 'var Buffer = require(\'../\').Buffer\n' - - // don't run this test for the Object-based bufer implementation because - // it doesn't have an Iterable interface (but these old browsers won't have it - // anyway) - if (filename === 'test-buffer-iterator.js') - line += 'if (process.env.OBJECT_IMPL) return\n' - else - line += 'if (process.env.OBJECT_IMPL) Buffer.TYPED_ARRAY_SUPPORT = false\n' - - line += originalLine + line = 'var Buffer = require(\'../../\').Buffer\nif (process.env.OBJECT_IMPL) Buffer.TYPED_ARRAY_SUPPORT = false\n' + line firstline = false } @@ -68,7 +63,7 @@ function testfixer (filename) { line = line.replace(/(var common = require.*)/, '// $1') // require browser buffer - line = line.replace(/(.*)require\('buffer'\)(.*)/, '$1require(\'../\')$2') + line = line.replace(/(.*)require\('buffer'\)(.*)/, '$1require(\'../../\')$2') // smalloc is only used for kMaxLength line = line.replace(/require\('smalloc'\)/, '{ kMaxLength: 0x3FFFFFFF }') diff --git a/package.json b/package.json index a362d88..724c3bf 100644 --- a/package.json +++ b/package.json @@ -49,17 +49,18 @@ }, "scripts": { "test": "standard && node ./bin/test.js", - "test-browser": "zuul -- test/*.js", - "test-browser-local": "zuul --local -- test/*.js", - "test-node": "tape test/*.js && OBJECT_IMPL=true tape test/*.js", + "test-browser": "zuul -- test/*.js test/node/*.js", + "test-browser-local": "zuul --local -- test/*.js test/node/*.js", + "test-node": "tape test/*.js test/node/*.js test/es6/*.js && OBJECT_IMPL=true tape test/*.js test/node/*.js", "perf": "browserify --debug perf/bracket-notation.js > perf/bundle.js && open perf/index.html", "perf-node": "node perf/bracket-notation.js && node perf/concat.js && node perf/copy-big.js && node perf/copy.js && node perf/new-big.js && node perf/new.js && node perf/readDoubleBE.js && node perf/readFloatBE.js && node perf/readUInt32LE.js && node perf/slice.js && node perf/writeFloatBE.js", "size": "browserify -r ./ | uglifyjs -c -m | gzip | wc -c" }, "standard": { "ignore": [ - "test/node-*", - "perf/*" + "test/node/*.js", + "test/es6/*.js", + "perf/*.js" ] }, "testling": { diff --git a/test/es6/README.txt b/test/es6/README.txt new file mode 100644 index 0000000..933dd6f --- /dev/null +++ b/test/es6/README.txt @@ -0,0 +1 @@ +io.js/node.js core buffer tests that require ES6 (for..of construct) diff --git a/test/node-test-buffer-iterator.js b/test/es6/test-buffer-iterator.js similarity index 96% rename from test/node-test-buffer-iterator.js rename to test/es6/test-buffer-iterator.js index 972c7c6..1bbe1c7 100644 --- a/test/node-test-buffer-iterator.js +++ b/test/es6/test-buffer-iterator.js @@ -1,4 +1,4 @@ -var Buffer = require('../').Buffer +var Buffer = require('../../').Buffer if (process.env.OBJECT_IMPL) return // var common = require('../common'); var assert = require('assert'); diff --git a/test/node/README.txt b/test/node/README.txt new file mode 100644 index 0000000..adf7087 --- /dev/null +++ b/test/node/README.txt @@ -0,0 +1 @@ +io.js/node.js core buffer tests diff --git a/test/node-test-buffer-ascii.js b/test/node/test-buffer-ascii.js similarity index 96% rename from test/node-test-buffer-ascii.js rename to test/node/test-buffer-ascii.js index e3d918c..16572b3 100644 --- a/test/node-test-buffer-ascii.js +++ b/test/node/test-buffer-ascii.js @@ -1,4 +1,4 @@ -var Buffer = require('../').Buffer +var Buffer = require('../../').Buffer if (process.env.OBJECT_IMPL) Buffer.TYPED_ARRAY_SUPPORT = false // var common = require('../common'); var assert = require('assert'); @@ -24,4 +24,3 @@ for (var i = 0; i < expected.length; ++i) { if (input.charCodeAt(i) > 65535) ++i; if (input.charCodeAt(i) > 127) ++i; } - diff --git a/test/node-test-buffer-big.js b/test/node/test-buffer-big.js similarity index 93% rename from test/node-test-buffer-big.js rename to test/node/test-buffer-big.js index a5558d5..d704cf9 100644 --- a/test/node-test-buffer-big.js +++ b/test/node/test-buffer-big.js @@ -1,4 +1,4 @@ -var Buffer = require('../').Buffer +var Buffer = require('../../').Buffer if (process.env.OBJECT_IMPL) Buffer.TYPED_ARRAY_SUPPORT = false // var common = require('../common'); var assert = require('assert'); diff --git a/test/node-test-buffer-concat.js b/test/node/test-buffer-concat.js similarity index 94% rename from test/node-test-buffer-concat.js rename to test/node/test-buffer-concat.js index d68b135..c703c14 100644 --- a/test/node-test-buffer-concat.js +++ b/test/node/test-buffer-concat.js @@ -1,4 +1,4 @@ -var Buffer = require('../').Buffer +var Buffer = require('../../').Buffer if (process.env.OBJECT_IMPL) Buffer.TYPED_ARRAY_SUPPORT = false // var common = require('../common'); var assert = require('assert'); diff --git a/test/node-test-buffer-inspect.js b/test/node/test-buffer-inspect.js similarity index 91% rename from test/node-test-buffer-inspect.js rename to test/node/test-buffer-inspect.js index c35d416..d8263a8 100644 --- a/test/node-test-buffer-inspect.js +++ b/test/node/test-buffer-inspect.js @@ -1,11 +1,11 @@ -var Buffer = require('../').Buffer +var Buffer = require('../../').Buffer if (process.env.OBJECT_IMPL) Buffer.TYPED_ARRAY_SUPPORT = false // var common = require('../common'); var assert = require('assert'); var util = require('util'); -var buffer = require('../'); +var buffer = require('../../'); buffer.INSPECT_MAX_BYTES = 2; diff --git a/test/node-test-buffer-slice.js b/test/node/test-buffer-slice.js similarity index 82% rename from test/node-test-buffer-slice.js rename to test/node/test-buffer-slice.js index ebef86e..6e58812 100644 --- a/test/node-test-buffer-slice.js +++ b/test/node/test-buffer-slice.js @@ -1,9 +1,9 @@ -var Buffer = require('../').Buffer +var Buffer = require('../../').Buffer if (process.env.OBJECT_IMPL) Buffer.TYPED_ARRAY_SUPPORT = false // var common = require('../common'); var assert = require('assert'); -var Buffer = require('../').Buffer; +var Buffer = require('../../').Buffer; var buff = new Buffer(Buffer.poolSize + 1); var slicedBuffer = buff.slice(); diff --git a/test/node-test-buffer.js b/test/node/test-buffer.js similarity index 99% rename from test/node-test-buffer.js rename to test/node/test-buffer.js index ab4535d..1a6a09d 100644 --- a/test/node-test-buffer.js +++ b/test/node/test-buffer.js @@ -1,10 +1,10 @@ -var Buffer = require('../').Buffer +var Buffer = require('../../').Buffer if (process.env.OBJECT_IMPL) Buffer.TYPED_ARRAY_SUPPORT = false // var common = require('../common'); var assert = require('assert'); -var Buffer = require('../').Buffer; -var SlowBuffer = require('../').SlowBuffer; +var Buffer = require('../../').Buffer; +var SlowBuffer = require('../../').SlowBuffer; var smalloc = { kMaxLength: 0x3FFFFFFF }; // counter to ensure unique value is always copied @@ -1172,3 +1172,4 @@ assert.throws(function() { // Regression test for https://github.com/iojs/io.js/issues/649. assert.throws(function() { Buffer(1422561062959).toString('utf8'); }); + -- 2.34.1