| 
									
										
										
										
											2009-02-25 13:22:12 -05:00
										 |  |  | ! Copyright (C) 2009 Daniel Ehrenberg | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2009-03-10 19:27:04 -04:00
										 |  |  | USING: regexp.combinators tools.test regexp kernel sequences ;
 | 
					
						
							| 
									
										
										
										
											2009-02-25 13:22:12 -05:00
										 |  |  | IN: regexp.combinators.tests | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : strings ( -- regexp )
 | 
					
						
							|  |  |  |     { "foo" "bar" "baz" } <any-of> ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { t t t } [ "foo" "bar" "baz" [ strings matches? ] tri@ ] unit-test | 
					
						
							|  |  |  | { f f f } [ "food" "ibar" "ba" [ strings matches? ] tri@ ] unit-test | 
					
						
							| 
									
										
										
										
											2009-02-25 13:22:12 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : conj ( -- regexp )
 | 
					
						
							| 
									
										
										
										
											2016-03-31 00:07:43 -04:00
										 |  |  |     { R/ .*a/ R/ b.*/ } <and> ;
 | 
					
						
							| 
									
										
										
										
											2009-02-25 13:22:12 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { t } [ "bljhasflsda" conj matches? ] unit-test | 
					
						
							|  |  |  | { f } [ "bsdfdfs" conj matches? ] unit-test | 
					
						
							|  |  |  | { f } [ "fsfa" conj matches? ] unit-test | 
					
						
							| 
									
										
										
										
											2009-02-25 13:22:12 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { f } [ "bljhasflsda" conj <not> matches? ] unit-test | 
					
						
							|  |  |  | { t } [ "bsdfdfs" conj <not> matches? ] unit-test | 
					
						
							|  |  |  | { t } [ "fsfa" conj <not> matches? ] unit-test | 
					
						
							| 
									
										
										
										
											2009-02-25 13:22:12 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { f f } [ "" "hi" [ <nothing> matches? ] bi@ ] unit-test | 
					
						
							|  |  |  | { t t } [ "" "hi" [ <nothing> <not> matches? ] bi@ ] unit-test | 
					
						
							| 
									
										
										
										
											2009-02-25 13:22:12 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { { t t t f } } [ { "" "a" "aaaaa" "aab" } [ "a" <literal> <zero-or-more> matches? ] map ] unit-test | 
					
						
							|  |  |  | { { f t t f } } [ { "" "a" "aaaaa" "aab" } [ "a" <literal> <one-or-more> matches? ] map ] unit-test | 
					
						
							|  |  |  | { { t t f f } } [ { "" "a" "aaaaa" "aab" } [ "a" <literal> <option> matches? ] map ] unit-test |