From 79da6e1442e255416e59f311a8ba41bc284922da Mon Sep 17 00:00:00 2001 From: Alexander Iljin Date: Thu, 19 Jan 2017 13:28:49 +0300 Subject: [PATCH] charts.lines: add tests for fix-right-chunk, fix implementation --- lines/lines-tests.factor | 32 ++++++++++++++++++++++++++++++++ lines/lines.factor | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lines/lines-tests.factor b/lines/lines-tests.factor index 129e8f3f30..43c888e1aa 100644 --- a/lines/lines-tests.factor +++ b/lines/lines-tests.factor @@ -79,6 +79,38 @@ IN: charts.lines.tests -3 3 fix-left-chunk ] unit-test +! fix-right-chunk: y coord = top limit +{ + { { 5 3 } { 6 0 } } +} [ + { { -6 6 } { -3 4 } } { { 5 3 } { 6 0 } } + -3 3 fix-right-chunk +] unit-test + +! fix-right-chunk: y coord = bottom limit +{ + { { 5 -3 } { 6 0 } } +} [ + { { -6 -6 } { -3 -4 } } { { 5 -3 } { 6 0 } } + -3 3 fix-right-chunk +] unit-test + +! fix-right-chunk: going upwards +{ + { { -3 -3 } { -2 -2 } { 6 0 } } +} [ + { { -6 -6 } { -4 -4 } } { { -2 -2 } { 6 0 } } + -3 3 fix-right-chunk +] unit-test + +! fix-right-chunk: going downwards +{ + { { -3 3 } { -2 2 } { 6 0 } } +} [ + { { -6 6 } { -4 4 } } { { -2 2 } { 6 0 } } + -3 3 fix-right-chunk +] unit-test + ! tight bounds { { { { 0 0 } { 0 1 } { 1 2 } { 1 3 } { 2 5 } } } diff --git a/lines/lines.factor b/lines/lines.factor index 9753b80b2c..da0946863f 100644 --- a/lines/lines.factor +++ b/lines/lines.factor @@ -154,7 +154,7 @@ ALIAS: y second left-point right-point calc-line-slope y-coord left-point calc-point-y ] if - right rest-slice swap suffix + right swap prefix ] if ; : first-point ( chunks -- first-point ) first first ;