Skip to content

Instantly share code, notes, and snippets.

View gigasquid's full-sized avatar

Carin Meier gigasquid

View GitHub Profile
# An example of Mutual Recursion.
# A simple lexer for our parser. We only return tokens for :numbers
# and +, - and new lines.
class Lexer
attr_reader :token, :type
def initialize(stream)
@stream = stream
@tokens = []
;; Current version -- note the use of `when-valid`... it is essentially duplicating the work the
;; syntax-validation-m monad should be able to handle, so I've been attempting to
;; clean it up / refactor it to use only the monad
(defmacro expect
"Run the call form, check that all the mocks defined in the fakes
(probably with 'fake') have been satisfied, and check that the actual
results are as expected. If the expected results are a function, it
will be called with the actual result as its single argument.
@gigasquid
gigasquid / gist:2296961
Created April 4, 2012 01:26 — forked from AlexBaranosky/gist:2296469
Try expect
;; Current version -- note the use of `when-valid`... it is essentially duplicating the work the
;; syntax-validation-m monad should be able to handle, so I've been attempting to
;; clean it up / refactor it to use only the monad
(defmacro expect
"Run the call form, check that all the mocks defined in the fakes
(probably with 'fake') have been satisfied, and check that the actual
results are as expected. If the expected results are a function, it
will be called with the actual result as its single argument.