Replace JavaScript Standard Style with Prettier.
This commit is contained in:
parent
b9638f2113
commit
d7355e17e1
9 changed files with 647 additions and 675 deletions
|
@ -4,70 +4,73 @@
|
|||
|
||||
// Test simple select.
|
||||
|
||||
'use strict'
|
||||
"use strict";
|
||||
|
||||
const Channel = require('../../lib')
|
||||
const Channel = require("../../lib");
|
||||
|
||||
it(`select`, async function () {
|
||||
const closed = Channel()
|
||||
closed.close()
|
||||
let counter = 0
|
||||
let shift = 0
|
||||
it(`select`, async function() {
|
||||
const closed = Channel();
|
||||
closed.close();
|
||||
let counter = 0;
|
||||
let shift = 0;
|
||||
|
||||
const GetValue = () => {
|
||||
counter++
|
||||
return 1 << shift
|
||||
}
|
||||
counter++;
|
||||
return 1 << shift;
|
||||
};
|
||||
|
||||
const Send = async (a, b) => {
|
||||
let done = false
|
||||
let i = 0
|
||||
let done = false;
|
||||
let i = 0;
|
||||
|
||||
do {
|
||||
switch (await Channel.select(a.push(GetValue()), b.push(GetValue()),
|
||||
closed.shift())) {
|
||||
switch (await Channel.select(
|
||||
a.push(GetValue()),
|
||||
b.push(GetValue()),
|
||||
closed.shift()
|
||||
)) {
|
||||
case a:
|
||||
i++
|
||||
a = Channel()
|
||||
break
|
||||
i++;
|
||||
a = Channel();
|
||||
break;
|
||||
|
||||
case b:
|
||||
i++
|
||||
b = Channel()
|
||||
break
|
||||
i++;
|
||||
b = Channel();
|
||||
break;
|
||||
|
||||
default:
|
||||
done = true
|
||||
done = true;
|
||||
}
|
||||
|
||||
shift++
|
||||
} while (!done)
|
||||
shift++;
|
||||
} while (!done);
|
||||
|
||||
return i
|
||||
}
|
||||
return i;
|
||||
};
|
||||
|
||||
let a = Channel(1)
|
||||
let b = Channel(1)
|
||||
let v = await Send(a, b)
|
||||
let a = Channel(1);
|
||||
let b = Channel(1);
|
||||
let v = await Send(a, b);
|
||||
|
||||
if (v !== 2) {
|
||||
throw new Error(`Send returned ${v} !== 2`)
|
||||
throw new Error(`Send returned ${v} !== 2`);
|
||||
}
|
||||
|
||||
const av = await a.shift()
|
||||
const bv = await b.shift()
|
||||
const av = await a.shift();
|
||||
const bv = await b.shift();
|
||||
|
||||
if ((av | bv) !== 3) {
|
||||
throw new Error(`bad values ${av} ${bv}`)
|
||||
throw new Error(`bad values ${av} ${bv}`);
|
||||
}
|
||||
|
||||
v = await Send(a, Channel())
|
||||
v = await Send(a, Channel());
|
||||
|
||||
if (v !== 1) {
|
||||
throw new Error(`Send returned ${v} !== 1`)
|
||||
throw new Error(`Send returned ${v} !== 1`);
|
||||
}
|
||||
|
||||
if (counter !== 10) {
|
||||
throw new Error(`counter is ${counter} !== 10`)
|
||||
throw new Error(`counter is ${counter} !== 10`);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue