mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 07:28:08 +03:00
Add Set::isEqual method in specs
This allows us to use the .toEqual matcher to compare Set objects.
This commit is contained in:
parent
224575fc46
commit
b59bec5f9d
@ -49,6 +49,25 @@ Object.defineProperty document, 'title',
|
||||
get: -> documentTitle
|
||||
set: (title) -> documentTitle = title
|
||||
|
||||
Set.prototype.jasmineToString = ->
|
||||
result = "Set {"
|
||||
first = true
|
||||
@forEach (element) ->
|
||||
result += ", " unless first
|
||||
result += element.toString()
|
||||
first = false
|
||||
result + "}"
|
||||
|
||||
Set.prototype.isEqual = (other) ->
|
||||
if other instanceof Set
|
||||
return false if @size isnt other.size
|
||||
values = @values()
|
||||
until (next = values.next()).done
|
||||
return false unless other.has(next.value)
|
||||
true
|
||||
else
|
||||
false
|
||||
|
||||
jasmine.getEnv().addEqualityTester(_.isEqual) # Use underscore's definition of equality for toEqual assertions
|
||||
|
||||
if process.env.CI
|
||||
|
Loading…
Reference in New Issue
Block a user