urbit-ob

JavaScript utilities for phonemic base wrangling.
Log | Files | Refs | README

commit 754f3414b6c58099ca203f5d05e822d5f4e82800
parent b5c593e2fa36d467484ee5af63df3921717aba9f
Author: Jared Tobin <jared@jtobin.io>
Date:   Mon, 18 Mar 2019 10:13:17 +1300

Update test code.

Removes tests of the deprecated @p functions.

Includes a couple of extra unit tests of @p values previously known to
collide.

Diffstat:
Mtest/co.test.js | 42+++++-------------------------------------
Mtest/ob.test.js | 74+++++++-------------------------------------------------------------------
2 files changed, 12 insertions(+), 104 deletions(-)

diff --git a/test/co.test.js b/test/co.test.js @@ -6,18 +6,12 @@ const { patp2hex, hex2patp, patp2dec, - vatp, - vatp2hex, - hex2vatp, - vatp2dec, patq, patq2hex, hex2patq, patq2dec, clan, sein, - clen, - sign, eqPatq, isValidPatq, isValidPatp @@ -28,17 +22,12 @@ const patps = jsc.uint32.smap( pp => parseInt(patp2dec(pp)) ) -const vatps = jsc.uint32.smap( - num => vatp(num), - pp => parseInt(vatp2dec(pp)) -) - const patqs = jsc.uint32.smap( num => patq(num), pq => parseInt(patq2dec(pq)) ) -describe('patp, vatp, etc.', () => { +describe('patp, etc.', () => { it('patp2dec matches expected reference values', () => { expect(patp2dec('~zod')).to.equal('0') expect(patp2dec('~lex')).to.equal('200') @@ -46,6 +35,8 @@ describe('patp, vatp, etc.', () => { expect(patp2dec('~samzod')).to.equal('1024') expect(patp2dec('~poldec-tonteg')).to.equal('9896704') expect(patp2dec('~nidsut-tomdun')).to.equal('15663360') + expect(patp2dec('~morlyd-mogmev')).to.equal('3108299008') + expect(patp2dec('~fipfes-morlyd')).to.equal('479733505') }) it('patp matches expected reference values', () => { @@ -55,6 +46,8 @@ describe('patp, vatp, etc.', () => { expect(patp('1024')).to.equal('~samzod') expect(patp('9896704')).to.equal('~poldec-tonteg') expect(patp('15663360')).to.equal('~nidsut-tomdun') + expect(patp('3108299008')).to.equal('~morlyd-mogmev') + expect(patp('479733505')).to.equal('~fipfes-morlyd') }) it('large patp values match expected reference values', () => { @@ -86,19 +79,6 @@ describe('patp, vatp, etc.', () => { jsc.assert(iso1) }) - it('vatp and vatp2dec are inverses', () => { - let iso0 = jsc.forall(jsc.uint32, num => - parseInt(vatp2dec(vatp(num))) === num - ) - - let iso1 = jsc.forall(vatps, vp => - vatp(vatp2dec(vp)) === vp - ) - - jsc.assert(iso0, { tests: 10000 }) - jsc.assert(iso1, { tests: 10000 }) - }) - it('patp2hex and hex2patp are inverses', () => { let iso0 = jsc.forall(jsc.uint32, num => parseInt(patp2hex(hex2patp(num.toString(16))), 16) === num @@ -112,18 +92,6 @@ describe('patp, vatp, etc.', () => { jsc.assert(iso1) }) - it('vatp2hex and hex2vatp are inverses', () => { - let iso0 = jsc.forall(jsc.uint32, num => - parseInt(vatp2hex(hex2vatp(num.toString(16))), 16) === num - ) - - let iso1 = jsc.forall(vatps, vp => - hex2vatp(vatp2hex(vp)) === vp - ) - - jsc.assert(iso0) - jsc.assert(iso1) - }) }) describe('patq, etc.', () => { diff --git a/test/ob.test.js b/test/ob.test.js @@ -3,16 +3,10 @@ const { expect } = require('chai'); const jsc = require('jsverify') const { isEqual } = require('lodash') const { - feen, fein, - fend, fynd, - fice, feis, - teil, - tail, - rynd, - rund + tail } = require('../src/internal/ob') const uint32 = jsc.uint32.smap( @@ -26,37 +20,10 @@ const planets = (bn) => bn.toNumber() ) -describe('feen/fend', () => { - it('feen and fend are inverses', () => { - let prop = jsc.forall(uint32, bn => - fend(feen(bn)).eq(bn) && feen(fend(bn)).eq(bn)) - - jsc.assert(prop) - }) - - it('feen matches expected reference values', () => { - let input = new BN('123456789') - let output = new BN('1897766331') - expect(feen(input).eq(output)).to.equal(true) - - input = new BN('15663360') - output = new BN('1208402137') - expect(feen(input).eq(output)).to.equal(true) - }) - - it('fend matches expected reference values', () => { - let input = new BN('1897766331') - let output = new BN('123456789') - expect(fend(input).eq(output)).to.equal(true) - - input = new BN('1208402137') - output = new BN('15663360') - expect(fend(input).eq(output)).to.equal(true) - }) -}) - describe('fein/fynd', () => { - it('fein and fynd are inverses', () => { + it('fein and fynd are inverses', function() { + this.timeout(5000) + let prop = jsc.forall(uint32, bn => fynd(fein(bn)).eq(bn) && fein(fynd(bn)).eq(bn)) @@ -84,37 +51,10 @@ describe('fein/fynd', () => { }) }) -describe('fice/teil', () => { - it('fice and teil are inverses', () => { - let prop = jsc.forall(uint32, bn => - fice(teil(bn)).eq(bn) && teil(fice(bn)).eq(bn)) - - jsc.assert(prop) - }) - - it('fice matches expected reference values', () => { - let input = new BN ('123456789') - let output = new BN('2060458291') - expect(fice(input).eq(output)).to.equal(true) - - input = new BN('15663360') - output = new BN('1195593620') - expect(fice(input).eq(output)).to.equal(true) - }) - - it('teil matches expected reference values', () => { - let input = new BN('2060458291') - let output = new BN ('123456789') - expect(teil(input).eq(output)).to.equal(true) - - input = new BN('1195593620') - output = new BN('15663360') - expect(teil(input).eq(output)).to.equal(true) - }) -}) - describe('feis/tail', () => { - it('feis and tail are inverses over the space of planets', () => { + it('feis and tail are inverses over the space of planets', function() { + this.timeout(5000) + let prop = jsc.forall(planets, bn => feis(tail(bn)).eq(bn) && tail(feis(bn)).eq(bn) )