minor clean-ups

This commit is contained in:
David Braun 2018-04-05 16:01:34 -04:00
parent 02ded38825
commit fda1c036b4

View file

@ -113,11 +113,9 @@ describe(`Channel function`, function() {
const a = Channel(); const a = Channel();
const b = Channel(); const b = Channel();
switch (await Channel.select([ switch (
a.shift(), await Channel.select([a.shift(), b.push(0), Channel.of().shift()])
b.push(0), ) {
Channel.of().shift()
])) {
case a: case a:
assert(false); assert(false);
break; break;
@ -237,7 +235,7 @@ describe(`Channel object`, function() {
it(`every`, async function() { it(`every`, async function() {
const even = number => number % 2 === 0; const even = number => number % 2 === 0;
assert(!await Channel.of(0, 1, 2).every(even)); assert(!(await Channel.of(0, 1, 2).every(even)));
assert(await Channel.of(0, 2, 4).every(even)); assert(await Channel.of(0, 2, 4).every(even));
}); });
@ -251,13 +249,9 @@ describe(`Channel object`, function() {
}); });
it(`forEach`, async function() { it(`forEach`, async function() {
const output = Channel(); const output = [];
(async () => { await Channel.of(0, 1, 2).forEach(value => output.push(value));
await Channel.of(0, 1, 2).forEach(output.push); assert.deepEqual(output, [0, 1, 2]);
output.close();
})();
assert.deepEqual(await output.values(), [0, 1, 2]);
}); });
it(`join`, async function() { it(`join`, async function() {
@ -331,6 +325,7 @@ describe(`Channel object`, function() {
assert.throws(() => { assert.throws(() => {
readOnly.writeOnly(); readOnly.writeOnly();
}); });
(async () => { (async () => {
await channel.push(1); await channel.push(1);
})(); })();
@ -405,7 +400,7 @@ describe(`Channel object`, function() {
const channel = Channel.of(0, 1, 2); const channel = Channel.of(0, 1, 2);
assert(await channel.some(even)); assert(await channel.some(even));
assert.deepEqual(await channel.values(), [1, 2]); assert.deepEqual(await channel.values(), [1, 2]);
assert(!await Channel.of(1, 3, 5).some(even)); assert(!(await Channel.of(1, 3, 5).some(even)));
}); });
it(`toString`, function() { it(`toString`, function() {
@ -440,6 +435,7 @@ describe(`Channel object`, function() {
}); });
assert.equal(writeOnly.value, undefined); assert.equal(writeOnly.value, undefined);
(async () => { (async () => {
await channel.shift(); await channel.shift();
})(); })();