]> gitweb.factorcode.org Git - factor.git/commitdiff
charts.lines: add clip-data tests, fix implementation of left-cut-x
authorAlexander Iljin <ajsoft@yandex.ru>
Sat, 21 Jan 2017 19:24:04 +0000 (22:24 +0300)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 17 Apr 2017 20:54:51 +0000 (13:54 -0700)
lines/lines-tests.factor
lines/lines.factor

index 29efcbf197abaa809212e2f351c943c058b91236..0e8ee00b565d96790b55cb7b5d2ecc5facd37775 100644 (file)
@@ -257,4 +257,44 @@ IN: charts.lines.tests
     } clip-data
 ] unit-test
 
-! TODO: add tests where after search there is no adjustment necessary, so that extra adjustment would take bad elements. Also, add tests for sequences fully outside the range.
+! no points within the viewport, complete calculation
+{
+    { { 1 1 } { 4 4 } }
+} [
+    { { 1 4 } { 1 4 } }
+    { { 0 0 } { 5 5 } } clip-data
+] unit-test
+
+! no points within the viewport, complete calculation
+{
+    { { 1 4 } { 4 1 } }
+} [
+    { { 1 4 } { 1 4 } }
+    { { 0 5 } { 5 0 } } clip-data
+] unit-test
+
+! no points within the viewport, complete calculation
+{
+    { { 1 3 } { 4 3 } }
+} [
+    { { 1 4 } { 1 4 } }
+    { { 0 3 } { 5 3 } } clip-data
+] unit-test
+
+! all data are to the left of viewport
+{
+    { }
+} [
+    { { 1 4 } { 1 4 } }
+    { { -1 0 } { 0 1 } { 0.5 1 } } clip-data
+] unit-test
+
+! all data are to the right of viewport
+{
+    { }
+} [
+    { { 1 4 } { 1 4 } }
+    { { 4.5 0 } { 5 1 } { 6 1 } } clip-data
+] unit-test
+
+! TODO: add tests where after search there is no adjustment necessary, so that extra adjustment would take bad elements.
index a119463bd1512b293b5784811d96bf5fabb2c30e..9edb0029b6b9af8c6732fe9da7c0d58d55039208 100644 (file)
@@ -71,7 +71,7 @@ ALIAS: y second
 ! pairs is <= xmin, and if the first is < xmin, then the second is
 ! > xmin. Otherwise the first one would be = xmin.
 : left-cut-x ( xmin pairs -- seq )
-    2dup first x < [
+    2dup first x > [
         [ dupd first2 y-at 2array ] keep rest-slice swap prefix
     ] [
         nip