Clean up each-line combinator a bit, add unit tests
parent
3385cf5992
commit
cb56943f81
|
@ -1,8 +1,37 @@
|
|||
IN: documents.tests
|
||||
USING: documents namespaces tools.test ;
|
||||
USING: documents namespaces tools.test make arrays kernel fry ;
|
||||
|
||||
! Tests
|
||||
|
||||
[ { } ] [
|
||||
[
|
||||
{ 1 10 }
|
||||
{ 1 10 } [ , "HI" , ] each-line
|
||||
] { } make
|
||||
] unit-test
|
||||
|
||||
[ { 1 "HI" } ] [
|
||||
[
|
||||
{ 1 10 }
|
||||
{ 1 11 } [ , "HI" , ] each-line
|
||||
] { } make
|
||||
] unit-test
|
||||
|
||||
[ { 1 "HI" 2 "HI" } ] [
|
||||
[
|
||||
{ 1 10 }
|
||||
{ 2 11 } [ , "HI" , ] each-line
|
||||
] { } make
|
||||
] unit-test
|
||||
|
||||
[ { { t f 1 } { t f 2 } } ] [
|
||||
[
|
||||
{ 1 10 } { 2 11 }
|
||||
t f
|
||||
'[ [ _ _ ] dip 3array , ] each-line
|
||||
] { } make
|
||||
] unit-test
|
||||
|
||||
[ { 10 4 } ] [ { "a" } { 10 3 } text+loc ] unit-test
|
||||
[ { 10 4 } ] [ { "a" } { 10 3 } text+loc ] unit-test
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2006, 2007 Slava Pestov
|
||||
! Copyright (C) 2006, 2008 Slava Pestov
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors arrays io kernel math models namespaces make
|
||||
sequences strings splitting combinators unicode.categories
|
||||
math.order ;
|
||||
math.order math.ranges ;
|
||||
IN: documents
|
||||
|
||||
: +col ( loc n -- newloc ) [ first2 ] dip + 2array ;
|
||||
|
@ -47,7 +47,7 @@ TUPLE: document < model locs ;
|
|||
2over = [
|
||||
3drop
|
||||
] [
|
||||
[ [ first ] bi@ 1+ dup <slice> ] dip each
|
||||
[ [ first ] bi@ [a,b] ] dip each
|
||||
] if ; inline
|
||||
|
||||
: start/end-on-line ( from to line# -- n1 n2 )
|
||||
|
|
Loading…
Reference in New Issue