(s/def ::fontspecs (s/coll-of ::fontspec))

Sorry, I missed that error first time around. s/* is a regex spec but your
argument should be a collection of ::fontspec

On Wed, Oct 30, 2019 at 9:02 PM Philos Kim <philo...@gmail.com> wrote:

> Thanks for your answer!
>
> I corrected the code like the following according to your advice.
>
> (s/fdef transform-fontspecs
>   :args (s/cat :fontspecs ::fontspecs))
>
> However, the same error occurs again.
>
> 2019년 10월 31일 목요일 오전 11시 44분 46초 UTC+9, Philos Kim 님의 말:
>>
>> I don't know why the following spec error occurred.
>>
>> Could anyone tell me why?
>>
>> (ns spec-test
>>    (:require [clojure.spec.alpha :as s]
>>              [clojure.spec.test.alpha :as stest]))
>>
>> ;;; spec definitions
>>
>> (s/def :msds.fontspec/tag #{:fontspec})
>>
>> (s/def ::id string?)
>> (s/def ::size int?)
>> (s/def ::family string?)
>> (s/def ::color string?)
>>
>> (s/def :msds.fontspec/attrs
>>   (s/keys :req-un [::id ::size ::family ::color]))
>>
>> (s/def :msds.fontspec/content (s/cat))
>>
>> (s/def ::fontspec
>>   (s/keys :req-un [:msds.fontspec/tag :msds.fontspec/attrs
>> :msds.fontspec/content]))
>>
>> (s/def ::fontspecs (s/* ::fontspec))
>>
>>
>> ;;; spec application
>>
>> (defn transform-fontspecs
>>   "fontspecs를 사용하기 편리한 형태로 변환한다."
>>   [fontspecs]
>>   (->> fontspecs
>>        (map (fn [{:keys [attrs] :as fontspec}]
>>               [(get attrs :id) (dissoc attrs :id)] ))
>>        (into {}) ))
>>
>> (s/fdef transform-fontspecs
>>   :args ::fontspecs)
>>
>> (stest/instrument `transform-fontspecs)
>>
>>
>> ;;; test code
>>
>> (def test-sample
>>   '({:tag :fontspec,
>>      :attrs {:id "283f1EV", :size 21, :family "c2S6", :color ""},
>>      :content ()}
>>     {:tag :fontspec,
>>      :attrs
>>      {:id "BzYMt4eEm", :size -5, :family "q0xhOE3", :color "bhV3PsVh"},
>>      :content ()}
>>     {:tag :fontspec,
>>      :attrs {:id "uA2i", :size -5, :family "HHGoD", :color "J47ZX935"},
>>      :content ()}))
>>
>> (transform-fontspecs test-sample)
>> 2. Unhandled clojure.lang.Compiler$CompilerException
>>    Error compiling src/spec_test.clj at (55:1)
>>    #:clojure.error{:phase :compile-syntax-check,
>>                    :line 55,
>>                    :column 1,
>>                    :source "/home/philos/work/metapdf/src/spec_test.clj"}
>>              Compiler.java: 7648  clojure.lang.Compiler/load
>>                       REPL:    1  metapdf.core/eval19243
>>                       REPL:    1  metapdf.core/eval19243
>>              Compiler.java: 7177  clojure.lang.Compiler/eval
>>              Compiler.java: 7132  clojure.lang.Compiler/eval
>>                   core.clj: 3214  clojure.core/eval
>>                   core.clj: 3210  clojure.core/eval
>>                   main.clj:  437  clojure.main/repl/read-eval-print/fn
>>                   main.clj:  437  clojure.main/repl/read-eval-print
>>                   main.clj:  458  clojure.main/repl/fn
>>                   main.clj:  458  clojure.main/repl
>>                   main.clj:  368  clojure.main/repl
>>                RestFn.java: 1523  clojure.lang.RestFn/invoke
>>     interruptible_eval.clj:   79
>> nrepl.middleware.interruptible-eval/evaluate
>>     interruptible_eval.clj:   55
>> nrepl.middleware.interruptible-eval/evaluate
>>     interruptible_eval.clj:  142
>> nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
>>                   AFn.java:   22  clojure.lang.AFn/run
>>                session.clj:  171
>> nrepl.middleware.session/session-exec/main-loop/fn
>>                session.clj:  170
>> nrepl.middleware.session/session-exec/main-loop
>>                   AFn.java:   22  clojure.lang.AFn/run
>>                Thread.java:  748  java.lang.Thread/run
>>
>> 1. Caused by clojure.lang.ExceptionInfo
>>    Spec assertion failed.
>>
>>          Spec: #object[clojure.spec.alpha$regex_spec_impl$reify__2509
>> 0x3660c4ee "clojure.spec.alpha$regex_spec_impl$reify__2509@3660c4ee"]
>>         Value: (({:tag :fontspec,
>>                   :attrs {:id "283f1EV", :size 21, :family "c2S6", :color
>> ""},
>>                   :content ()}
>>                  {:tag :fontspec,
>>                   :attrs
>>                   {:id "BzYMt4eEm", :size -5, :family "q0xhOE3", :color
>> "bhV3PsVh"},
>>                   :content ()}
>>                  {:tag :fontspec,
>>                   :attrs {:id "uA2i", :size -5, :family "HHGoD", :color
>> "J47ZX935"},
>>                   :content ()}))
>>
>>      Problems:
>>
>>             val: ({:tag :fontspec,
>>                    :attrs {:id "283f1EV", :size 21, :family "c2S6",
>> :color ""},
>>                    :content ()}
>>                   {:tag :fontspec,
>>                    :attrs
>>                    {:id "BzYMt4eEm", :size -5, :family "q0xhOE3", :color
>> "bhV3PsVh"},
>>                    :content ()}
>>                   {:tag :fontspec,
>>                    :attrs {:id "uA2i", :size -5, :family "HHGoD", :color
>> "J47ZX935"},
>>                    :content ()})
>>              in: [0]
>>          failed: map?
>>            spec: :spec-test/fontspec
>>
>>                  alpha.clj:  132
>> clojure.spec.test.alpha/spec-checking-fn/conform!
>>                  alpha.clj:  140
>> clojure.spec.test.alpha/spec-checking-fn/fn
>>                RestFn.java:  408  clojure.lang.RestFn/invoke
>>              spec_test.clj:   55  spec-test/eval19293
>>              spec_test.clj:   55  spec-test/eval19293
>>              Compiler.java: 7177  clojure.lang.Compiler/eval
>>              Compiler.java: 7636  clojure.lang.Compiler/load
>>                       REPL:    1  metapdf.core/eval19243
>>                       REPL:    1  metapdf.core/eval19243
>>              Compiler.java: 7177  clojure.lang.Compiler/eval
>>              Compiler.java: 7132  clojure.lang.Compiler/eval
>>                   core.clj: 3214  clojure.core/eval
>>                   core.clj: 3210  clojure.core/eval
>>                   main.clj:  437  clojure.main/repl/read-eval-print/fn
>>                   main.clj:  437  clojure.main/repl/read-eval-print
>>                   main.clj:  458  clojure.main/repl/fn
>>                   main.clj:  458  clojure.main/repl
>>                   main.clj:  368  clojure.main/repl
>>                RestFn.java: 1523  clojure.lang.RestFn/invoke
>>     interruptible_eval.clj:   79
>> nrepl.middleware.interruptible-eval/evaluate
>>     interruptible_eval.clj:   55
>> nrepl.middleware.interruptible-eval/evaluate
>>     interruptible_eval.clj:  142
>> nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
>>                   AFn.java:   22  clojure.lang.AFn/run
>>                session.clj:  171
>> nrepl.middleware.session/session-exec/main-loop/fn
>>                session.clj:  170
>> nrepl.middleware.session/session-exec/main-loop
>>                   AFn.java:   22  clojure.lang.AFn/run
>>                Thread.java:  748  java.lang.Thread/run
>>
>> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/clojure/c7c5895c-56db-427b-8e40-e10dfe273080%40googlegroups.com
> <https://groups.google.com/d/msgid/clojure/c7c5895c-56db-427b-8e40-e10dfe273080%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles Networks, LLC. -- https://worldsinglesnetworks.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/CAD4thx-Lv9TpJMrD9hXw_0T9ObRWbE79Mc%3DB74ff671p6sJN6A%40mail.gmail.com.

Reply via email to