-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
propagators/conditional.test -- fix switcher -- should not take outpu…
…t as arg
- Loading branch information
Showing
3 changed files
with
19 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import test from "node:test" | ||
import { patch } from "../cell/index.js" | ||
import { run } from "../scheduler/index.js" | ||
import { conditional } from "./conditional.js" | ||
|
||
test("propagators / conditional", async () => { | ||
{ | ||
const [control, ifTrue, ifFalse, output] = conditional() | ||
patch(control, true) | ||
patch(ifFalse, 0) | ||
patch(ifTrue, 1) | ||
await run() | ||
assert(output.content === 1) | ||
Check failure on line 13 in src/propagators/conditional.test.ts GitHub Actions / build (20.x)
|
||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { nothing } from "../nothing/Nothing.js" | ||
import { definePrimitive } from "../propagator/index.js" | ||
|
||
// For `switch` is preserved by JavaScript. | ||
export const switcher = definePrimitive(3, (control, input, output) => { | ||
if (control) return input | ||
else return output | ||
}) | ||
export const switcher = definePrimitive(3, (control, input) => | ||
control ? input : nothing, | ||
) |