-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged by gomerge CLI.
- Loading branch information
Showing
4 changed files
with
98 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import * as _ from 'radashi' | ||
|
||
describe('first', () => { | ||
test('inlined array', () => { | ||
expectTypeOf(_.first([])).toEqualTypeOf<undefined>() | ||
expectTypeOf(_.first([1, 2, 3])).toEqualTypeOf<1>() | ||
}) | ||
|
||
test('variable with empty array', () => { | ||
const emptyArray = [] as never[] | ||
|
||
expectTypeOf(_.first(emptyArray)).toEqualTypeOf<undefined>() | ||
}) | ||
|
||
test('variable with mutable array', () => { | ||
const array = [1, 2, 3] | ||
|
||
expectTypeOf(_.first(array)).toEqualTypeOf<number | undefined>() | ||
}) | ||
|
||
test('variable with readonly tuple', () => { | ||
const emptyTuple = [] as const | ||
const tuple = [1, 2, 3] as const | ||
|
||
expectTypeOf(_.first(emptyTuple)).toEqualTypeOf<undefined>() | ||
expectTypeOf(_.first(tuple)).toEqualTypeOf<1>() | ||
}) | ||
|
||
test('with default value', () => { | ||
const emptyArray = [] as never[] | ||
const emptyTuple = [] as const | ||
const array = [1, 2, 3] | ||
const tuple = [1, 2, 3] as const | ||
|
||
expectTypeOf(_.first(emptyArray, false)).toEqualTypeOf<false>() | ||
expectTypeOf(_.first(emptyTuple, false)).toEqualTypeOf<false>() | ||
expectTypeOf(_.first(array, false)).toEqualTypeOf<number | false>() | ||
expectTypeOf(_.first(tuple, false)).toEqualTypeOf<1>() | ||
}) | ||
}) |
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 * as _ from 'radashi' | ||
|
||
describe('last', () => { | ||
test('inlined array', () => { | ||
expectTypeOf(_.last([])).toEqualTypeOf<undefined>() | ||
expectTypeOf(_.last([1, 2, 3])).toEqualTypeOf<3>() | ||
}) | ||
|
||
test('variable with empty array', () => { | ||
const emptyArray = [] as never[] | ||
|
||
expectTypeOf(_.last(emptyArray)).toEqualTypeOf<undefined>() | ||
}) | ||
|
||
test('variable with mutable array', () => { | ||
const array = [1, 2, 3] | ||
|
||
expectTypeOf(_.last(array)).toEqualTypeOf<number | undefined>() | ||
}) | ||
|
||
test('variable with readonly tuple', () => { | ||
const emptyTuple = [] as const | ||
const tuple = [1, 2, 3] as const | ||
|
||
expectTypeOf(_.last(emptyTuple)).toEqualTypeOf<undefined>() | ||
expectTypeOf(_.last(tuple)).toEqualTypeOf<3>() | ||
}) | ||
|
||
test('with default value', () => { | ||
const emptyArray = [] as never[] | ||
const emptyTuple = [] as const | ||
const array = [1, 2, 3] | ||
const tuple = [1, 2, 3] as const | ||
|
||
expectTypeOf(_.last(emptyArray, false)).toEqualTypeOf<false>() | ||
expectTypeOf(_.last(emptyTuple, false)).toEqualTypeOf<false>() | ||
expectTypeOf(_.last(array, false)).toEqualTypeOf<number | false>() | ||
expectTypeOf(_.last(tuple, false)).toEqualTypeOf<3>() | ||
}) | ||
}) |