Created
September 22, 2009 13:27
-
-
Save olabini/191064 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Then = Origin mimic | |
Then allThens = [] | |
Then match = method(inputText, | |
allThens each(th, | |
if(th pattern =~ inputText, | |
th code call(*(it names map(nm, it[nm])))))) | |
then = dmacro( | |
[>pattern, code] | |
messages = pattern names map(nm, | |
Message fromText(nm asText)) | |
messages << code | |
lexicalCode = LexicalBlock createFrom(messages, call ground) | |
Then allThens << Then with(pattern: pattern, code: lexicalCode) | |
) | |
then(#/I should have ({cukes}.*) cukes in my belly/, | |
cukes println) | |
then(#/I should have ({howMany}\d+) ({itemName}.*) in my belly/, | |
"got #{howMany} #{itemName}" println) | |
Then match("I should have 42 cukes in my belly") | |
Then match("I should have 25 banananananananas in my belly") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment