charts.lines: add tests for fix-left-chunk, fix implementation

char-rename
Alexander Iljin 2017-01-19 13:14:28 +03:00 committed by John Benediktsson
parent cfd271aa88
commit 37ec09dd7a
2 changed files with 34 additions and 2 deletions

View File

@ -47,6 +47,38 @@ IN: charts.lines.tests
-3 3 2-point-chunk
] unit-test
! fix-left-chunk: y coord = top limit
{
{ { -6 0 } { -3 3 } }
} [
{ { -6 0 } { -3 3 } } { { 5 5 } { 6 6 } }
-3 3 fix-left-chunk
] unit-test
! fix-left-chunk: y coord = bottom limit
{
{ { -6 0 } { -3 -3 } }
} [
{ { -6 0 } { -3 -3 } } { { 5 -5 } { 6 -6 } }
-3 3 fix-left-chunk
] unit-test
! fix-left-chunk: going upwards
{
{ { -6 0 } { 2 2 } { 3 3 } }
} [
{ { -6 0 } { 2 2 } } { { 5 5 } { 6 6 } }
-3 3 fix-left-chunk
] unit-test
! fix-left-chunk: going downwards
{
{ { -6 0 } { -2 -2 } { -1 -3 } }
} [
{ { -6 0 } { -2 -2 } } { { 0 -4 } { 6 -6 } }
-3 3 fix-left-chunk
] unit-test
! tight bounds
{
{ { { 0 0 } { 0 1 } { 1 2 } { 1 3 } { 2 5 } } }

View File

@ -132,14 +132,14 @@ ALIAS: y second
left-point y { [ ymin = ] [ ymax = ] } 1|| [
left
] [
left-point y right-point y < ymin ymax ? :> y-coord
left-point y right-point y > ymin ymax ? :> y-coord
left-point x right-point x = [
left-point x y-coord 2array
] [
left-point right-point calc-line-slope
y-coord left-point calc-point-y
] if
left but-last-slice swap suffix
left swap suffix
] if ;
:: fix-right-chunk ( left right ymin ymax -- right' )