1 ;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-mock-tests; -*-
3 (in-package #:cl-mock-tests)
7 (def-test progf.calls-binding ()
8 (progf '(foo) (list (lambda () 23))
11 (def-test dflet.calls-binding ()
15 (declaim (inline foo/inline))
19 (def-test dflet.inline.works ()
20 "If a function is declared INLINE (and that request is honored), DFLET
21 won't work. Not a failure, since we can't force INLINE."
22 (dflet ((foo/inline () 42))
23 (if (eql 23 (foo/inline))
24 (pass "INLINE declaration honored, so DFLET fails")
25 (skip "INLINE declaration not honored, so DFLET works"))))
27 (def-test dflet.notinline.works ()
28 "If a function is declared INLINE, but NOTINLINE is used locally,
30 (declare (notinline foo/inline))
31 (dflet ((foo/inline () 42))
32 (is (eql 42 (foo/inline)))))
34 (defun foo/mock (&optional (string "Hello, World!"))
35 (1+ (bar/mock string)))
37 (defun bar/mock (string)
40 (def-test dflet.simple-mock ()
41 (dflet ((bar/mock (string)
43 ((equalp string "Hello, World!")
45 (is (eql 43 (foo/mock)))
46 (is (eql 43 (foo/mock "HELLO, WORLD!")))))
48 (def-test dflet.package-locks ()
49 "Either we can rebind LIST, or an error occurs and the binding is not
52 (handler-case (dflet ((list ()))
55 (is (eq #'list list))))))
60 (def-test dflet.package-locks.order.1 ()
61 "Either we can rebind LIST, or an error occurs and both binding are
64 (foo/lock #'foo/lock))
69 (is (eql 13 (foo/lock))))
72 (is (eq #'foo/lock foo/lock))))))