diff --git a/spec/atom/point-spec.coffee b/spec/atom/point-spec.coffee index c4d095775..0b6852e3b 100644 --- a/spec/atom/point-spec.coffee +++ b/spec/atom/point-spec.coffee @@ -1,6 +1,17 @@ Point = require 'point' describe "Point", -> + describe ".isEqual(value)", -> + describe "when given value is a Point", -> + it "returns true when the rows and columns match", -> + expect(new Point(1,2)).toEqual new Point(1,2) + expect(new Point(2,1)).not.toEqual new Point(1,2) + + describe "when given value is an Array", -> + it "returns true only when index zero matches row and index one matches column", -> + expect(new Point(1,2)).toEqual [1,2] + expect(new Point(2,1)).not.toEqual [1,2] + describe "compare", -> it "returns 1, 0, or -1 based on whether the given point precedes, equals, or follows the receivers location in the buffer", -> expect(new Point(5, 0).compare(new Point(5, 0))).toBe 0 diff --git a/src/atom/point.coffee b/src/atom/point.coffee index 8e1076f9a..3c3f7d103 100644 --- a/src/atom/point.coffee +++ b/src/atom/point.coffee @@ -14,7 +14,10 @@ class Point constructor: (@row, @column) -> isEqual: (other) -> - @row == other.row && @column == other.column + if other instanceof Array + @row == other[0] and @column == other[1] + else + @row == other.row and @column == other.column compare: (other) -> if @row > other.row