Created
December 30, 2016 11:18
-
-
Save schmee/021a59317edc2c99f491e9c72479c530 to your computer and use it in GitHub Desktop.
clojure.spec bug?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns spec-test.core | |
(:require [clojure.spec :as s])) | |
(defprotocol Game | |
(move [game])) | |
(s/def ::game1 #(satisfies? Game %)) | |
(s/def ::game2 (partial satisfies? Game)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns spec-test.foo | |
(:require [spec-test.core :refer [Game]])) | |
(defrecord Foo []) | |
(extend-type Foo | |
Game | |
(move [game])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ spec-test lein repl | |
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: cider.inlined-deps.fipp.v0v6v4.fipp.visit, being replaced by: #'cider.inlined-deps.fipp.v0v6v4.fipp.visit/boolean? | |
nREPL server started on port 58606 on host 127.0.0.1 - nrepl://127.0.0.1:58606 | |
REPL-y 0.3.7, nREPL 0.2.12 | |
Clojure 1.9.0-alpha14 | |
Java HotSpot(TM) 64-Bit Server VM 1.8.0_92-b14 | |
Docs: (doc function-name-here) | |
(find-doc "part-of-name-here") | |
Source: (source function-name-here) | |
Javadoc: (javadoc java-object-or-class-here) | |
Exit: Control+D or (exit) or (quit) | |
Results: Stored in vars *1, *2, *3, an exception in *e | |
user=> (ns spec-test.core) | |
nil | |
spec-test.core=> (require 'spec-test.core :reload) | |
nil | |
spec-test.core=> (require 'spec-test.foo :reload) | |
nil | |
spec-test.core=> (satisfies? Game (spec-test.foo/->Foo)) | |
true | |
spec-test.core=> ((partial satisfies? Game) (spec-test.foo/->Foo)) | |
true | |
spec-test.core=> (s/explain ::game1 (spec-test.foo/->Foo)) | |
Success! | |
nil | |
spec-test.core=> (s/explain ::game2 (spec-test.foo/->Foo)) | |
val: #spec_test.foo.Foo{} fails spec: :spec-test.core/game2 predicate: (partial satisfies? Game) <---- WAAAAAT | |
nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment