Skip to content

with-spy doesn't seem to work on tests with :inline definitions in metadata #65

Open
@E-A-Griffin

Description

As far as I can tell, calling with-spy (and with-stub!) seem to not work as expected on functions that have an inline definition (i.e. a function with :inline defined in the metadata).

(t/deftest a-test 
  (t/is (= 1 (count (bond/with-spy [inc]
                     (inc 1)
                     (bond/calls inc))))))
;; => #'user/a-test
user> (a-test)
​
FAIL in (a-test) (x.clj:226)
expected: (= 1 (count (bond/with-spy [inc] (inc 1) (bond/calls inc))))
  actual: (not (= 1 0))
;; => nil

(t/deftest a-test 
  (t/is (= 1 (count (bond/with-spy [identical?]
                     (identical? 1 2)
                     (bond/calls identical?))))))
;; => #'user/a-test
user> (a-test)
​
FAIL in (a-test) (x.clj:226)
expected: (= 1 (count (bond/with-spy [identical?] (identical? 1 2) (bond/calls identical?))))
  actual: (not (= 1 0))
;; => nil

;; NOTE: `=` is only inlined for its 2 argument form

(t/deftest a-test 
  (t/is (= 1 (count (bond/with-spy [=]
                     (= 1 2)
                     (bond/calls =))))))
;; => #'user/a-test
user> (a-test)
​
FAIL in (a-test) (x.clj:226)
expected: (= 1 (count (bond/with-spy [=] (= 1 2) (bond/calls =)))
  actual: (not (= 1 0))
;; => nil

;; Passes for non-inlined form
(t/deftest a-test 
  (t/is (= 1 (count (bond/with-spy [=]
                     (= 1 2 3)
                     (bond/calls =))))))
;; => #'user/a-test
user> (a-test)
;; => nil

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions