mirror of
https://github.com/jackfoxy/urQL.git
synced 2025-01-07 08:48:03 +03:00
namespace tests
This commit is contained in:
parent
7758efc5b2
commit
3e22a6b764
@ -42,6 +42,8 @@
|
||||
(cold %create-view ;~(plug whitespace (jester 'create') whitespace (jester 'view')))
|
||||
:: (cold ;~(plug whitespace (jester '') whitespace (jester '')))
|
||||
==
|
||||
~| 'Current database name is not a proper face'
|
||||
=/ dummy (scan (trip current-database) sym)
|
||||
:: main loop
|
||||
::
|
||||
|-
|
||||
|
@ -1,50 +0,0 @@
|
||||
|%
|
||||
+$ states ?(%unknown %create)
|
||||
+$ token ?(%create tape)
|
||||
++ resolve-face
|
||||
|= [buffer=tape pos=[@ud @ud]]
|
||||
^- @t
|
||||
~| "Cannot parse {<pos>} to face"
|
||||
`@t`(scan (flop buffer) sym)
|
||||
++ resolve-unknown
|
||||
|= [buffer=tape pos=[@ud @ud]]
|
||||
^- [states token]
|
||||
~| "Cannot parse {<pos>}"
|
||||
?: =('etaerc' (crip (cass buffer)))
|
||||
[%create %create]
|
||||
!!
|
||||
++ parse
|
||||
|= script=tape
|
||||
~| 'Input script is empty.'
|
||||
?> !=((lent script) 0)
|
||||
^- (list token)
|
||||
=/ tokens `(list token)`~
|
||||
=/ buffer `tape`~
|
||||
=/ state `states`%unknown
|
||||
=/ script-position [1 1]
|
||||
=/ buffer-position [1 1]
|
||||
|-
|
||||
:: https://github.com/urbit/arvo/issues/1024
|
||||
::
|
||||
?: =(~ script)
|
||||
?: &(=((lent tokens) 0) =((lent buffer) 0))
|
||||
~| "no input"
|
||||
!!
|
||||
?- state
|
||||
%unknown
|
||||
~& "state is: {<state>}"
|
||||
~& "tokens is: {<tokens>}"
|
||||
~& "buffer is: {<buffer>}"
|
||||
~| "incomplete statement {<buffer-position>}"
|
||||
!!
|
||||
%create
|
||||
tokens
|
||||
:: (flop `(list token)`[(resolve-face [buffer buffer-position]) tokens])
|
||||
==
|
||||
?- state
|
||||
%unknown
|
||||
!!
|
||||
%create
|
||||
!!
|
||||
==
|
||||
--
|
@ -1,12 +1,49 @@
|
||||
/+ parse, *test
|
||||
/+ parse, *test
|
||||
::
|
||||
:: we frequently break the rules of unit and regression tests here
|
||||
:: by testing more than one thing per result, otherwise there would
|
||||
:: just be too many tests
|
||||
::
|
||||
:: each arm tests one urql command
|
||||
::
|
||||
:: common things to test
|
||||
:: 1) basic command works producing AST object
|
||||
:: 2) multiple ASTs
|
||||
:: 3) all keywords are case ambivalent
|
||||
:: 4) all names follow rules for faces
|
||||
:: 5) all qualifier combinations work
|
||||
::
|
||||
:: -test /=urql=/tests/lib/parse/hoon ~
|
||||
|%
|
||||
++ test-blah
|
||||
;: weld
|
||||
%+ expect-eq
|
||||
!> %.y
|
||||
!> %.y
|
||||
::
|
||||
%+ expect-eq
|
||||
!> %.y
|
||||
!> %.y
|
||||
:: watch rsync -zr --delete ~/GitRepos/urQL/urql/* ~/urbit/zod/urql
|
||||
:: current database must be proper face
|
||||
++ test-current-database
|
||||
%- expect-fail
|
||||
|. (parse:parse ['Other-db' "cReate\0d\09 namespace my-namespace"])
|
||||
::
|
||||
:: tests 1, 2, 3, 5, and extra whitespace characters
|
||||
++ test-create-namespace-1
|
||||
=/ expected1 [%create-namespace database-name='other-db' name='my-namespace']
|
||||
=/ expected2 [%create-namespace database-name='my-db' name='another-namespace']
|
||||
%+ expect-eq
|
||||
!> ~[expected1 expected2]
|
||||
!> %- parse:parse
|
||||
['other-db' "cReate\0d\09 namespace my-namespace ; cReate namesPace my-db.another-namespace"]
|
||||
::
|
||||
:: leading and trailing whitespace characters, end delimiter not required on single
|
||||
++ test-create-namespace-2
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='other-db' name='my-namespace']]
|
||||
!> %- parse:parse
|
||||
['other-db' " \09cReate\0d\09 namespace my-namespace "]
|
||||
::
|
||||
:: fail when database qualifier is not a face
|
||||
++ test-create-namespace-3
|
||||
%- expect-fail
|
||||
|. (parse:parse ['other-db' "cReate namesPace Bad-face.another-namespace"])
|
||||
::
|
||||
:: fail when namespace is not a face
|
||||
++ test-create-namespace-4
|
||||
%- expect-fail
|
||||
|. (parse:parse ['other-db' "cReate namesPace my-db.Bad-face"])
|
||||
|
||||
--
|
||||
|
@ -1,12 +0,0 @@
|
||||
/+ parse, *test
|
||||
|%
|
||||
++ test-blah
|
||||
;: weld
|
||||
%+ expect-eq
|
||||
!> %.y
|
||||
!> %.y
|
||||
::
|
||||
%+ expect-eq
|
||||
!> %.y
|
||||
!> %.y
|
||||
:: watch rsync -zr --delete ~/GitRepos/urQL/urql/* ~/urbit/zod/urql
|
Loading…
Reference in New Issue
Block a user