Skip to content

Commit dc568e9

Browse files
committed
fix(tests): change mechanism for testing list equality
1 parent 692e342 commit dc568e9

26 files changed

+62
-54
lines changed

test/concat-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ describe(`concat()`, function () {
66
const lst3 = lazy.list()
77
const xss = lazy.list(lst1, lst2, lst3)
88
it(`should concatenate (flatten) the elements in a list of lists`, function () {
9-
lazy.concat(xss).should.eql(lazy.list(1, 2, 3, 4, 5, 6))
9+
lazy.concat(xss).isEq(lazy.list(1, 2, 3, 4, 5, 6)).should.be.true
1010
})
1111
})

test/cons-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as lazy from '../source'
33
describe(`cons()`, function () {
44
const lst = lazy.list(4, 5, 6)
55
it(`should create a new list from a head and tail`, function () {
6-
lazy.cons(3, lst).should.eql(lazy.list(3, 4, 5, 6))
7-
lazy.cons(1, lazy.emptyList).should.eql(lazy.list(1))
6+
lazy.cons(3, lst).isEq(lazy.list(3, 4, 5, 6))
7+
lazy.cons(1, lazy.emptyList).isEq(lazy.list(1)).should.be.true
88
})
99
})

test/cycle-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ describe(`cycle()`, function () {
44
const lst = lazy.list(1, 2, 3)
55
const cyc = lazy.cycle(lst)
66
it(`should return the infinite repetition of a list`, function () {
7-
lazy.take(9, cyc).should.eql(lazy.list(1, 2, 3, 1, 2, 3, 1, 2, 3))
7+
lazy.take(9, cyc).isEq(lazy.list(1, 2, 3, 1, 2, 3, 1, 2, 3)).should.be.true
88
lazy.index(cyc, 100).should.equal(2)
99
})
1010
it(`should throw an error if the list is empty`, function () {

test/drop-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import * as lazy from '../source'
33
describe(`drop()`, function () {
44
const lst = lazy.list(1, 2, 3)
55
it(`should return the suffix of a list after discarding a specified number of values`, function () {
6-
lazy.drop(2, lst).should.eql(lazy.list(3))
6+
lazy.drop(2, lst).isEq(lazy.list(3)).should.be.true
77
})
88
it(`should return the empty list if the second argument is the empty list`, function () {
9-
lazy.drop(2, lazy.list()).should.equal(lazy.emptyList)
9+
lazy.drop(2, lazy.list()).isEq(lazy.emptyList).should.be.true
1010
})
1111
})

test/dropWhile-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ describe(`dropWhile()`, function () {
44
const lst = lazy.list(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
55
const f = x => x < 3
66
it(`should drop values from a list while a given predicate function returns true`, function () {
7-
lazy.dropWhile(f, lst).should.eql(lazy.list(3, 4, 5, 6, 7, 8, 9, 10))
7+
lazy.dropWhile(f, lst).isEq(lazy.list(3, 4, 5, 6, 7, 8, 9, 10)).should.be.true
88
})
99
it(`should return an empty list if the second argument is an empty list`, function () {
10-
lazy.dropWhile(f, lazy.emptyList).should.equal(lazy.emptyList)
10+
lazy.dropWhile(f, lazy.emptyList).isEq(lazy.emptyList).should.be.true
1111
})
1212
})

test/filter-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ describe(`filter()`, function () {
44
const lst = lazy.listRangeBy(0, 50, x => x + 5)
55
const f = x => x % 10 === 0
66
it(`should return the list of elements in a list for which a function f returns true`, function () {
7-
lazy.filter(f, lst).should.eql(lazy.list(0, 10, 20, 30, 40, 50))
7+
lazy.filter(f, lst).isEq(lazy.list(0, 10, 20, 30, 40, 50)).should.be.true
88
})
99
})

test/fromArrayToList-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ describe(`fromArrayToList()`, function () {
44
const lst = lazy.list(1, 2, 3)
55
const arr = [1, 2, 3]
66
it(`should convert an array into a list`, function () {
7-
lazy.fromArrayToList(arr).should.eql(lst)
7+
lazy.fromArrayToList(arr).isEq(lst).should.be.true
88
})
99
})

test/fromStringToList-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import * as lazy from '../source'
33
describe(`fromStringToList()`, function () {
44
const str = lazy.list(`a`, `b`, `c`)
55
it(`should convert a string into a list`, function () {
6-
lazy.fromStringToList(`abc`).should.eql(str)
6+
lazy.fromStringToList(`abc`).isEq(str).should.be.true
77
})
88
})

test/init-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as lazy from '../source'
33
describe(`init()`, function () {
44
const lst = lazy.list(1, 2, 3)
55
it(`should return all the elements of a list except the last one`, function () {
6-
lazy.init(lst).should.eql(lazy.list(1, 2))
6+
lazy.init(lst).isEq(lazy.list(1, 2)).should.be.true
77
})
88
it(`should throw an error if the list is empty`, function () {
99
lazy.init.bind(null, lazy.emptyList).should.throw()

test/iterate-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import * as lazy from '../source'
22

33
describe(`iterate()`, function () {
44
const inf = lazy.iterate(x => x * 2, 1)
5+
const lst = lazy.list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512)
56
it(`should return an infinite list of repeated applications of a function to a value`, function () {
6-
lazy.take(10, inf).should.eql(lazy.list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512))
7+
lazy.take(10, inf).isEq(lst).should.be.true
78
lazy.index(inf, 10).should.equal(1024)
89
})
910
})

0 commit comments

Comments
 (0)