Jasmine will call toString() if available to print an object.

This commit is contained in:
Corey Johnson & Nathan Sobo 2012-02-02 17:00:10 -08:00
parent c92397d55f
commit 82366b1226
3 changed files with 13 additions and 0 deletions

View File

@ -20,6 +20,13 @@ window.atom = new (require 'app')
# Use underscore's definition of equality for toEqual assertions
jasmine.Env.prototype.equals_ = _.isEqual
emitObject = jasmine.StringPrettyPrinter.prototype.emitObject
jasmine.StringPrettyPrinter.prototype.emitObject = (obj) ->
if obj.toString
@append obj.toString()
else
emitObject.call(this, obj)
eventPropertiesFromPattern = (pattern) ->
bindingSet = new BindingSet("*", {})
parsedPattern = bindingSet.parseKeyPattern(pattern)

View File

@ -19,6 +19,9 @@ class Point
else
@row == other.row and @column == other.column
toString: ->
"(#{@row}, #{@column})"
compare: (other) ->
if @row > other.row
1

View File

@ -13,6 +13,9 @@ class Range
@start = pointB
@end = pointA
toString: ->
"[#{@start.toString()} - #{@end.toString()}]"
isEmpty: ->
@start.isEqual(@end)