one => { stream = new Readable() stream._read = () => {} emitter = walk(stream) stream.push('[ ]') stream.push(null) Object.keys(events).forEach(key => { emitter.on(events[key], spooks.fn({ name: key, log: log })) }) emitter.on(events.end, done) }) test('array event occurred once', () => { assert.strictEqual(log.counts.array, 1) }) test('endArray event occurred once', () => { assert.strictEqual(log.counts.endArray, 1) }) test('end event occurred once', () => { assert.strictEqual(log.counts.end, 1) }) test('error event did not occur', () => { assert.strictEqual(log.counts.error, 0) }) }) suite('chunked empty array:', () => { let stream, emitter setup(done => { stream = new Readable() stream._read = () => {} emitter = walk(stream) stream.push('[') Object.keys(events).forEach(key => { emitter.on(events[key], spooks.fn({ name: key, log: log })) }) emitter.on(events.end, done) emitter.on(events.array, stream.push.bind(stream, ']')) emitter.on(events.endArray, stream.push.bind(stream, null)) }) test('array event occurred once', () => { assert.strictEqual(log.counts.array, 1) }) test('endArray event occurred once', () => { assert.strictEqual(log.counts.endArray, 1) }) test('end event occurred once', () => { assert.strictEqual(log.counts.end, 1) }) test('error event did not occur', () => { assert.strictEqual(log.counts.error, 0) }) }) suite('chunked empty object with whitespace:', () => { let stream, emitter setup(done => { stream = new Readable() stream._read = () => {} emitter = walk(stream) stream.push(' {') Object.keys(events).forEach(key => { emitter.on(events[key], spooks.fn({ name: key, log: log })) }) emitter.on(events.end, done) emitter.on(events.object, () => { setTimeout(stream.push.bind(stream, ' }'), 20) }) emitter.on(events.endObject, () => { setTimeout(stream.push.bind(stream, null), 20) }) }) test('object event occurred once', () => { assert.strictEqual(log.counts.object, 1) }) test('endObject event occurred once', () => { assert.strictEqual(log.counts.endObject, 1) }) test('end event occurred once', () => { assert.strictEqual(log.counts.end, 1) }) test('error event did not occur', () => { assert.strictEqual(log.counts.error, 0) }) }) suite('chunked string:', () => { let stream, emitter setup(done => { stream = new Readable() stream._read = () => {} emitter = walk(stream) stream.push('"') Object.keys(events).forEach(key => { emitter.on(events[key], spooks.fn({ name: key, log: log })) }) emitter.on(events.end, done) emitter.on(events.string, () => { setTimeout(stream.push.bind(stream, null), 20) }) setTimeout(stream.push.bind(stream, '\\'), 20) setTimeout(stream.push.bind(stream, 't\\u'), 40) setTimeout(stream.push.bind(stream, '00'), 60) setTimeout(stream.push.bind(stream, 'a0'), 80) setTimeout(stream.push.bind(stream, '"'), 100) }) test('string event occurred once', () => { assert.strictEqual(log.counts.string, 1) }) test('string event was dispatched correctly', () => { assert.strictEqual(log.args.string[0][0], '\t\u00a0') }) test('end event occurred once', () => { assert.strictEqual(log.counts.end, 1) }) test('error event did not occur', () => { assert.strictEqual(log.counts.error, 0) }) }) suite('chunked number:', () => { let stream, emitter setup(done => { stream = new Readable() stream._read = () => {} emitter = walk(stream) stream.push('-') Object.keys(events).forEach(key => { emitter.on(events[key], spooks.fn({ name: key, log: log })) }) emitter.on(events.end, done) setTimeout(stream.push.bind(stream, '3'), 20) setTimeout(stream.push.bind(stream, '.'), 40) setTimeout(stream.push.bind(stream, '14159'), 60) setTimeout(stream.push.bind(stream, '265359'), 80) setTimeout(stream.push.bind(stream, 'e'), 100) setTimeout(stream.push.bind(stream, '-'), 120) setTimeout(stream.push.bind(stream, '7'), 140) setTimeout(stream.push.bind(stream, null), 160) }) test('number event occurred once', () => { assert.strictEqual(log.counts.number, 1) }) test('number event was dispatched correctly', () => { assert.strictEqual(log.args.number[0][0], -3.14159265359e-7) }) test('end event occurred once', () => { assert.strictEqual(log.counts.end, 1) }) test('error event did not occur', () => { assert.strictEqual(log.counts.error, 0) }) }) suite('chunked literal:', () => { let stream, emitter setup(done => { stream = new Readable() stream._read = () => {} emitter = walk(stream) stream.push('n') Object.keys(events).forEach(key => { emitter.on(events[key], spooks.fn({ name: key, log: log })) }) emitter.on(events.end, done) setTimeout(stream.push.bind(stream, 'u'), 20) setTimeout(stream.push.bind(stream, 'l'), 40) setTimeout(stream.push.bind(stream, 'l'), 60) setTimeout(stream.push.bind(stream, null), 80) }) test('literal event occurred once', () => { assert.strictEqual(log.counts.literal, 1) }) test('literal event was dispatched correctly', () => { assert.strictEqual(log.args.literal[0][0], null) }) test('end event occurred once', () => { assert.strictEqual(log.counts.end, 1) }) test('error event did not occur', () => { assert.strictEqual(log.counts.error, 0) }) }) suite('populated array with discard=1:', () => { let stream, emitter setup(done => { stream = new Readable() stream._read = () => {} emitter = walk(stream, { discard: 1 }) stream.push(' ') Object.keys(events).forEach(key => { emitter.on(events[key], spooks.fn({ name: key, log: log })) }) emitter.on(events.end, done) emitter.on(events.array, () => { stream.push(' ""') }) emitter.on(events.string, () => { stream.push(' ]') }) emitter.on(events.endArray, () => { stream.push(null) }) setImmediate(stream.push.bind(stream, '[')) }) test('array event occurred once', () => { assert.strictEqual(log.counts.array, 1) }) test('string event was dispatched correctly', () => { assert.strictEqual(log.args.string[0][0], "") }) test('endArray event occurred once', () => { assert.strictEqual(log.counts.endArray, 1) }) test('end event occurred once', () => { assert.strictEqual(log.counts.end, 1) }) test('string event occurred once', () => { assert.strictEqual(log.counts.string, 1) }) test('error event did not occur', () => { assert.strictEqual(log.counts.error, 0) }) }) suite('throw errors from event handlers:', () => { let stream, emitter setup(done => { stream = new Readable() stream._read = () => {} emitter = walk(stream) stream.push('[null,false,true,0,"",{"foo":"bar"}]') stream.push(null) Object.keys(events).forEach(key => { const event = events[key] emitter.on(event, spooks.fn({ name: key, log: log })) if (event !== events.end) { emitter.on(event, () => { throw 0 }) } }) emitter.on(events.end, done) }) test('array event occurred once', () => { assert.strictEqual(log.counts.array, 1) }) test('endArray event occurred once', () => { assert.strictEqual(log.counts.endArray, 1) }) test('literal event occurred three times', () => { assert.strictEqual(log.counts.literal, 3) }) test('number event occurred once', () => { assert.strictEqual(log.counts.number, 1) }) test('string event occurred twice', () => { assert.strictEqual(log.counts.string, 2) }) test('property event occurred once', () => { assert.strictEqual(log.counts.property, 1) }) test('object event occurred once', () => { assert.strictEqual(log.counts.object, 1) }) test('endObject event occurred once', () => { assert.strictEqual(log.counts.endObject, 1) }) test('error event occurred eleven times', () => { assert.strictEqual(log.counts.error, 11) }) test('end event occurred once', () => { assert.strictEqual(log.counts.end, 1) }) }) suite('error occurs on stream:', () => { let stream, emitter setup(done => { stream = new Readable() stream._read = () => {} emitter = walk(stream) Object.keys(events).forEach(key => { emitter.on(events[key], spooks.fn({ name: key, log: log })) }) stream.emit('error', new Error('wibble')) stream.push(null) emitter.on(events.end, done) }) test('error event occurred once', () => { assert.strictEqual(log.counts.error, 1) }) test('error event was dispatched correctly', () => { assert.strictEqual(log.args.error[0][0].message, 'wibble') assert.isUndefined(log.args.error[0][0].actual) assert.isUndefined(log.args.error[0][0].expected) assert.isUndefined(log.args.error[0][0].lineNumber) assert.isUndefined(log.args.error[0][0].columnNumber) }) test('end event occurred once', () => { assert.strictEqual(log.counts.end, 1) }) }) suite('two values separated by newline:', () => { let stream, emitter setup(done => { stream = new Readable() stream._read = () => {} emitter = walk(stream) stream.push('[]\n"foo"') stream.push(null) Object.keys(events).forEach(key => { emitter.on(events[key], spooks.fn({ name: key, log: log })) }) emitter.on(events.end, done) }) test('array event occurred once', () => { assert.strictEqual(log.counts.array, 1) }) test('endArray event occurred once', () => { assert.strictEqual(log.counts.endArray, 1) }) test('string event occurred once', () => { assert.strictEqual(log.counts.string, 1) }) test('error event occurred once', () => { assert.strictEqual(log.counts.error, 1) }) test('end event occurred once', () => { assert.strictEqual(log.counts.end, 1) }) test('endLine event did not occur', () => { assert.strictEqual(log.counts.endLine, 0) }) }) suite('two values separated by newline, ndjson=true:', () => { let stream, emitter setup(done => { stream = new Readable() stream._read = () => {} emitter = walk(stream, { ndjson: true }) stream.push('[]\n"foo"') stream.push(null) Object.keys(events).forEach(key => { emitter.on(events[key], spooks.fn({ name: key, log: log })) }) emitter.on(events.end, done) }) test('array event occurred once', () => { assert.strictEqual(log.counts.array, 1) }) test('endArray event occurred once', () => { assert.strictEqual(log.counts.endArray, 1) }) test('string event occurred once', () => { assert.strictEqual(log.counts.string, 1) }) test('endLine event occurred once', () => { assert.strictEqual(log.counts.endLine, 1) }) test('end event occurred once', () => { assert.strictEqual(log.counts.end, 1) }) test('error event did not occur', () => { assert.strictEqual(log.counts.error, 0) }) }) suite('two values separated by newline, ndjson=true, with embedded newlines in a value:', () => { let stream, emitter setup(done => { stream = new Readable() stream._read = () => {} emitter = walk(stream, { ndjson: true }) stream.push('[\n\n\n"foo"\n\n,\n"bar"]\n"baz"') stream.push(null) Object.keys(events).forEach(key => { emitter.on(events[key], spooks.fn({ name: key, log: log })) }) emitter.on(events.end, done) }) test('array event occurred once', () => { assert.strictEqual(log.counts.array, 1) }) test('endArray event occurred once', () => { assert.strictEqual(log.counts.endArray, 1) }) test('string event occurred three times', () => { assert.strictEqual(log.counts.string, 3) }) test('endLine event occurred once', () => { assert.strictEqual(log.counts.endLine, 1) }) test('end event occurred once', () => { assert.strictEqual(log.counts.end, 1) }) test('error event did not occur', () => { assert.strictEqual(log.counts.error, 0) }) }) suite('two values not separated by newline, ndjson=true:', () => { let stream, emitter setup(done => { stream = new Readable() stream._read = () => {} emitter = walk(stream, { ndjson: true }) stream.push('[]"foo"') stream.push(null) Object.keys(events).forEach(key => { emitter.on(events[key], spooks.fn({ name: key, log: log })) }) emitter.on(events.end, done) }) test('array event occurred once', () => { assert.strictEqual(log.counts.array, 1) }) test('endArray event occurred once', () => { assert.strictEqual(log.counts.endArray, 1) }) test('end event occurred once', () => { assert.strictEqual(log.counts.end, 1) }) test('error event occurred five times', () => { assert.strictEqual(log.counts.error, 5) }) test('string event did not occurr', () => { assert.strictEqual(log.counts.string, 0) }) test('endLine event did not occur', () => { assert.strictEqual(log.counts.endLine, 0) }) }) suite('two values separated by two newlines, ndjson=true:', () => { let stream, emitter setup(done => { stream = new Readable() stream._read = () => {} emitter = walk(stream, { ndjson: true }) stream.push('[]\r\n\r\n"foo"') stream.push(null) Object.keys(events).forEach(key => { emitter.on(events[key], spooks.fn({ name: key, log: log })) }) emitter.on(events.end, done) }) test('array event occurred once', () => { assert.strictEqual(log.counts.array, 1) }) test('endArray event occurred once', () => { assert.strictEqual(log.counts.endArray, 1) }) test('string event occurred once', () => { assert.strictEqual(log.counts.string, 1) }) test('endLine event occurred twice', () => { assert.strictEqual(log.counts.endLine, 2) }) test('end event occurred once', () => { assert.strictEqual(log.counts.end, 1) }) test('error event did not occur', () => { assert.strictEqual(log.counts.error, 0) }) }) suite('chunked ndjson:', () => { let stream, emitter setup(done => { stream = new Readable() stream._read = () => {} emitter = walk(stream, { ndjson: true }) stream.push('[]') Object.keys(events).forEach(key => { emitter.on(events[key], spooks.fn({ name: key, log: log })) }) emitter.on(events.end, done) setTimeout(stream.push.bind(stream, ' '), 20) setTimeout(stream.push.bind(stream, '\n'), 40) setTimeout(stream.push.bind(stream, ' '), 60) setTimeout(stream.push.bind(stream, '"'), 80) setTimeout(stream.push.bind(stream, 'foo"'), 100) setTimeout(stream.push.bind(stream, null), 120) }) test('array event occurred once', () => { assert.strictEqual(log.counts.array, 1) }) test('endArray event occurred once', () => { assert.strictEqual(log.counts.endArray, 1) }) test('endLine event occurred once', () => { assert.strictEqual(log.counts.endLine, 1) }) test('string event occurred once', () => { assert.strictEqual(log.counts.string, 1) }) test('end event occurred once', () => { assert.strictEqual(log.counts.end, 1) }) test('error event did not occur', () => { assert.strictEqual(log.counts.error, 0) }) }) }) }) Kodo/kodo - Gogs: Go Git Service

19 コミット (6596b01a755db75a7b90cb37d4e3e8b4b00c7109)

作者 SHA1 メッセージ 日付
  Brightcells f3cf68f957 Add PAI2_HOME_WX_API for request.weixin 7 年 前
  Brightcells a6195fa70d Add outtake lensman 7 年 前
  Brightcells 2a054aa566 Fix Bug: photo_url error 8 年 前
  Brightcells ad503a9078 User should not see photo of group which groupuser is false at home 8 年 前
  Brightcells 14d5d63e3b Add nomark/origin price for GroupPhotoInfo 8 年 前
  Brightcells ba2c19f73e Change rawsql pk to photo_id 8 年 前
  Brightcells 7111961986 Return session_id in api pai2_home_api 8 年 前
  Brightcells c12df969e1 add origin_expired_stamps 9 年 前
  Brightcells 3253541b10 change to exec raw sql from django.db.connection to records 9 年 前
  Brightcells 084a5eece8 order ruler: date/self/7*thumbup_num+3*comment_num/id 9 年 前
  Brightcells de60d59c26 order ruler: date/self/thumbup_num/id 9 年 前
  Brightcells f684a1d89c order ruler: date/self/thumbup_num 9 年 前
  Brightcells 5bf645c33d change order ruler for paiai home, user_id self upload first 9 年 前
  Brightcells d64b3c216b add and return photo_thumbnail2 relative 9 年 前
  Brightcells ec142555be return group_from for pai2_home_api 9 年 前
  Brightcells dbea356558 add photo_from field for GroupPhotoInfo and return photo_from for some api 9 年 前
  Brightcells 537bd9bd41 add api group_quit_api 9 年 前
  Brightcells 78e4e238a7 GroupUserInfo.user_status == GroupUserInfo.DELETED & error status code 9 年 前
  Brightcells f7d159714f Fix Bug: PAI2_HOME_API error 9 年 前