~pepe/manisha

ddb3d7a2ce6765c8497f837c713fc3225f1ebacc — Josef Pospíšil 2 months ago 2d044a9
Change analyst result
2 files changed, 10 insertions(+), 11 deletions(-)

M manisha/init.janet
M test/suite01.janet
M manisha/init.janet => manisha/init.janet +3 -3
@@ 110,9 110,9 @@
                   (loop [pred :pairs directive]
                     (match pred
                       [(afun (function? fun)) (fun (function? afun))]
                       (if-not (all fun (afun data)) (put res data [(afun data) fun]))
                       (if-not (all fun (afun data)) (put res afun fun))
                       [key (fun (function? fun))]
                       (if-not (fun (get data key)) (put res (get data key) [key fun]))
                       (if-not (fun (get data key)) (put res key fun))
                       [head (tup (tuple? tup))]
                       (let [v (if (function? head)
                                 (head data)


@@ 120,7 120,7 @@
                             fun (tup 0)
                             preds (tuple/slice tup 1 -1)]
                         (if-not (all (fn [i] (fun |($ i) preds)) v)
                           (put res (v 0) [head tup])))))
                           (put res head tup)))))
                   (freeze res))))
             [true r] r
             [false e] [directive [:error e]]))))))

M test/suite01.janet => test/suite01.janet +7 -8
@@ 135,31 135,30 @@

(assert (appraise ((analyst table? {:name string?}) @{:name 1})
                  tuple? {0 empty?
                          1 (??? struct? {1 (??? tuple? {0 |(= $ :name)
                                                         1 function?})})})
                          1 (??? struct? {:name function?})})
        "Anaylyst of invalid is array with blocker appraised")

(assert (appraise
          ((analyst table? {:name string? :age [all number? pos?]})
            @{:name "pepe" :age -1})
          tuple? {0 empty?
                  1 (??? struct? {-1 (??? tuple? {0 (eq :age) 1 tuple?})})})
                  1 (??? struct? {:age tuple?})})
        "Anaylyst of invalid data is array with tuple blocker")

(assert (appraise
          ((analyst table? {:name present-string? :age [all number? pos?]})
            @{:name "" :age -1})
                    @{:name "" :age -1})
          tuple? {0 empty?
                  1 (??? struct? {"" (??? tuple? {0 (eq :name) 1 (eq present-string?)})
                                  -1 (??? tuple? {0 (eq :age) 1 tuple?})})})
                  1 (??? struct? {:name function?
                                  :age tuple?})})
        "Anaylyst of invalid data is array with more tuple blockers")

(assert (appraise
          ((!!! table? {:name present-string? :age [all number? pos?]})
            @{:name "" :age -1})
          tuple? {0 empty?
                  1 (??? struct? {"" (??? tuple? {0 (eq :name) 1 (eq present-string?)})
                                  -1 (??? tuple? {0 (eq :age) 1 tuple?})})})
                  1 (??? struct? {:name function?
                                  :age tuple?})})
        "Alias anaylyst of invalid data is array with more tuple blockers")

(assert (= ((analyst [all buffer? present?]) @"HOHO") '())