Comparing version
@@ -9,218 +9,222 @@ import { encode, decode } from './ascii.delta'; | ||
assert(input === decode(encode(input))); | ||
assert(0 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = '0'; | ||
assert(input === decode(encode(input))); | ||
assert(1 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = 'A'; | ||
assert(input === decode(encode(input))); | ||
assert(1 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = 'a'; | ||
assert(input === decode(encode(input))); | ||
assert(1 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = 'at'; | ||
assert(input === decode(encode(input))); | ||
assert(1 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = ' '; | ||
assert(input === decode(encode(input))); | ||
assert(1 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = '|'; | ||
assert(input === decode(encode(input))); | ||
assert(1 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = '00'; | ||
assert(input === decode(encode(input))); | ||
assert(2 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = '02'; | ||
assert(input === decode(encode(input))); | ||
assert(2 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = '0A'; | ||
assert(input === decode(encode(input))); | ||
assert(2 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = '0|'; | ||
assert(input === decode(encode(input))); | ||
assert(2 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = '||'; | ||
assert(input === decode(encode(input))); | ||
assert(2 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = '|0'; | ||
assert(input === decode(encode(input))); | ||
assert(2 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = '000'; | ||
assert(input === decode(encode(input))); | ||
assert(2 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = '00z'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = '024'; | ||
assert(input === decode(encode(input))); | ||
assert(2 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = '0AZ'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = '00|'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = '|00'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = '0000'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = '000z'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = '00000'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 2 === encode(input).length); | ||
input = '0000z'; | ||
assert(input === decode(encode(input))); | ||
assert(4 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = '00024'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 2 === encode(input).length); | ||
input = '000AZ'; | ||
assert(input === decode(encode(input))); | ||
assert(4 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = 'http'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = 'CASE'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = 'Cas'; | ||
assert(input === decode(encode(input))); | ||
assert(2 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = 'lCas'; | ||
assert(input === decode(encode(input, false), false)); | ||
assert(3 === encode(input, false).length); | ||
assert(input.length - 1 === encode(input, false).length); | ||
input = '0FF7'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = '0F:F7'; | ||
assert(input === decode(encode(input))); | ||
assert(4 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = '0F::F7'; | ||
assert(input === decode(encode(input))); | ||
assert(5 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = '0Dada'; | ||
assert(input === decode(encode(input, false), false)); | ||
assert(4 === encode(input, false).length); | ||
assert(input.length - 1 === encode(input, false).length); | ||
input = '1a\x00a'; | ||
assert(input === decode(encode(input))); | ||
assert(4 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = ' Cas'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = 'J.Do'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = 'z an'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = '0.00'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = ', an'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = '-f f'; | ||
assert(input === decode(encode(input))); | ||
assert(4 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = '0%0'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = '.. '; | ||
assert(input === decode(encode(input))); | ||
assert(4 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = 's4-0dQh-'; | ||
assert(input === decode(encode(input, false), false)); | ||
assert(6 === encode(input, false).length); | ||
assert(input.length - 2 === encode(input, false).length); | ||
input = '. o.'; | ||
assert(input === decode(encode(input))); | ||
assert(4 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = '7bc2'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = ' bp'; | ||
assert(input === decode(encode(input))); | ||
assert(2 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = '6E/j7B7'; | ||
assert(input === decode(encode(input))); | ||
assert(7 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = 'Aa0'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 0 === encode(input).length); | ||
input = 'aaaaaA '; | ||
assert(input === decode(encode(input, false), false)); | ||
assert(7 === encode(input, false).length); | ||
assert(input.length - 0 === encode(input, false).length); | ||
input = 'aaaaaAN '; | ||
assert(input === decode(encode(input, false), false)); | ||
assert(8 === encode(input, false).length); | ||
assert(input.length - 0 === encode(input, false).length); | ||
input = 'aA A'; | ||
assert(input === decode(encode(input))); | ||
assert(3 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = 'aA Ur'; | ||
assert(input === decode(encode(input))); | ||
assert(4 === encode(input).length); | ||
assert(input.length - 2 === encode(input).length); | ||
input = 'dKt/o esnF'; | ||
assert(input === decode(encode(input))); | ||
assert(9 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = 'tLa6u.ps'; | ||
assert(input === decode(encode(input))); | ||
assert(7 === encode(input).length); | ||
assert(input.length - 1 === encode(input).length); | ||
input = 'fE771'; | ||
assert(input === decode(encode(input))); | ||
assert(4 === encode(input).length); | ||
}); | ||
it('verify', function () { | ||
for (let i = 0; i < 10; ++i) it(`verify ${i}`, function () { | ||
this.timeout(10 * 1e3); | ||
@@ -231,3 +235,3 @@ | ||
assert(input === decode(encode(input))); | ||
const random = xorshift.random(1); | ||
const random = xorshift.random(3 ** i); | ||
for (let i = 0; i < 1e4; ++i) { | ||
@@ -234,0 +238,0 @@ const input = [...Array(random() * 32 + 1 | 0)] |
@@ -173,3 +173,3 @@ import { encode as encodeRandom, decode as decodeRandom } from './ascii.random'; | ||
v12 ランダム文字列とパーセントエンコーディングに対応 | ||
num: 0.4224; hex: 0.3041; 36: 0.2358; 64: 0.2208; pct: 0.5833; | ||
num: 0.4224; hex: 0.3001; 36: 0.2357; 64: 0.2207; pct: 0.5833; | ||
lower: 0.3239; upper: 0.2063; camel: 0.2663; country: 0.3058; text: 0.3544; json: 0.2352; | ||
@@ -305,7 +305,7 @@ | ||
hexstate = isHEX(code); | ||
if (hexstate >>> 4 !== 0) return axisH; | ||
if (hexstate >>> 4 !== 0 && axis === axisH) return axisH; | ||
return axisN; | ||
case Segment.Lower: | ||
hexstate = isHEX(code); | ||
if (hexstate >>> 4 !== 0) return axisH; | ||
if (hexstate >>> 4 !== 0 && axis === axisH) return axisH; | ||
return axisN; | ||
@@ -360,3 +360,3 @@ case Segment.Number: | ||
if (code < 0x3a) { | ||
return hexstate >>> 4 === 0 | ||
return hexstate >>> 4 === 0// && hexstate !== 0b111 | ||
? hexstate << 4 | 0b111 | ||
@@ -367,3 +367,3 @@ : hexstate & hexstate << 4 | 0b111; | ||
if (code < 0x47) { | ||
return hexstate >>> 4 === 0 | ||
return hexstate >>> 4 === 0// && hexstate !== 0b101 | ||
? hexstate << 4 | 0b011 | ||
@@ -374,3 +374,3 @@ : (hexstate >>> 4 & hexstate) === 0b011 ? 0b011 << 4 | 0b011 : 0b011; | ||
if (code < 0x67) { | ||
return hexstate >>> 4 === 0 | ||
return hexstate >>> 4 === 0// && hexstate !== 0b011 | ||
? hexstate << 4 | 0b101 | ||
@@ -545,3 +545,3 @@ : (hexstate >>> 4 & hexstate) === 0b101 ? 0b101 << 4 | 0b101 : 0b101; | ||
output += input[i] ?? ''; | ||
base = output.charCodeAt(output.length - 1); | ||
base = input.charCodeAt(i); | ||
reset(); | ||
@@ -548,0 +548,0 @@ continue; |
@@ -35,3 +35,3 @@ import { encode, decode } from './ascii.hpack'; | ||
it('verify', function () { | ||
for (let i = 0; i < 10; ++i) it(`verify ${i}`, function () { | ||
this.timeout(10 * 1e3); | ||
@@ -42,3 +42,3 @@ | ||
assert(input === decode(encode(input))); | ||
const random = xorshift.random(1); | ||
const random = xorshift.random(3 ** i); | ||
for (let i = 0; i < 1e4; ++i) { | ||
@@ -45,0 +45,0 @@ const input = [...Array(random() * 32 + 1 | 0)] |
@@ -35,3 +35,3 @@ import { encode, decode } from './ascii.huffman'; | ||
it('verify', function () { | ||
for (let i = 0; i < 10; ++i) it(`verify ${i}`, function () { | ||
this.timeout(10 * 1e3); | ||
@@ -42,3 +42,3 @@ | ||
assert(input === decode(encode(input))); | ||
const random = xorshift.random(1); | ||
const random = xorshift.random(3 ** i); | ||
for (let i = 0; i < 1e4; ++i) { | ||
@@ -45,0 +45,0 @@ const input = [...Array(random() * 32 + 1 | 0)] |
@@ -35,3 +35,3 @@ import { encode, decode } from './ascii.random'; | ||
it('verify', function () { | ||
for (let i = 0; i < 10; ++i) it(`verify ${i}`, function () { | ||
this.timeout(10 * 1e3); | ||
@@ -42,3 +42,3 @@ | ||
assert(input === decode(encode(input))); | ||
const random = xorshift.random(1); | ||
const random = xorshift.random(3 ** i); | ||
for (let i = 0; i < 1e4; ++i) { | ||
@@ -45,0 +45,0 @@ const input = [...Array(random() * 32 + 1 | 0)] |
@@ -35,3 +35,3 @@ import { encode, decode } from './ascii.xpack'; | ||
it('verify', function () { | ||
for (let i = 0; i < 10; ++i) it(`verify ${i}`, function () { | ||
this.timeout(10 * 1e3); | ||
@@ -42,3 +42,3 @@ | ||
assert(input === decode(encode(input))); | ||
const random = xorshift.random(1); | ||
const random = xorshift.random(3 ** i); | ||
for (let i = 0; i < 1e4; ++i) { | ||
@@ -45,0 +45,0 @@ const input = [...Array(random() * 32 + 1 | 0)] |
@@ -311,3 +311,3 @@ import { Cache } from './cache'; | ||
it('verify', function () { | ||
for (let i = 0; i < 10; ++i) it(`verify ${i}`, function () { | ||
this.timeout(10 * 1e3); | ||
@@ -319,3 +319,3 @@ | ||
const trials = capacity * 1000; | ||
const random = xorshift.random(1); | ||
const random = xorshift.random(3 ** i); | ||
for (let i = 0; i < trials; ++i) { | ||
@@ -322,0 +322,0 @@ const key = random() * capacity * 10 | 0; |
@@ -56,3 +56,3 @@ import { Clock } from './clock'; | ||
it('verify', function () { | ||
for (let i = 0; i < 10; ++i) it(`verify ${i}`, function () { | ||
this.timeout(10 * 1e3); | ||
@@ -64,3 +64,3 @@ | ||
const trials = capacity * 1000; | ||
const random = zipfian(1, capacity * 1e3, 0.8, xorshift.random(1)); | ||
const random = zipfian(1, capacity * 1e3, 0.8, xorshift.random(3 ** i)); | ||
for (let i = 0; i < trials; ++i) { | ||
@@ -67,0 +67,0 @@ const key = random() * capacity * 10 | 0; |
import { Heap } from './heap'; | ||
import { pcg32 } from './random'; | ||
import { xorshift } from './random'; | ||
@@ -212,7 +212,7 @@ describe('Unit: lib/heap', () => { | ||
it('verify', async () => { | ||
for (let i = 0; i < 10; ++i) it(`verify ${i}`, function () { | ||
const heap = new Heap<number>(); | ||
const size = 1e4; | ||
const random = pcg32.random(pcg32.seed(0n, 0n)); | ||
const random = xorshift.random(3 ** i); | ||
for (let i = 0; i < size; ++i) { | ||
@@ -219,0 +219,0 @@ const ord = random() * 1e6 | 0; |
@@ -8,3 +8,3 @@ import { LRU } from './lru'; | ||
describe('LRU', () => { | ||
it('verify', function () { | ||
for (let i = 0; i < 10; ++i) it(`verify ${i}`, function () { | ||
this.timeout(10 * 1e3); | ||
@@ -16,3 +16,3 @@ | ||
const trials = capacity * 1000; | ||
const random = xorshift.random(1); | ||
const random = xorshift.random(3 ** i); | ||
for (let i = 0; i < trials; ++i) { | ||
@@ -19,0 +19,0 @@ const key = random() * capacity * 10 | 0; |
{ | ||
"name": "spica", | ||
"version": "0.0.773", | ||
"version": "0.0.774", | ||
"description": "Supervisor, Coroutine, Channel, select, AtomicPromise, Cancellation, Cache, List, Queue, Stack, and some utils.", | ||
@@ -5,0 +5,0 @@ "private": false, |
@@ -8,3 +8,3 @@ import { S3FIFO } from './s3-fifo'; | ||
describe('S3FIFO', () => { | ||
it('verify', function () { | ||
for (let i = 0; i < 10; ++i) it(`verify ${i}`, function () { | ||
this.timeout(10 * 1e3); | ||
@@ -16,3 +16,3 @@ | ||
const trials = capacity * 1000; | ||
const random = xorshift.random(1); | ||
const random = xorshift.random(3 ** i); | ||
for (let i = 0; i < trials; ++i) { | ||
@@ -19,0 +19,0 @@ const key = random() * capacity * 10 | 0; |
797447
0.17%26153
0.01%