-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
44 lines (38 loc) · 1.17 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'use strict'
const eca = require('./')
const test = require('tape')
test('genLattice', (assert) => {
assert.plan(4)
const thirty = eca(30)
thirty.genLattice()
thirty.genLattice()
thirty.genLattice()
assert.deepEqual(thirty.lattices, ['00000100000', '00001110000', '00011001000', '00110111100'])
const even = eca(30, {width: 4})
even.genLattice()
even.genLattice()
assert.equal(even.lattices[2].length, 4)
assert.equal(even.lattices[0], '0100')
const custom = eca('00111001', {seed: '1001', width: 4})
custom.genLattice()
custom.genLattice()
custom.genLattice()
assert.deepEqual(custom.lattices, [ '1001', '0100', '0011', '1011' ])
})
test('generateLattices', (assert) => {
assert.plan(1)
const thirty = eca(30)
assert.deepEqual(thirty.generateLattices(3), ['00001110000', '00011001000', '00110111100'])
})
test('_initialLattice', (assert) => {
assert.plan(2)
assert.throws(() => eca(30, {width: 3, seed: '1111'}))
assert.throws(() => eca(1, {seed: [1]}))
})
test('_makeLookup', (assert) => {
assert.plan(3)
const env = eca(1)
assert.equal(env.lookup, '00000001')
assert.throws(() => env._rule(-1))
assert.throws(() => env._rule('1'))
})