Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating list-ops test generic types parameters #1463

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions exercises/practice/list-ops/list-ops.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ describe('append entries to a list and return the new list', () => {
})

xit('list to empty list', () => {
const list1 = List.create()
const list1 = List.create<number>()
const list2 = List.create(1, 2, 3, 4)
expect(list1.append(list2)).toEqual(list2)
})

xit('empty list to list', () => {
const list1 = List.create(1, 2, 3, 4)
const list2 = List.create()
const list2 = List.create<number>()
expect(list1.append(list2)).toEqual(list1)
})

Expand All @@ -75,7 +75,7 @@ describe('concat lists and lists of lists into new list', () => {
xit('list of lists', () => {
const list1 = List.create(1, 2)
const list2 = List.create(3)
const list3 = List.create()
const list3 = List.create<number>()
const list4 = List.create(4, 5, 6)
const listOfLists = List.create(list2, list3, list4)
expect(list1.concat(listOfLists)).toHaveValues(1, 2, 3, 4, 5, 6)
Expand All @@ -84,13 +84,13 @@ describe('concat lists and lists of lists into new list', () => {

describe('filter list returning only values that satisfy the filter function', () => {
xit('empty list', () => {
const list1 = List.create()
expect(list1.filter<number>((el) => el % 2 === 1)).toHaveValues()
const list1 = List.create<number>()
expect(list1.filter((el) => el % 2 === 1)).toHaveValues()
})

xit('non empty list', () => {
const list1 = List.create(1, 2, 3, 5)
expect(list1.filter<number>((el) => el % 2 === 1)).toHaveValues(1, 3, 5)
expect(list1.filter((el) => el % 2 === 1)).toHaveValues(1, 3, 5)
})
})

Expand All @@ -108,47 +108,47 @@ describe('returns the length of a list', () => {

describe('returns a list of elements whose values equal the list value transformed by the mapping function', () => {
xit('empty list', () => {
const list1 = List.create()
expect(list1.map<number>((el) => ++el)).toHaveValues()
const list1 = List.create<number>()
expect(list1.map((el) => ++el)).toHaveValues()
})

xit('non-empty list', () => {
const list1 = List.create(1, 3, 5, 7)
expect(list1.map<number>((el) => ++el)).toHaveValues(2, 4, 6, 8)
expect(list1.map((el) => ++el)).toHaveValues(2, 4, 6, 8)
})
})

describe('folds (reduces) the given list from the left with a function', () => {
xit('empty list', () => {
const list1 = List.create()
expect(list1.foldl<number, number>((acc, el) => el * acc, 2)).toEqual(2)
const list1 = List.create<number>()
expect(list1.foldl((acc, el) => el * acc, 2)).toEqual(2)
})

xit('direction independent function applied to non-empty list', () => {
const list1 = List.create(1, 2, 3, 4)
expect(list1.foldl<number, number>((acc, el) => acc + el, 5)).toEqual(15)
expect(list1.foldl((acc, el) => acc + el, 5)).toEqual(15)
})

xit('direction dependent function applied to non-empty list', () => {
const list1 = List.create(1, 2, 3, 4)
expect(list1.foldl<number, number>((acc, el) => el / acc, 24)).toEqual(64)
expect(list1.foldl((acc, el) => el / acc, 24)).toEqual(64)
})
})

describe('folds (reduces) the given list from the right with a function', () => {
xit('empty list', () => {
const list1 = List.create()
expect(list1.foldr<number, number>((acc, el) => el * acc, 2)).toEqual(2)
const list1 = List.create<number>()
expect(list1.foldr((acc, el) => el * acc, 2)).toEqual(2)
})

xit('direction independent function applied to non-empty list', () => {
const list1 = List.create(1, 2, 3, 4)
expect(list1.foldr<number, number>((acc, el) => acc + el, 5)).toEqual(15)
expect(list1.foldr((acc, el) => acc + el, 5)).toEqual(15)
})

xit('direction dependent function applied to non-empty list', () => {
const list1 = List.create(1, 2, 3, 4)
expect(list1.foldr<number, number>((acc, el) => el / acc, 24)).toEqual(9)
expect(list1.foldr((acc, el) => el / acc, 24)).toEqual(9)
})
})

Expand Down