if (firstline) {
// require buffer explicitly
var preamble = 'var Buffer = require(\'../../\').Buffer;\n' +
- 'if (!Buffer.TYPED_ARRAY_SUPPORT) return;'
+ 'if (Buffer.TYPED_ARRAY_SUPPORT) {'
if (/use strict/.test(line)) line += '\n' + preamble
else line + preamble + '\n' + line
firstline = false
}
cb(null, line + '\n')
+ }, function (cb) {
+ // flush function
+ this.push('\n}')
})
}
#!/usr/bin/env node
var cp = require('child_process')
+var fs = require('fs')
+var path = require('path')
-var runBrowserTests = !process.env.TRAVIS_PULL_REQUEST ||
+var shouldRunBrowserTests = !process.env.TRAVIS_PULL_REQUEST ||
process.env.TRAVIS_PULL_REQUEST === 'false'
var node = cp.spawn('npm', ['run', 'test-node'], { stdio: 'inherit' })
node.on('close', function (code) {
- if (code === 0 && runBrowserTests) {
- var browser = cp.spawn('npm', ['run', 'test-browser'], { stdio: 'inherit' })
- browser.on('close', function (code) {
- process.exit(code)
- })
+ if (code === 0 && shouldRunBrowserTests) {
+ runBrowserTests()
} else {
process.exit(code)
}
})
+
+function runBrowserTests () {
+ var zuulYmlPath = path.join(__dirname, '..', '.zuul.yml')
+
+ writeES5ZuulYml()
+ cp.spawn('npm', ['run', 'test-browser-es5'], { stdio: 'inherit' })
+ .on('close', function (code) {
+ if (code !== 0) process.exit(code)
+ writeES6ZuulYml()
+ cp.spawn('npm', ['run', 'test-browser-es6'], { stdio: 'inherit' })
+ .on('close', function (code) {
+ process.exit(code)
+ })
+ })
+
+ function writeES5ZuulYml () {
+ fs.writeFileSync(zuulYmlPath, fs.readFileSync(path.join(__dirname, 'zuul-es5.yml')))
+ }
+
+ function writeES6ZuulYml () {
+ fs.writeFileSync(zuulYmlPath, fs.readFileSync(path.join(__dirname, 'zuul-es6.yml')))
+ }
+}
+
--- /dev/null
+ui: tape
+scripts:
+ - ./test/_polyfill.js
+browsers:
+ - name: safari
+ version: latest
+ - name: ie
+ version: 8..latest
+ - name: android
+ version: 4.4..latest
+ - name: iphone
+ version: latest
--- /dev/null
+ui: tape
+scripts:
+ - ./test/_polyfill.js
+browsers:
+ - name: chrome
+ version: '-2..latest'
+ - name: firefox
+ version: '-2..latest'
+ - name: microsoftedge
+ version: 13..latest
},
"scripts": {
"test": "standard && node ./bin/test.js",
- "test-browser": "zuul -- test/*.js test/node/*.js",
+ "test-browser-es5": "zuul -- test/*.js",
+ "test-browser-es6": "zuul -- test/*.js test/node/*.js",
"test-browser-local": "zuul --local -- test/*.js test/node/*.js",
"test-node": "tape test/*.js test/node/*.js && OBJECT_IMPL=true tape test/*.js",
"perf": "browserify --debug perf/bracket-notation.js > perf/bundle.js && open perf/index.html",
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var common = {};
var assert = require('assert');
}
// Regression test for https://github.com/nodejs/node/issues/3496.
-// TODO assert.equal(Buffer.from('=bad'.repeat(1e4), 'base64').length, 0);
+// assert.equal(Buffer.from('=bad'.repeat(1e4), 'base64').length, 0);
{
// Creating buffers larger than pool size.
}
var utf16Buf = Buffer.from('0123456789', 'utf16le');
- // TODO assert.deepEqual(utf16Buf.slice(0, 6), Buffer.from('012', 'utf16le'));
+ // assert.deepEqual(utf16Buf.slice(0, 6), Buffer.from('012', 'utf16le'));
assert.equal(buf.slice('0', '1'), '0');
assert.equal(buf.slice('-5', '10'), '56789');
assert(ubuf.buffer);
assert.equal(ubuf.buffer.byteLength, 10);
+
+
+}
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var assert = require('assert');
});
}
+
+
+}
\ No newline at end of file
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var assert = require('assert');
if (input.charCodeAt(i) > 127) ++i;
}
+
+
+}
\ No newline at end of file
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var assert = require('assert');
Buffer.from('deadbeaf', 'hex');
});
+
+
+}
\ No newline at end of file
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var assert = require('assert');
assert.equal(24, Buffer.byteLength('Il était tué', encoding));
});
+
+
+}
\ No newline at end of file
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var assert = require('assert');
assert.throws(() => a.compare(b, -Infinity, Infinity), oor);
assert.throws(() => a.compare(), /Argument must be a Buffer/);
+
+
+}
\ No newline at end of file
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var assert = require('assert');
});
}
+
+
+}
\ No newline at end of file
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var assert = require('assert');
writeToFill.apply(null, arguments));
}
+
+
+}
\ No newline at end of file
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var assert = require('assert');
b.includes([]);
});
+
+
+}
\ No newline at end of file
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var assert = require('assert');
b.indexOf([]);
});
+
+
+}
\ No newline at end of file
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var assert = require('assert');
t.toString();
});
+
+
+}
\ No newline at end of file
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var assert = require('assert');
assert.strictEqual(util.inspect(s), expected);
});
+
+
+}
\ No newline at end of file
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var assert = require('assert');
[4, 5]
]);
+
+
+}
\ No newline at end of file
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var assert = require('assert');
Buffer.allocUnsafe(10);
assert(isZeroFilled(Buffer.alloc(10)));
+
+
+}
\ No newline at end of file
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var assert = require('assert');
SlowBuffer(buffer.kMaxLength + 1);
}, 'invalid Buffer length');
+
+
+}
\ No newline at end of file
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var assert = require('assert');
assert.throws(() => buf3.slice(1, 3).swap32(), re32);
assert.throws(() => Buffer.alloc(1025).swap32(), re32);
+
+
+}
\ No newline at end of file
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
// Flags: --zero-fill-buffers
// when using --zero-fill-buffers, every Buffer and SlowBuffer
}
}
+
+
+}
\ No newline at end of file
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var assert = require('assert');
assert.ok(testUint8Array(ui), 'Uint8Array is not zero-filled');
}
+
+
+}
\ No newline at end of file
'use strict';
var Buffer = require('../../').Buffer;
-if (!Buffer.TYPED_ARRAY_SUPPORT) return;
+if (Buffer.TYPED_ARRAY_SUPPORT) {
var common = {};
var assert = require('assert');
}
// Regression test for https://github.com/nodejs/node/issues/3496.
-// TODO assert.equal(Buffer('=bad'.repeat(1e4), 'base64').length, 0);
+// assert.equal(Buffer('=bad'.repeat(1e4), 'base64').length, 0);
{
// Creating buffers larger than pool size.
}
var utf16Buf = new Buffer('0123456789', 'utf16le');
- // TODO assert.deepEqual(utf16Buf.slice(0, 6), Buffer('012', 'utf16le'));
+ // assert.deepEqual(utf16Buf.slice(0, 6), Buffer('012', 'utf16le'));
assert.equal(buf.slice('0', '1'), '0');
assert.equal(buf.slice('-5', '10'), '56789');
assert.equal(SlowBuffer.prototype.parent, undefined);
assert.equal(SlowBuffer.prototype.offset, undefined);
+
+
+}