88 lines
2.2 KiB
Plaintext
88 lines
2.2 KiB
Plaintext
(defAlias &ident Stream kiss.Stream)
|
|
(defAlias &type Stream kiss.Stream)
|
|
|
|
(defMacro makeExample [expression &body b]
|
|
`(let [normal ,(printExp expression)
|
|
expanded ,(printExp (macroExpand expression))]
|
|
,@b))
|
|
|
|
(defMacro makeExampleNoValues [expression &opt body1 body2]
|
|
`{
|
|
{
|
|
,(printExp expression)
|
|
,(or body1 `{})
|
|
}
|
|
{
|
|
,(printExp (macroExpand expression))
|
|
,(or body2 `{})
|
|
}
|
|
})
|
|
|
|
(function _testAllForms []
|
|
// object
|
|
(makeExample
|
|
(object
|
|
Stream (Stream.fromString ""))
|
|
normal.Stream
|
|
expanded.Stream)
|
|
|
|
// lambda
|
|
(makeExample
|
|
(lambda [Stream] (Stream.fromString ""))
|
|
(normal null)
|
|
(expanded null))
|
|
|
|
(makeExample
|
|
(lambda [:Stream s] (Stream.fromString ""))
|
|
(normal null)
|
|
(expanded null))
|
|
|
|
// localVar
|
|
(makeExampleNoValues
|
|
(localVar Stream (Stream.fromString "")))
|
|
|
|
(makeExampleNoValues
|
|
(localVar :Stream s (Stream.fromString "")))
|
|
|
|
// let
|
|
(makeExampleNoValues
|
|
(let [:Stream s (Stream.fromString "")
|
|
Stream (Stream.fromString "")]
|
|
null))
|
|
|
|
// localFunction
|
|
(makeExampleNoValues
|
|
(localFunction Stream [] (Stream.fromString "")))
|
|
|
|
(makeExampleNoValues
|
|
(localFunction :Stream s [] (Stream.fromString "")))
|
|
|
|
// for/doFor
|
|
|
|
(localVar listOfLists [["a b c"]["d e f"]])
|
|
(defAlias &ident lol listOfLists)
|
|
(defAlias &type Texty String)
|
|
|
|
(makeExampleNoValues
|
|
(for [:Texty t1 :Texty t2 :Texty t3] lol
|
|
null))
|
|
|
|
(makeExampleNoValues
|
|
(doFor [:Texty t1 :Texty t2 :Texty t3] lol
|
|
null))
|
|
|
|
// the
|
|
(makeExample
|
|
.content (the Stream (Stream.fromString "hey"))
|
|
(Assert.equals normal "hey\n")
|
|
(Assert.equals expanded "hey\n"))
|
|
(makeExample
|
|
.content (cast (Stream.fromString "hey") Stream)
|
|
(Assert.equals normal "hey\n")
|
|
(Assert.equals expanded "hey\n"))
|
|
|
|
(makeExampleNoValues
|
|
(try (throw (Stream.fromString "error"))
|
|
(catch [:Stream s]
|
|
(print "as expected"))))
|
|
) |