1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
(local t (require :test.faith))
(local expected {
:comment "function"
:comment? "function"
:compile "function"
:compile-stream "function"
:compile-string "function"
:doc "function"
:dofile "function"
:eval "function"
:getinfo "function"
:install "function"
:list "function"
:list? "function"
:load-code "function"
:macro-loaded "table"
:macro-path "string"
:macro-searchers "table"
:make-searcher "function"
:metadata "table"
:multi-sym? "function"
:parser "function"
:path "string"
:repl "callable"
:runtime-version "function"
:search-module "function"
:searcher "function"
:sequence "function"
:sequence? "function"
:sym "function"
:sym-char? "function"
:sym? "function"
:syntax "function"
:table? "function"
:traceback "function"
:varg "function"
:varg? "function"
:version "string"
:view "function"
:ast-source "function"})
(local expected-aliases {
:compileStream "function"
:compileString "function"
:loadCode "function"
:macroLoaded "table"
:macroPath "string"
:macroSearchers "table"
:makeSearcher "function"
:runtimeVersion "function"
:searchModule "function"})
(local expected-deprecations {
:compile1 "function"
:gensym "function"
:granulate "function"
:make_searcher "function"
:mangle "function"
:scope "function"
:string-stream "function"
:stringStream "function"
:unmangle "function"})
(fn supertype [expect v]
(let [vt (type v)]
(if (and (= expect :callable)
(or (= vt :function) (and (= vt :table)
(?. (getmetatable v) :__call))))
:callable
vt)))
(fn test-api-exposure []
(let [fennel (require :fennel) current {}]
(each [key value (pairs fennel)]
(tset current key (type value)))
(each [key kind (pairs expected)]
(t.is (. fennel key) (.. "expect fennel." key " to exists"))
(t.= (supertype kind (. fennel key)) kind
(.. "expect fennel." key " to be \"" kind "\"")))
(each [key kind (pairs expected-aliases)]
(t.is (. fennel key) (.. "expect alias fennel." key " to exists"))
(t.= (supertype kind (. fennel key)) kind
(.. "expect alias fennel." key " to be \"" kind "\"")))
(each [key kind (pairs expected-deprecations)]
(t.is (. fennel key) (.. "expect deprecated fennel." key " to exists"))
(t.= (supertype kind (. fennel key)) kind
(.. "expect deprecated fennel." key " to be \"" kind "\"")))
(each [key value (pairs fennel)]
(t.is (or (. expected key)
(. expected-aliases key)
(. expected-deprecations key))
(.. "fennel." key " not expected to be in the public api")))))
{: test-api-exposure}
|