1 | const test = require('./config').test
|
2 | const { map, chain } = require('..')
|
3 |
|
4 |
|
5 | // --- Preserving state
|
6 |
|
7 | const checkState = (name, cpsFn, cpsFn1) => {
|
8 | test(name + 'prototype passed to transformed CPS fn', t => {
|
9 | t.is(cpsFn1.a, 22)
|
10 | })
|
11 | }
|
12 |
|
13 | const cpsFn = cb => cb(42)
|
14 | const protoObj = {a: 22}
|
15 | Object.setPrototypeOf(cpsFn, protoObj)
|
16 |
|
17 | const cpsFn1 = map(x => x*2)(cpsFn)
|
18 | const cpsFn2 = chain(x => cb => cb(x*2))(cpsFn)
|
19 |
|
20 | checkState('map: ', cpsFn, cpsFn1)
|
21 | checkState('chain: ', cpsFn, cpsFn2)
|