Skip to content

Commit

Permalink
generics/boolean.test
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Sep 30, 2024
1 parent e675668 commit 82d420a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 0 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

> https://github.com/cicada-lang/propagator/issues/4
generics/boolean.test

propagators/boolean -- inverter
propagators/boolean.test -- inverter

Expand Down
9 changes: 9 additions & 0 deletions src/generics/boolean.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import assert from "node:assert"
import test from "node:test"
import { and, not, or } from "./boolean.js"

test("generics / boolean", () => {
assert.deepStrictEqual(not(true), false)
assert.deepStrictEqual(and(true, false), false)
assert.deepStrictEqual(or(true, false), true)
})
2 changes: 1 addition & 1 deletion src/generics/boolean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const not = defineGeneric()
defineHandler(not, [isBoolean], (x) => !x)

export const and = defineGeneric()
defineHandler(and, [isBoolean, isBoolean], (x) => x && y)
defineHandler(and, [isBoolean, isBoolean], (x, y) => x && y)

export const or = defineGeneric()
defineHandler(or, [isBoolean, isBoolean], (x, y) => x || y)

0 comments on commit 82d420a

Please sign in to comment.