Skip to content

Instantly share code, notes, and snippets.

@hashmal
Last active December 16, 2015 09:39
Show Gist options
  • Save hashmal/5414895 to your computer and use it in GitHub Desktop.
Save hashmal/5414895 to your computer and use it in GitHub Desktop.
-- Copyright (c) 2013, Jeremy Pinat.
------------------------------------------------------------------------------
-- --
-- PARSER TESTS --
-- --
------------------------------------------------------------------------------
(with) "lib/test.shk"
(=> <>type) [
length? 1 = not [abort] !?
uncons >< << type? >< <<
]
------------------------------------------------------------------------------
(test/run)
[
--+-------------------------------------+-----------------------+-------------
--| Computation | Expectation |-------------
[ "1" $parse [1] ] assert_equal
[ "1" $parse <>type :Number ] assert_equal
[ "12" $parse [12] ] assert_equal
[ "12" $parse <>type :Number ] assert_equal
[ "-1" $parse [-1] ] assert_equal
[ "-1" $parse <>type :Number ] assert_equal
[ "1_" $parse ] assert_error
[ "0.1" $parse [0.1] ] assert_equal
[ "0.1" $parse <>type :Number ] assert_equal
[ ".1" $parse ] assert_error
[ "0." $parse ] assert_error
[ "-.0" $parse ] assert_error
[ "'a" $parse ['a] ] assert_equal
[ "'a" $parse <>type :Character ] assert_equal
[ "'ab" $parse ] assert_error
[ "\"a\"" $parse [['a]] ] assert_equal
[ "\"a\"" $parse <>type :List ] assert_equal
--+---------------------------------+---------------------------+-------------
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment