@@ -153,6 +153,61 @@ tape( 'the function tokenizes a string (nested prefixes and suffixes)', function
153153 t . end ( ) ;
154154} ) ;
155155
156+ tape ( 'the function tokenizes a string (ellipsis)' , function test ( t ) {
157+ var expected ;
158+ var actual ;
159+ var str ;
160+
161+ str = 'The quick brown fox jumps over the lazy dog... in the morning.' ;
162+ expected = [ 'The' , 'quick' , 'brown' , 'fox' , 'jumps' , 'over' , 'the' , 'lazy' , 'dog' , '...' , 'in' , 'the' , 'morning' , '.' ] ;
163+ actual = tokenize ( str ) ;
164+ t . deepEqual ( actual , expected , 'returns an array of tokens' ) ;
165+
166+ str = 'From sea to shining sea....' ;
167+ actual = tokenize ( str ) ;
168+ expected = [ 'From' , 'sea' , 'to' , 'shining' , 'sea' , '...' , '.' ] ;
169+ t . deepEqual ( actual , expected , 'returns an array of tokens' ) ;
170+
171+ str = 'He thought he had it all figured out...but then reality set in.' ;
172+ actual = tokenize ( str ) ;
173+ expected = [ 'He' , 'thought' , 'he' , 'had' , 'it' , 'all' , 'figured' , 'out...but' , 'then' , 'reality' , 'set' , 'in' , '.' ] ;
174+ t . deepEqual ( actual , expected , 'returns an array of tokens' ) ;
175+
176+ str = 'He thought he had it all figured out ...but then reality set in.' ;
177+ actual = tokenize ( str ) ;
178+ expected = [ 'He' , 'thought' , 'he' , 'had' , 'it' , 'all' , 'figured' , 'out' , '...' , 'but' , 'then' , 'reality' , 'set' , 'in' , '.' ] ;
179+ t . deepEqual ( actual , expected , 'returns an array of tokens' ) ;
180+
181+ str = 'I thought it was going to be easy ... but it wasn\'t ... so I had to work harder.' ;
182+ actual = tokenize ( str ) ;
183+ expected = [ 'I' , 'thought' , 'it' , 'was' , 'going' , 'to' , 'be' , 'easy' , '...' , 'but' , 'it' , 'wasn\'t' , '...' , 'so' , 'I' , 'had' , 'to' , 'work' , 'harder' , '.' ] ;
184+ t . deepEqual ( actual , expected , 'returns an array of tokens' ) ;
185+
186+ t . end ( ) ;
187+ } ) ;
188+
189+ tape ( 'the function tokenizes a string (phone numbers, currency, and dates)' , function test ( t ) {
190+ var expected ;
191+ var actual ;
192+ var str ;
193+
194+ str = 'Call me at 1-800-123-4567.' ;
195+ expected = [ 'Call' , 'me' , 'at' , '1-800-123-4567' , '.' ] ;
196+ actual = tokenize ( str ) ;
197+ t . deepEqual ( actual , expected , 'returns an array of tokens' ) ;
198+
199+ str = 'On 12/25/2016, I bought a new car for $25,000.00.' ;
200+ expected = [ 'On' , '12/25/2016' , ',' , 'I' , 'bought' , 'a' , 'new' , 'car' , 'for' , '$25,000.00' , '.' ] ;
201+ actual = tokenize ( str ) ;
202+ t . deepEqual ( actual , expected , 'returns an array of tokens' ) ;
203+
204+ str = 'Please call me at 1-800-123-4567 on 12/25/2016.' ;
205+ expected = [ 'Please' , 'call' , 'me' , 'at' , '1-800-123-4567' , 'on' , '12/25/2016' , '.' ] ;
206+ actual = tokenize ( str ) ;
207+
208+ t . end ( ) ;
209+ } ) ;
210+
156211tape ( 'the function tokenizes a string (preserving whitespace)' , function test ( t ) {
157212 var expected ;
158213 var actual ;
0 commit comments