(.using [library [lux {"-" char symbol} ["_" test {"+" Test}] [abstract [monad {"+" Monad do}] [\\specification ["$[0]" equivalence] ["$[0]" codec]]] [control ["[0]" maybe] ["[0]" try] ["p" parser ["" xml]]] [data ["[0]" text ("[1]#[0]" equivalence) ["%" format {"+" format}]] [collection ["[0]" dictionary] ["[0]" list ("[1]#[0]" functor)]]] [macro ["^" pattern]] [math ["[0]" random {"+" Random} ("[1]#[0]" monad)] [number ["n" nat]]] [meta ["[0]" symbol]]]] [\\library ["[0]" / {"+" XML}]]) (def: char_range Text (format "_" "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) (def: char (Random Nat) (do [! random.monad] [idx (|> random.nat (# ! each (n.% (text.size char_range))))] (in (maybe.trusted (text.char idx char_range))))) (def: (size bottom top) (-> Nat Nat (Random Nat)) (let [constraint (|>> (n.% top) (n.max bottom))] (random#each constraint random.nat))) (def: (text bottom top) (-> Nat Nat (Random Text)) (do random.monad [size (..size bottom top)] (random.text ..char size))) (def: symbol (Random Symbol) (random.and (..text 0 10) (..text 1 10))) (def: .public random (Random XML) (random.rec (function (_ random) (random.or (..text 1 10) (do random.monad [size (..size 0 2)] (all random.and ..symbol (random.dictionary symbol.hash size ..symbol (..text 0 10)) (random.list size random))))))) (def: .public test Test (<| (_.covering /._) (_.for [/.XML]) (all _.and (_.for [/.equivalence] ($equivalence.spec /.equivalence ..random)) (_.for [/.codec] ($codec.spec /.equivalence /.codec ..random)) (do [! random.monad] [(^.let symbol [namespace name]) ..symbol] (`` (all _.and (~~ (template [ ] [(_.coverage [ ] (and (text#= name ( ["" name])) (let [symbol ( symbol)] (and (text.starts_with? namespace symbol) (text.ends_with? name symbol)))))] [/.Tag /.tag] [/.Attribute /.attribute] )) (_.coverage [/.Attrs /.attributes] (dictionary.empty? /.attributes)) ))) )))