-
-
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
166 changed files
with
10,127 additions
and
6,517 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
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
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,40 @@ | ||
import { expectType } from 'ts-expect' | ||
|
||
import { A, pipe } from '../..' | ||
|
||
describe('isEmpty', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(A.isEmpty([1, 2, 3])) | ||
}) | ||
|
||
it('returns `true` if the given array is empty', () => { | ||
expect(A.isEmpty([])).toEqual(true) | ||
}) | ||
|
||
it('returns `false` if the given array is not empty', () => { | ||
expect(A.isEmpty([1, 2, 3])).toEqual(false) | ||
}) | ||
|
||
it('*', () => { | ||
expect(A.isEmpty(['hello', 'world'])).toEqual(false) | ||
expect(A.isEmpty([])).toEqual(true) | ||
}) | ||
}) | ||
|
||
describe('isEmpty (pipe)', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(pipe([1, 2, 3], A.isEmpty)) | ||
}) | ||
|
||
it('returns `true` if the given array is empty', () => { | ||
expect(pipe([], A.isEmpty)).toEqual(true) | ||
}) | ||
|
||
it('returns `false` if the given array is not empty', () => { | ||
expect(pipe([1, 2, 3], A.isEmpty)).toEqual(false) | ||
}) | ||
|
||
it('*', () => { | ||
expect(pipe([1, 2, 3], A.isEmpty)).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,40 @@ | ||
import { expectType } from 'ts-expect' | ||
|
||
import { A, pipe } from '../..' | ||
|
||
describe('isNotEmpty', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(A.isNotEmpty([1, 2, 3])) | ||
}) | ||
|
||
it('returns `true` if the given array is not empty', () => { | ||
expect(A.isNotEmpty([1, 2, 3])).toEqual(true) | ||
}) | ||
|
||
it('returns `false` if the given array is empty', () => { | ||
expect(A.isNotEmpty([])).toEqual(false) | ||
}) | ||
|
||
it('*', () => { | ||
expect(A.isNotEmpty(['hello', 'world'])).toEqual(true) | ||
expect(A.isNotEmpty([])).toEqual(false) | ||
}) | ||
}) | ||
|
||
describe('isNotEmpty (pipe)', () => { | ||
it('provides correct types', () => { | ||
expectType<boolean>(pipe([1, 2, 3], A.isNotEmpty)) | ||
}) | ||
|
||
it('returns `true` if the given array is not empty', () => { | ||
expect(pipe([1, 2, 3], A.isNotEmpty)).toEqual(true) | ||
}) | ||
|
||
it('returns `false` if the given array is empty', () => { | ||
expect(pipe([], A.isNotEmpty)).toEqual(false) | ||
}) | ||
|
||
it('*', () => { | ||
expect(pipe([1, 2, 3], A.isNotEmpty)).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,33 @@ | ||
import { expectType } from 'ts-expect' | ||
|
||
import { A, pipe } from '../..' | ||
|
||
describe('length', () => { | ||
it('provides correct types', () => { | ||
expectType<number>(A.length([1, 2, 3, 4, 5])) | ||
}) | ||
|
||
it('returns the correct size of the given array', () => { | ||
expect(A.length([1, 2, 3, 4, 5])).toEqual(5) | ||
expect(A.length([])).toEqual(0) | ||
}) | ||
|
||
it('*', () => { | ||
expect(A.length(['hello', 'world'])).toEqual(2) | ||
}) | ||
}) | ||
|
||
describe('length (pipe)', () => { | ||
it('provides correct types', () => { | ||
expectType<number>(pipe([1, 2, 3], A.length)) | ||
}) | ||
|
||
it('returns the correct size of the given array', () => { | ||
expect(pipe([1, 2, 3], A.length)).toEqual(3) | ||
expect(pipe([], A.length)).toEqual(0) | ||
}) | ||
|
||
it('*', () => { | ||
expect(pipe([0, 2, 4], A.length)).toEqual(3) | ||
}) | ||
}) |
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,46 @@ | ||
import { expectType } from 'ts-expect' | ||
|
||
import { A, pipe } from '../..' | ||
|
||
describe('make', () => { | ||
it('provides correct types', () => { | ||
expectType<ReadonlyArray<number>>(A.make(3, 3)) | ||
expectType<ReadonlyArray<string>>(A.make(3, 'hello')) | ||
}) | ||
|
||
it('creates an empty array', () => { | ||
const result = A.make(-1, 'hello') | ||
expect(result).toEqual([]) | ||
}) | ||
|
||
it('creates a new array of size `n`', () => { | ||
const result = A.make(3, 1) | ||
expect(result).toEqual([1, 1, 1]) | ||
}) | ||
|
||
it('*', () => { | ||
expect(A.make(-1, 'hello')).toEqual([]) | ||
expect(A.make(3, 1)).toEqual([1, 1, 1]) | ||
}) | ||
}) | ||
|
||
describe('make (pipe)', () => { | ||
it('provides correct types', () => { | ||
expectType<ReadonlyArray<string>>(pipe(2, A.make('hello'))) | ||
expectType<ReadonlyArray<number>>(pipe(2, A.make(5))) | ||
}) | ||
|
||
it('creates an empty array', () => { | ||
const result = pipe(-1, A.make('hello')) | ||
expect(result).toEqual([]) | ||
}) | ||
|
||
it('creates a new array of size `n`', () => { | ||
const result = pipe(3, A.make(1)) | ||
expect(result).toEqual([1, 1, 1]) | ||
}) | ||
|
||
it('*', () => { | ||
expect(pipe(2, A.make('hello'))).toEqual(['hello', 'hello']) | ||
}) | ||
}) |
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,18 @@ | ||
import { expectType } from 'ts-expect' | ||
|
||
import { A } from '../..' | ||
|
||
describe('makeEmpty', () => { | ||
it('provides correct types', () => { | ||
expectType<ReadonlyArray<number>>(A.makeEmpty<number>()) | ||
}) | ||
|
||
it('creates an empty array', () => { | ||
const result = A.makeEmpty<string>() | ||
expect(result).toEqual([]) | ||
}) | ||
|
||
it('*', () => { | ||
expect(A.makeEmpty<number>()).toEqual([]) | ||
}) | ||
}) |
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,19 @@ | ||
import { expectType } from 'ts-expect' | ||
|
||
import { A } from '../..' | ||
|
||
describe('makeWithIndex', () => { | ||
it('provides correct types', () => { | ||
expectType<ReadonlyArray<string>>(A.makeWithIndex(4, index => `${index}`)) | ||
expectType<ReadonlyArray<number>>(A.makeWithIndex(4, index => index * 2)) | ||
}) | ||
|
||
it('returns a new array of size `n`', () => { | ||
const result = A.makeWithIndex(5, index => index * 2) | ||
expect(result).toEqual([0, 2, 4, 6, 8]) | ||
}) | ||
|
||
it('*', () => { | ||
expect(A.makeWithIndex(5, index => index * 2)).toEqual([0, 2, 4, 6, 8]) | ||
}) | ||
}) |
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,37 @@ | ||
import { expectType } from 'ts-expect' | ||
|
||
import { A, pipe } from '../..' | ||
|
||
const xs = [1, 2, 3, 4, 5] | ||
|
||
describe('reverse', () => { | ||
it('provides correct types', () => { | ||
expectType<ReadonlyArray<number>>(A.reverse(xs)) | ||
expectType<ReadonlyArray<string>>(A.reverse(['hello', 'world'])) | ||
}) | ||
|
||
it('returns the provided array in reverse order', () => { | ||
const result = A.reverse(xs) | ||
expect(result).toEqual([5, 4, 3, 2, 1]) | ||
}) | ||
|
||
it('*', () => { | ||
expect(A.reverse([1, 2, 3, 4, 5])).toEqual([5, 4, 3, 2, 1]) | ||
}) | ||
}) | ||
|
||
describe('make (pipe)', () => { | ||
it('provides correct types', () => { | ||
expectType<ReadonlyArray<number>>(pipe(xs, A.reverse)) | ||
expectType<ReadonlyArray<string>>(pipe(['hello', 'world'], A.reverse)) | ||
}) | ||
|
||
it('returns the provided array in reverse order', () => { | ||
const result = pipe(xs, A.reverse) | ||
expect(result).toEqual([5, 4, 3, 2, 1]) | ||
}) | ||
|
||
it('*', () => { | ||
expect(pipe(['hello', 'world'], A.reverse)).toEqual(['world', 'hello']) | ||
}) | ||
}) |
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,14 +1,23 @@ | ||
import { A } from '../..' | ||
import { A, O, pipe } from '../..' | ||
|
||
describe('tail', () => { | ||
it('should return None', () => { | ||
expect(A.tail([])).toBeNone() | ||
it('returns None', () => { | ||
expect(A.tail([])).toEqual(O.None) | ||
}) | ||
|
||
it('should return Some', () => { | ||
expect(A.tail([1, 2, 3])).toBeSome([2, 3]) | ||
expect(A.tail([true, true, false])).toBeSome([true, false]) | ||
expect(A.tail([{ prop: 1 }, { prop: 2 }])).toBeSome([{ prop: 2 }]) | ||
expect(A.tail([[1], [2], [3]])).toBeSome([[2], [3]]) | ||
it('returns Some', () => { | ||
expect(A.tail([1, 2, 3])).toEqual(O.Some([2, 3])) | ||
expect(A.tail([true, true, false])).toEqual(O.Some([true, false])) | ||
expect(A.tail([{ prop: 1 }, { prop: 2 }])).toEqual(O.Some([{ prop: 2 }])) | ||
expect(A.tail([[1], [2], [3]])).toEqual(O.Some([[2], [3]])) | ||
}) | ||
|
||
it('*', () => { | ||
const { Some, None } = O | ||
|
||
expect(A.tail([1, 2, 3])).toEqual(Some([2, 3])) | ||
expect(A.tail([1])).toEqual(Some([])) | ||
expect(A.tail([])).toEqual(None) | ||
expect(pipe([1, 2, 3, 4], A.tail)).toEqual(Some([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
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
Oops, something went wrong.