(def-setting “testing.reset.string” “hello world”) (def-setting “testing.reset.fn” to-string)

(examples-for settings/fn

("returns arg if it is a sym"
 (settings/fn 'foobar)
 foobar)

("returns fn wrapper for arg if it is a string"
 (settings/fn "hello")
 (k "hello"))

("returns fn wrapper for arg if it is a number"
 (settings/fn 42)
 (k 42))

("returns fn wrapper for arg if it is nil"
 (settings/fn nil)
 (k nil))

("wraps arg in a fn expression if it is a hash"
 (settings/fn '{ a 1 b 2 })
 (k { a 1 b 2 }))

("wraps arg in a fn expression if it is a complex expression"
 (settings/fn '(let foo this that (rfnwith (complex stuff) (%td.tricky#syntax))))
 (fn (_) (let foo this that (rfnwith (complex stuff) ((percent-syntax || (dot-syntax td tricky#syntax))))))))

(examples-for reset-setting

("restores a setting to its original value"
 (do (set-setting "testing.reset.string" "goodbye, dear life")
     (reset-setting "testing.reset.string")
     (setting "testing.reset.string"))
 "hello world")

("restores a setting to its original function value"
 (do (set-setting "testing.reset.fn" "goodbye, dear life")
     (reset-setting "testing.reset.fn")
     (setting "testing.reset.fn"))
 "testing.reset.fn"))