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
22 (dflet ((foo/inline () 42))
23 (is (eql 23 (foo/inline)))))
25 (def-test dflet.notinline.works ()
26 "If a function is declared INLINE, but NOTINLINE is used locally,
28 (declare (notinline foo/inline))
29 (dflet ((foo/inline () 42))
30 (is (eql 42 (foo/inline)))))
32 (defun foo/mock (&optional (string "Hello, World!"))
33 (1+ (bar/mock string)))
35 (defun bar/mock (string)
38 (def-test dflet.simple-mock ()
39 (dflet ((bar/mock (string)
41 ((equalp string "Hello, World!")
43 (is (eql 43 (foo/mock)))
44 (is (eql 43 (foo/mock "HELLO, WORLD!")))))
46 (def-test dflet.package-locks ()
47 "Either we can rebind LIST, or an error occurs and the binding is not
50 (handler-case (dflet ((list ()))
53 (is (eq #'list list))))))
58 (def-test dflet.package-locks.order.1 ()
59 "Either we can rebind LIST, or an error occurs and both binding are
62 (foo/lock #'foo/lock))
67 (is (eql 13 (foo/lock))))
70 (is (eq #'foo/lock foo/lock))))))