From: Feross Aboukhadijeh Date: Thu, 29 Jan 2015 07:35:37 +0000 (-0800) Subject: JavaScript Standard Style X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=4169bbc1ff06b3944625c6f6737783f0393293bf;p=buffer.git JavaScript Standard Style See https://github.com/feross/standard --- diff --git a/bin/download-node-tests.js b/bin/download-node-tests.js index 7461aee..0b21e39 100755 --- a/bin/download-node-tests.js +++ b/bin/download-node-tests.js @@ -2,7 +2,7 @@ var hyperquest = require('hyperquest') var concat = require('concat-stream') -var split = require('split') +var split = require('split') var thru = require('through2') var fs = require('fs') @@ -14,26 +14,24 @@ var dirs = [ var httpOpts = { headers: { - 'User-Agent': null, - + 'User-Agent': null // auth if github rate-limits you... // 'Authorization': 'Basic ' + Buffer('username:password').toString('base64'), } } -dirs.forEach(function(dir) { +dirs.forEach(function (dir) { var req = hyperquest(url + dir, httpOpts) - req.pipe(concat(function(data) { + req.pipe(concat(function (data) { if (req.response.statusCode !== 200) { throw new Error(url + dir + ': ' + data.toString()) } - - downloadBufferTests(dir, JSON.parse(data)); + downloadBufferTests(dir, JSON.parse(data)) })) }) -function downloadBufferTests(dir, files) { - files.forEach(function(file) { +function downloadBufferTests (dir, files) { + files.forEach(function (file) { if (!/test-buffer.*/.test(file.name)) return hyperquest(file.download_url, httpOpts) @@ -43,14 +41,13 @@ function downloadBufferTests(dir, files) { }) } -function testfixer(filename) { +function testfixer (filename) { var firstline = true - return thru(function(line, enc, cb) { + return thru(function (line, enc, cb) { line = line.toString() if (firstline) { - // require buffer explicitly line = 'var Buffer = require(\'../\').Buffer\n' + 'if (process.env.OBJECT_IMPL) Buffer.TYPED_ARRAY_SUPPORT = false\n' + line diff --git a/index.js b/index.js index 1aa5acc..d148573 100644 --- a/index.js +++ b/index.js @@ -44,7 +44,7 @@ Buffer.TYPED_ARRAY_SUPPORT = (function () { var buf = new ArrayBuffer(0) var arr = new Uint8Array(buf) arr.foo = function () { return 42 } - return 42 === arr.foo() && // typed array instances can be augmented + return arr.foo() === 42 && // typed array instances can be augmented typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` } catch (e) { @@ -80,52 +80,52 @@ function Buffer (subject, encoding, noZero) { if (subject.type === 'Buffer' && isArray(subject.data)) subject = subject.data length = +subject.length > 0 ? Math.floor(+subject.length) : 0 - } else + } else { throw new TypeError('must start with number, buffer, array or string') + } if (length > kMaxLength) throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + kMaxLength.toString(16) + ' bytes') - var buf + var self = this if (Buffer.TYPED_ARRAY_SUPPORT) { // Preferred: Return an augmented `Uint8Array` instance for best performance - buf = Buffer._augment(new Uint8Array(length)) + self = Buffer._augment(new Uint8Array(length)) } else { // Fallback: Return THIS instance of Buffer (created by `new`) - buf = this - buf.length = length - buf._isBuffer = true + self.length = length + self._isBuffer = true } var i if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') { // Speed optimization -- use set if we're copying from a typed array - buf._set(subject) + self._set(subject) } else if (isArrayish(subject)) { // Treat array-ish objects as a byte array if (Buffer.isBuffer(subject)) { for (i = 0; i < length; i++) - buf[i] = subject.readUInt8(i) + self[i] = subject.readUInt8(i) } else { for (i = 0; i < length; i++) - buf[i] = ((subject[i] % 256) + 256) % 256 + self[i] = ((subject[i] % 256) + 256) % 256 } } else if (type === 'string') { - buf.write(subject, 0, encoding) + self.write(subject, 0, encoding) } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT && !noZero) { for (i = 0; i < length; i++) { - buf[i] = 0 + self[i] = 0 } } if (length > 0 && length <= Buffer.poolSize) - buf.parent = rootParent + self.parent = rootParent - return buf + return self } -function SlowBuffer(subject, encoding, noZero) { +function SlowBuffer (subject, encoding, noZero) { if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding, noZero) @@ -382,7 +382,7 @@ Buffer.prototype.write = function (string, offset, length, encoding) { offset = Number(offset) || 0 if (length < 0 || offset < 0 || offset > this.length) - throw new RangeError('attempt to write outside buffer bounds'); + throw new RangeError('attempt to write outside buffer bounds') var remaining = this.length - offset if (!length) { @@ -505,7 +505,7 @@ Buffer.prototype.slice = function (start, end) { end = end === undefined ? len : ~~end if (start < 0) { - start += len; + start += len if (start < 0) start = 0 } else if (start > len) { @@ -574,7 +574,7 @@ Buffer.prototype.readUIntBE = function (offset, byteLength, noAssert) { var val = this[offset + --byteLength] var mul = 1 while (byteLength > 0 && (mul *= 0x100)) - val += this[offset + --byteLength] * mul; + val += this[offset + --byteLength] * mul return val } @@ -982,7 +982,7 @@ Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) { // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) Buffer.prototype.copy = function (target, target_start, start, end) { - var source = this + var self = this // source if (!start) start = 0 if (!end && end !== 0) end = this.length @@ -992,12 +992,12 @@ Buffer.prototype.copy = function (target, target_start, start, end) { // Copy 0 bytes; we're done if (end === start) return 0 - if (target.length === 0 || source.length === 0) return 0 + if (target.length === 0 || self.length === 0) return 0 // Fatal error conditions if (target_start < 0) throw new RangeError('targetStart out of bounds') - if (start < 0 || start >= source.length) throw new RangeError('sourceStart out of bounds') + if (start < 0 || start >= self.length) throw new RangeError('sourceStart out of bounds') if (end < 0) throw new RangeError('sourceEnd out of bounds') // Are we oob? @@ -1171,61 +1171,50 @@ function toHex (n) { return n.toString(16) } -function utf8ToBytes(string, units) { - var codePoint, length = string.length - var leadSurrogate = null +function utf8ToBytes (string, units) { units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null var bytes = [] var i = 0 - for (; i 0xD7FF && codePoint < 0xE000) { - // last char was a lead if (leadSurrogate) { - // 2 leads in a row if (codePoint < 0xDC00) { if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) leadSurrogate = codePoint continue - } - - // valid surrogate pair - else { + } else { + // valid surrogate pair codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000 leadSurrogate = null } - } - - // no lead yet - else { + } else { + // no lead yet - // unexpected trail if (codePoint > 0xDBFF) { + // unexpected trail if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) continue - } - - // unpaired lead - else if (i + 1 === length) { + } else if (i + 1 === length) { + // unpaired lead if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) continue - } - - // valid lead - else { + } else { + // valid lead leadSurrogate = codePoint continue } } - } - - // valid bmp char, but last char was a lead - else if (leadSurrogate) { + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) leadSurrogate = null } @@ -1234,32 +1223,28 @@ function utf8ToBytes(string, units) { if (codePoint < 0x80) { if ((units -= 1) < 0) break bytes.push(codePoint) - } - else if (codePoint < 0x800) { + } else if (codePoint < 0x800) { if ((units -= 2) < 0) break bytes.push( codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80 - ); - } - else if (codePoint < 0x10000) { + ) + } else if (codePoint < 0x10000) { if ((units -= 3) < 0) break bytes.push( codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80 - ); - } - else if (codePoint < 0x200000) { + ) + } else if (codePoint < 0x200000) { if ((units -= 4) < 0) break bytes.push( codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80 - ); - } - else { + ) + } else { throw new Error('Invalid code point') } } @@ -1280,7 +1265,6 @@ function utf16leToBytes (str, units) { var c, hi, lo var byteArray = [] for (var i = 0; i < str.length; i++) { - if ((units -= 2) < 0) break c = str.charCodeAt(i) @@ -1298,7 +1282,7 @@ function base64ToBytes (str) { } function blitBuffer (src, dst, offset, length, unitSize) { - if (unitSize) length -= length % unitSize; + if (unitSize) length -= length % unitSize for (var i = 0; i < length; i++) { if ((i + offset >= dst.length) || (i >= src.length)) break diff --git a/package.json b/package.json index 2501209..a362d88 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "hyperquest": "^1.0.1", "is-nan": "^1.0.1", "split": "^0.3.2", + "standard": "^2.0.0", "tape": "^3.0.1", "through2": "^0.6.3", "zuul": "^1.12.0" @@ -47,7 +48,7 @@ "url": "git://github.com/feross/buffer.git" }, "scripts": { - "test": "node ./bin/test.js", + "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", @@ -55,6 +56,12 @@ "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/*" + ] + }, "testling": { "files": "test/*.js", "browsers": [ diff --git a/perf/writeUtf8.js b/perf/writeUtf8.js index ba1c573..820002e 100644 --- a/perf/writeUtf8.js +++ b/perf/writeUtf8.js @@ -4,7 +4,7 @@ var suite = util.suite() var LENGTH = 9 var singleByte = 'abcdefghi' -var multiByte = '\u0610' + '\u6100' + '\uD944\uDC00' +var multiByte = '\u0610' + '\u6100' + '\uD944\uDC00' var browserBuffer = new BrowserBuffer(LENGTH) var nodeBuffer = new Buffer(LENGTH) diff --git a/test/base64.js b/test/base64.js index 57b2f7b..9772de4 100644 --- a/test/base64.js +++ b/test/base64.js @@ -2,7 +2,6 @@ var B = require('../').Buffer var test = require('tape') if (process.env.OBJECT_IMPL) B.TYPED_ARRAY_SUPPORT = false - test('base64: ignore whitespace', function (t) { var text = '\n YW9ldQ== ' var buf = new B(text, 'base64') @@ -38,4 +37,3 @@ test('base64: tab characters in base64 - should get stripped', function (t) { ) t.end() }) - diff --git a/test/compare.js b/test/compare.js index d4ec003..502d35d 100644 --- a/test/compare.js +++ b/test/compare.js @@ -2,7 +2,6 @@ var B = require('../').Buffer var test = require('tape') if (process.env.OBJECT_IMPL) B.TYPED_ARRAY_SUPPORT = false - test('buffer.compare', function (t) { var b = new B(1).fill('a') var c = new B(1).fill('c') diff --git a/test/constructor.js b/test/constructor.js index e109a11..3adc097 100644 --- a/test/constructor.js +++ b/test/constructor.js @@ -2,7 +2,6 @@ var B = require('../').Buffer var test = require('tape') if (process.env.OBJECT_IMPL) B.TYPED_ARRAY_SUPPORT = false - test('new buffer from array', function (t) { t.equal( new B([1, 2, 3]).toString(), @@ -153,4 +152,3 @@ test('new buffer from buffer.toJSON() output', function (t) { t.ok(buf.equals(copy)) t.end() }) - diff --git a/test/deprecated.js b/test/deprecated.js index faa6215..0385265 100644 --- a/test/deprecated.js +++ b/test/deprecated.js @@ -2,7 +2,6 @@ var B = require('../').Buffer var test = require('tape') if (process.env.OBJECT_IMPL) B.TYPED_ARRAY_SUPPORT = false - test('.get (deprecated)', function (t) { var b = new B([7, 42]) t.equal(b.get(0), 7) diff --git a/test/from-string.js b/test/from-string.js index eebd395..25d3e57 100644 --- a/test/from-string.js +++ b/test/from-string.js @@ -2,29 +2,28 @@ var B = require('../').Buffer var test = require('tape') if (process.env.OBJECT_IMPL) B.TYPED_ARRAY_SUPPORT = false - -test('detect utf16 surrogate pairs', function(t) { +test('detect utf16 surrogate pairs', function (t) { var text = '\uD83D\uDE38' + '\uD83D\uDCAD' + '\uD83D\uDC4D' var buf = new B(text) t.equal(text, buf.toString()) t.end() }) -test('replace orphaned utf16 surrogate lead code point', function(t) { +test('replace orphaned utf16 surrogate lead code point', function (t) { var text = '\uD83D\uDE38' + '\uD83D' + '\uD83D\uDC4D' var buf = new B(text) t.deepEqual(buf, new B([ 0xf0, 0x9f, 0x98, 0xb8, 0xef, 0xbf, 0xbd, 0xf0, 0x9f, 0x91, 0x8d ])) t.end() }) -test('replace orphaned utf16 surrogate trail code point', function(t) { +test('replace orphaned utf16 surrogate trail code point', function (t) { var text = '\uD83D\uDE38' + '\uDCAD' + '\uD83D\uDC4D' var buf = new B(text) t.deepEqual(buf, new B([ 0xf0, 0x9f, 0x98, 0xb8, 0xef, 0xbf, 0xbd, 0xf0, 0x9f, 0x91, 0x8d ])) t.end() }) -test('do not write partial utf16 code units', function(t) { +test('do not write partial utf16 code units', function (t) { var f = new B([0, 0, 0, 0, 0]) t.equal(f.length, 5) var size = f.write('あいうえお', 'utf16le') @@ -33,7 +32,7 @@ test('do not write partial utf16 code units', function(t) { t.end() }) -test('handle partial utf16 code points when encoding to utf8 the way node does', function(t) { +test('handle partial utf16 code points when encoding to utf8 the way node does', function (t) { var text = '\uD83D\uDE38' + '\uD83D\uDC4D' var buf = new B(8) @@ -51,27 +50,27 @@ test('handle partial utf16 code points when encoding to utf8 the way node does', buf.write(text) t.deepEqual(buf, new B([ 0xf0, 0x9f, 0x98, 0xb8, 0x00, 0x00 ])) - var buf = new B(5); + buf = new B(5) buf.fill(0) buf.write(text) t.deepEqual(buf, new B([ 0xf0, 0x9f, 0x98, 0xb8, 0x00 ])) - var buf = new B(4); + buf = new B(4) buf.fill(0) buf.write(text) t.deepEqual(buf, new B([ 0xf0, 0x9f, 0x98, 0xb8 ])) - var buf = new B(3); + buf = new B(3) buf.fill(0) buf.write(text) t.deepEqual(buf, new B([ 0x00, 0x00, 0x00 ])) - var buf = new B(2); + buf = new B(2) buf.fill(0) buf.write(text) t.deepEqual(buf, new B([ 0x00, 0x00 ])) - var buf = new B(1); + buf = new B(1) buf.fill(0) buf.write(text) t.deepEqual(buf, new B([ 0x00 ])) @@ -79,7 +78,7 @@ test('handle partial utf16 code points when encoding to utf8 the way node does', t.end() }) -test('handle invalid utf16 code points when encoding to utf8 the way node does', function(t) { +test('handle invalid utf16 code points when encoding to utf8 the way node does', function (t) { var text = 'a' + '\uDE38\uD83D' + 'b' var buf = new B(8) diff --git a/test/methods.js b/test/methods.js index e19f9da..4f997c0 100644 --- a/test/methods.js +++ b/test/methods.js @@ -2,12 +2,11 @@ var B = require('../').Buffer var test = require('tape') if (process.env.OBJECT_IMPL) B.TYPED_ARRAY_SUPPORT = false - test('buffer.toJSON', function (t) { var data = [1, 2, 3, 4] t.deepEqual( new B(data).toJSON(), - { type: 'Buffer', data: [1,2,3,4] } + { type: 'Buffer', data: [ 1, 2, 3, 4 ] } ) t.end() }) @@ -18,8 +17,8 @@ test('buffer.copy', function (t) { var buf2 = new B(26) for (var i = 0 ; i < 26 ; i++) { - buf1[i] = i + 97; // 97 is ASCII a - buf2[i] = 33; // ASCII ! + buf1[i] = i + 97 // 97 is ASCII a + buf2[i] = 33 // ASCII ! } buf1.copy(buf2, 8, 16, 20) @@ -43,7 +42,7 @@ test('test offset returns are correct', function (t) { test('concat() a varying number of buffers', function (t) { var zero = [] - var one = [ new B('asdf') ] + var one = [ new B('asdf') ] var long = [] for (var i = 0; i < 10; i++) { long.push(new B('asdf')) @@ -57,8 +56,8 @@ test('concat() a varying number of buffers', function (t) { t.equal(flatZero.length, 0) t.equal(flatOne.toString(), 'asdf') t.equal(flatOne, one[0]) - t.equal(flatLong.toString(), (new Array(10+1).join('asdf'))) - t.equal(flatLongLen.toString(), (new Array(10+1).join('asdf'))) + t.equal(flatLong.toString(), (new Array(10 + 1).join('asdf'))) + t.equal(flatLongLen.toString(), (new Array(10 + 1).join('asdf'))) t.end() }) diff --git a/test/slice.js b/test/slice.js index 285d0ab..a9511cb 100644 --- a/test/slice.js +++ b/test/slice.js @@ -2,7 +2,6 @@ var B = require('../').Buffer var test = require('tape') if (process.env.OBJECT_IMPL) B.TYPED_ARRAY_SUPPORT = false - test('modifying buffer created by .slice() modifies original memory', function (t) { if (!B._useTypedArrays) return t.end() diff --git a/test/static.js b/test/static.js index f4f6dfc..d9d32f4 100644 --- a/test/static.js +++ b/test/static.js @@ -2,7 +2,6 @@ var B = require('../').Buffer var test = require('tape') if (process.env.OBJECT_IMPL) B.TYPED_ARRAY_SUPPORT = false - test('Buffer.isEncoding', function (t) { t.equal(B.isEncoding('HEX'), true) t.equal(B.isEncoding('hex'), true) diff --git a/test/to-string.js b/test/to-string.js index 6b388aa..172c9e9 100644 --- a/test/to-string.js +++ b/test/to-string.js @@ -2,7 +2,6 @@ var B = require('../').Buffer var test = require('tape') if (process.env.OBJECT_IMPL) B.TYPED_ARRAY_SUPPORT = false - test('utf8 buffer to base64', function (t) { t.equal( new B('Ձאab', 'utf8').toString('base64'), @@ -28,19 +27,19 @@ test('utf8 to utf8', function (t) { }) test('utf16le to utf16', function (t) { - t.equal( - new B(new B('abcd', 'utf8').toString('utf16le'), 'utf16le').toString('utf8'), - 'abcd' - ) - t.end() + t.equal( + new B(new B('abcd', 'utf8').toString('utf16le'), 'utf16le').toString('utf8'), + 'abcd' + ) + t.end() }) test('utf16le to hex', function (t) { - t.equal( - new B('abcd', 'utf16le').toString('hex'), - '6100620063006400' - ) - t.end() + t.equal( + new B('abcd', 'utf16le').toString('hex'), + '6100620063006400' + ) + t.end() }) test('ascii buffer to base64', function (t) { @@ -108,9 +107,11 @@ test('hex buffer to binary', function (t) { }) test('utf8 to binary', function (t) { + /* jshint -W100 */ t.equal( new B('öäüõÖÄÜÕ', 'utf8').toString('binary'), 'öäüõÖÄÜÕ' ) + /* jshint +W100 */ t.end() }) diff --git a/test/user-agent.js b/test/user-agent.js deleted file mode 100644 index b8e78e6..0000000 --- a/test/user-agent.js +++ /dev/null @@ -1,28 +0,0 @@ -// var B = require('../').Buffer -// var test = require('tape') -// var useragent = require('useragent') -// if (process.env.OBJECT_IMPL) B.TYPED_ARRAY_SUPPORT = false - - -// test('expected browsers get Uint8Array implementation', function (t) { -// if (typeof navigator === 'undefined') { -// t.pass('Not running in a browser -- skip this test') -// t.end() -// return -// } -// var agent = useragent.parse(navigator.userAgent) -// console.log('Family: ' + agent.family) -// console.log('Version: ' + agent.major + '.' + agent.minor) - -// if ((agent.family === 'Chrome' && agent.major >= 7) || -// (agent.family === 'Internet Explorer' && agent.major >= 10) || -// (agent.family === 'Firefox' && agent.major >= 30) || -// (agent.family === 'Opera' && agent.major >= 12) || -// (agent.family === 'Safari' && agent.major === 5 && agent.minor === 1) || -// (agent.family === 'Safari' && agent.major === 6)) { -// t.ok(B._useTypedArrays) -// } else { -// t.ok(!B._useTypedArrays) -// } -// t.end() -// }) diff --git a/test/write.js b/test/write.js index 550ca8a..e396436 100644 --- a/test/write.js +++ b/test/write.js @@ -36,18 +36,18 @@ test('hex of write{Uint,Int}{8,16,32}{LE,BE}', function (t) { 'fd', 'fdff', 'fffd', 'fdffffff', 'fffffffd' ] var reads = [ 3, 3, 3, 3, 3, -3, -3, -3, -3, -3 ] - var xs = ['UInt','Int'] - var ys = [8,16,32] + var xs = ['UInt', 'Int'] + var ys = [8, 16, 32] for (var i = 0; i < xs.length; i++) { var x = xs[i] for (var j = 0; j < ys.length; j++) { var y = ys[j] - var endianesses = (y === 8) ? [''] : ['LE','BE'] + var endianesses = (y === 8) ? [''] : ['LE', 'BE'] for (var k = 0; k < endianesses.length; k++) { var z = endianesses[k] - var v1 = new B(y / 8) - var writefn = 'write' + x + y + z + var v1 = new B(y / 8) + var writefn = 'write' + x + y + z var val = (x === 'Int') ? -3 : 3 v1[writefn](val, 0) t.equal( @@ -81,20 +81,20 @@ test('hex of write{Uint,Int}{8,16,32}{LE,BE} with overflow', function (t) { undefined, 3, 0, NaN, 0, undefined, 253, -256, 16777213, -256 ] - var xs = ['UInt','Int'] - var ys = [8,16,32] + var xs = ['UInt', 'Int'] + var ys = [8, 16, 32] for (var i = 0; i < xs.length; i++) { var x = xs[i] for (var j = 0; j < ys.length; j++) { var y = ys[j] - var endianesses = (y === 8) ? [''] : ['LE','BE'] + var endianesses = (y === 8) ? [''] : ['LE', 'BE'] for (var k = 0; k < endianesses.length; k++) { var z = endianesses[k] - var v1 = new B(y / 8 - 1) + var v1 = new B(y / 8 - 1) var next = new B(4) next.writeUInt32BE(0, 0) - var writefn = 'write' + x + y + z + var writefn = 'write' + x + y + z var val = (x === 'Int') ? -3 : 3 v1[writefn](val, 0, true) t.equal(