-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#28 Implement Point.isBefore from Kolasu. Point and position comparis…
…on was already implemented using dataclasses. Note that Position comparisons don't consider the source field, but neither does Position is Kolasu 1.5. Add Point comparison tests as in Kolasu.
- Loading branch information
1 parent
8d2048f
commit ae3e333
Showing
4 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import unittest | ||
|
||
from pylasu.model import Point | ||
|
||
START_LINE = 1 | ||
START_COLUMN = 0 | ||
START_POINT = Point(START_LINE, START_COLUMN) | ||
|
||
|
||
class PositionTest(unittest.TestCase): | ||
def test_point_compare(self): | ||
p0 = START_POINT | ||
p1 = Point(1, 1) | ||
p2 = Point(1, 100) | ||
p3 = Point(2, 90) | ||
|
||
self.assertFalse(p0 < p0) | ||
self.assertTrue(p0 <= p0) | ||
self.assertTrue(p0 >= p0) | ||
self.assertFalse(p0 > p0) | ||
|
||
self.assertTrue(p0 < p1) | ||
self.assertTrue(p0 <= p1) | ||
self.assertFalse(p0 >= p1) | ||
self.assertFalse(p0 > p1) | ||
|
||
self.assertTrue(p0 < p2) | ||
self.assertTrue(p0 <= p2) | ||
self.assertFalse(p0 >= p2) | ||
self.assertFalse(p0 > p2) | ||
|
||
self.assertTrue(p0 < p3) | ||
self.assertTrue(p0 <= p3) | ||
self.assertFalse(p0 >= p3) | ||
self.assertFalse(p0 > p3) | ||
|
||
self.assertTrue(p1 < p2) | ||
self.assertTrue(p1 <= p2) | ||
self.assertFalse(p1 >= p2) | ||
self.assertFalse(p1 > p2) | ||
|
||
self.assertTrue(p1 < p3) | ||
self.assertTrue(p1 <= p3) | ||
self.assertFalse(p1 >= p3) | ||
self.assertFalse(p1 > p3) | ||
|
||
def test_is_before(self): | ||
p0 = START_POINT | ||
p1 = Point(1, 1) | ||
p2 = Point(1, 100) | ||
p3 = Point(2, 90) | ||
|
||
self.assertFalse(p0.is_before(p0)) | ||
self.assertTrue(p0.is_before(p1)) | ||
self.assertTrue(p0.is_before(p2)) | ||
self.assertTrue(p0.is_before(p3)) | ||
|
||
self.assertFalse(p1.is_before(p0)) | ||
self.assertFalse(p1.is_before(p1)) | ||
self.assertTrue(p1.is_before(p2)) | ||
self.assertTrue(p1.is_before(p3)) | ||
|
||
self.assertFalse(p2.is_before(p0)) | ||
self.assertFalse(p2.is_before(p1)) | ||
self.assertFalse(p2.is_before(p2)) | ||
self.assertTrue(p2.is_before(p3)) | ||
|
||
self.assertFalse(p3.is_before(p0)) | ||
self.assertFalse(p3.is_before(p1)) | ||
self.assertFalse(p3.is_before(p2)) | ||
self.assertFalse(p3.is_before(p3)) |