-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
95 changed files
with
3,296 additions
and
518 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 |
---|---|---|
@@ -1,20 +1,24 @@ | ||
import { A } from '../..' | ||
import { A, O } from '../..' | ||
|
||
describe('splitAt', () => { | ||
it('returns None', () => { | ||
expect(A.splitAt([], 1)).toBeNone() | ||
expect(A.splitAt([1, 2, 3], -1)).toBeNone() | ||
expect(A.splitAt([1, 2, 3], 4)).toBeNone() | ||
expect(A.splitAt([], 1)).toEqual(O.None) | ||
expect(A.splitAt([1, 2, 3], -1)).toEqual(O.None) | ||
expect(A.splitAt([1, 2, 3], 4)).toEqual(O.None) | ||
}) | ||
|
||
it('returns Some', () => { | ||
expect(A.splitAt([], 0)).toBeSome([[], []]) | ||
expect(A.splitAt([1], 1)).toBeSome([[1], []]) | ||
expect(A.splitAt([1, 2], 1)).toBeSome([[1], [2]]) | ||
expect(A.splitAt([true, true, false], 2)).toBeSome([[true, true], [false]]) | ||
expect(A.splitAt([[1], [2], [3], [4]], 2)).toBeSome([ | ||
[[1], [2]], | ||
[[3], [4]], | ||
]) | ||
expect(A.splitAt([], 0)).toEqual(O.Some([[], []])) | ||
expect(A.splitAt([1], 1)).toEqual(O.Some([[1], []])) | ||
expect(A.splitAt([1, 2], 1)).toEqual(O.Some([[1], [2]])) | ||
expect(A.splitAt([true, true, false], 2)).toEqual( | ||
O.Some([[true, true], [false]]), | ||
) | ||
expect(A.splitAt([[1], [2], [3], [4]], 2)).toEqual( | ||
O.Some([ | ||
[[1], [2]], | ||
[[3], [4]], | ||
]), | ||
) | ||
}) | ||
}) |
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,35 @@ | ||
import { expectType } from 'ts-expect' | ||
|
||
import { B, pipe } from '../..' | ||
|
||
describe('and', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(B.and(true, true)) | ||
}) | ||
|
||
it('combines two boolean using AND', () => { | ||
expect(B.and(true, true)).toEqual(true) | ||
expect(B.and(false, false)).toEqual(false) | ||
expect(B.and(true, false)).toEqual(false) | ||
}) | ||
|
||
it('*', () => { | ||
expect(B.and(true, true)).toEqual(true) | ||
}) | ||
}) | ||
|
||
describe('and (pipe)', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(pipe(true, B.and(true))) | ||
}) | ||
|
||
it('combines two boolean using AND', () => { | ||
expect(pipe(true, B.and(true))).toEqual(true) | ||
expect(pipe(false, B.and(false))).toEqual(false) | ||
expect(pipe(true, B.and(false))).toEqual(false) | ||
}) | ||
|
||
it('*', () => { | ||
expect(pipe(true, B.and(false))).toEqual(false) | ||
}) | ||
}) |
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,77 @@ | ||
import { expectType } from 'ts-expect' | ||
|
||
import { B, F, pipe } from '../..' | ||
|
||
describe('eq', () => { | ||
it('provides correct types', () => { | ||
expectType<string>( | ||
B.ifElse( | ||
true, | ||
() => 'ok', | ||
() => 'nok', | ||
), | ||
) | ||
}) | ||
|
||
it('folds a boolean value into a value of a different type', () => { | ||
expect( | ||
B.ifElse( | ||
true, | ||
() => 'ok', | ||
() => 'nok', | ||
), | ||
).toEqual('ok') | ||
expect( | ||
B.ifElse( | ||
false, | ||
() => 'ok', | ||
() => 'nok', | ||
), | ||
).toEqual('nok') | ||
}) | ||
|
||
it('*', () => { | ||
expect(B.ifElse(true, F.always('ts'), F.always('belt'))).toEqual('ts') | ||
}) | ||
}) | ||
|
||
describe('eq (pipe)', () => { | ||
it('provides correct types', () => { | ||
expectType<number>( | ||
pipe( | ||
true, | ||
B.ifElse( | ||
() => 0, | ||
() => 1, | ||
), | ||
), | ||
) | ||
}) | ||
|
||
it('folds a boolean value into a value of a different type', () => { | ||
expect( | ||
pipe( | ||
true, | ||
B.ifElse( | ||
() => 1, | ||
() => 0, | ||
), | ||
), | ||
).toEqual(1) | ||
expect( | ||
pipe( | ||
false, | ||
B.ifElse( | ||
() => 1, | ||
() => 0, | ||
), | ||
), | ||
).toEqual(0) | ||
}) | ||
|
||
it('*', () => { | ||
expect(pipe(false, B.ifElse(F.always('ts'), F.always('belt')))).toEqual( | ||
'belt', | ||
) | ||
}) | ||
}) |
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,35 @@ | ||
import { expectType } from 'ts-expect' | ||
|
||
import { B, pipe } from '../..' | ||
|
||
describe('implies', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(B.implies(true, true)) | ||
}) | ||
|
||
it('combines two booleans using an implication', () => { | ||
expect(B.implies(true, true)).toEqual(true) | ||
expect(B.implies(false, false)).toEqual(true) | ||
expect(B.implies(true, false)).toEqual(false) | ||
}) | ||
|
||
it('*', () => { | ||
expect(B.implies(false, true)).toEqual(true) | ||
}) | ||
}) | ||
|
||
describe('implies (pipe)', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(pipe(true, B.implies(true))) | ||
}) | ||
|
||
it('combines two booleans using an implication', () => { | ||
expect(pipe(true, B.implies(true))).toEqual(true) | ||
expect(pipe(false, B.implies(false))).toEqual(true) | ||
expect(pipe(true, B.implies(false))).toEqual(false) | ||
}) | ||
|
||
it('*', () => { | ||
expect(pipe(true, B.implies(false))).toEqual(false) | ||
}) | ||
}) |
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,33 @@ | ||
import { expectType } from 'ts-expect' | ||
|
||
import { B, pipe } from '../..' | ||
|
||
describe('inverse', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(B.inverse(true)) | ||
}) | ||
|
||
it('negates the given boolean', () => { | ||
expect(B.inverse(true)).toEqual(false) | ||
expect(B.inverse(false)).toEqual(true) | ||
}) | ||
|
||
it('*', () => { | ||
expect(B.inverse(false)).toEqual(true) | ||
}) | ||
}) | ||
|
||
describe('inverse (pipe)', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(pipe(true, B.inverse)) | ||
}) | ||
|
||
it('negates the given boolean', () => { | ||
expect(pipe(true, B.inverse)).toEqual(false) | ||
expect(pipe(false, B.inverse)).toEqual(true) | ||
}) | ||
|
||
it('*', () => { | ||
expect(pipe(true, B.inverse)).toEqual(false) | ||
}) | ||
}) |
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,35 @@ | ||
import { expectType } from 'ts-expect' | ||
|
||
import { B, pipe } from '../..' | ||
|
||
describe('nand', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(B.nand(true, true)) | ||
}) | ||
|
||
it('combines two booleans using NAND', () => { | ||
expect(B.nand(true, true)).toEqual(false) | ||
expect(B.nand(false, false)).toEqual(true) | ||
expect(B.nand(true, false)).toEqual(true) | ||
}) | ||
|
||
it('*', () => { | ||
expect(B.nand(true, false)).toEqual(true) | ||
}) | ||
}) | ||
|
||
describe('nand (pipe)', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(pipe(true, B.nand(true))) | ||
}) | ||
|
||
it('combines two booleans using NAND', () => { | ||
expect(pipe(true, B.nand(true))).toEqual(false) | ||
expect(pipe(false, B.nand(false))).toEqual(true) | ||
expect(pipe(true, B.nand(false))).toEqual(true) | ||
}) | ||
|
||
it('*', () => { | ||
expect(pipe(false, B.nand(false))).toEqual(true) | ||
}) | ||
}) |
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,35 @@ | ||
import { expectType } from 'ts-expect' | ||
|
||
import { B, pipe } from '../..' | ||
|
||
describe('nor', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(B.nor(true, true)) | ||
}) | ||
|
||
it('combines two booleans using NOR', () => { | ||
expect(B.nor(true, true)).toEqual(false) | ||
expect(B.nor(false, false)).toEqual(true) | ||
expect(B.nor(true, false)).toEqual(false) | ||
}) | ||
|
||
it('*', () => { | ||
expect(B.nor(true, false)).toEqual(false) | ||
}) | ||
}) | ||
|
||
describe('nor (pipe)', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(pipe(true, B.nor(true))) | ||
}) | ||
|
||
it('combines two booleans using NOR', () => { | ||
expect(pipe(true, B.nor(true))).toEqual(false) | ||
expect(pipe(false, B.nor(false))).toEqual(true) | ||
expect(pipe(true, B.nor(false))).toEqual(false) | ||
}) | ||
|
||
it('*', () => { | ||
expect(pipe(false, B.nor(false))).toEqual(true) | ||
}) | ||
}) |
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,35 @@ | ||
import { expectType } from 'ts-expect' | ||
|
||
import { B, pipe } from '../..' | ||
|
||
describe('or', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(B.or(true, true)) | ||
}) | ||
|
||
it('combines two booleans using OR', () => { | ||
expect(B.or(true, true)).toEqual(true) | ||
expect(B.or(false, false)).toEqual(false) | ||
expect(B.or(true, false)).toEqual(true) | ||
}) | ||
|
||
it('*', () => { | ||
expect(B.or(true, false)).toEqual(true) | ||
}) | ||
}) | ||
|
||
describe('or (pipe)', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(pipe(true, B.or(true))) | ||
}) | ||
|
||
it('combines two booleans using OR', () => { | ||
expect(pipe(true, B.or(true))).toEqual(true) | ||
expect(pipe(false, B.or(false))).toEqual(false) | ||
expect(pipe(true, B.or(false))).toEqual(true) | ||
}) | ||
|
||
it('*', () => { | ||
expect(pipe(false, B.or(false))).toEqual(false) | ||
}) | ||
}) |
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,35 @@ | ||
import { expectType } from 'ts-expect' | ||
|
||
import { B, pipe } from '../..' | ||
|
||
describe('xnor', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(B.xnor(true, true)) | ||
}) | ||
|
||
it('combines two booleans using XNOR', () => { | ||
expect(B.xnor(true, true)).toEqual(true) | ||
expect(B.xnor(false, false)).toEqual(true) | ||
expect(B.xnor(true, false)).toEqual(false) | ||
}) | ||
|
||
it('*', () => { | ||
expect(B.xnor(true, false)).toEqual(false) | ||
}) | ||
}) | ||
|
||
describe('xnor (pipe)', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(pipe(true, B.xnor(true))) | ||
}) | ||
|
||
it('combines two booleans using XNOR', () => { | ||
expect(pipe(true, B.xnor(true))).toEqual(true) | ||
expect(pipe(false, B.xnor(false))).toEqual(true) | ||
expect(pipe(true, B.xnor(false))).toEqual(false) | ||
}) | ||
|
||
it('*', () => { | ||
expect(pipe(false, B.xnor(false))).toEqual(true) | ||
}) | ||
}) |
Oops, something went wrong.