projects
/
cl-mock.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
82370fd
)
Formatting.
author
Olof-Joachim Frahm
<olof@macrolet.net>
Wed, 17 Dec 2014 20:42:30 +0000
(20:42 +0000)
committer
Olof-Joachim Frahm
<olof@macrolet.net>
Wed, 17 Dec 2014 20:44:38 +0000
(20:44 +0000)
cl-mock-tests.asd
patch
|
blob
|
history
cl-mock.asd
patch
|
blob
|
history
src/facade.lisp
patch
|
blob
|
history
src/functions.lisp
patch
|
blob
|
history
src/methods.lisp
patch
|
blob
|
history
src/mock.lisp
patch
|
blob
|
history
src/package.lisp
patch
|
blob
|
history
tests/facade.lisp
patch
|
blob
|
history
tests/functions.lisp
patch
|
blob
|
history
tests/methods.lisp
patch
|
blob
|
history
tests/package.lisp
patch
|
blob
|
history
diff --git
a/cl-mock-tests.asd
b/cl-mock-tests.asd
index
dcb0eb4
..
5c82c9a
100644
(file)
--- a/
cl-mock-tests.asd
+++ b/
cl-mock-tests.asd
@@
-1,4
+1,4
@@
-;;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-user; -*-
+;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-user; -*-
(in-package #:cl-user)
\f
(in-package #:cl-user)
\f
@@
-16,4
+16,4
@@
(:file "suite")
(:file "functions")
(:file "facade")
(:file "suite")
(:file "functions")
(:file "facade")
- (:file "methods")))))
\ No newline at end of file
+ (:file "methods")))))
diff --git
a/cl-mock.asd
b/cl-mock.asd
index
9111724
..
fac28ae
100644
(file)
--- a/
cl-mock.asd
+++ b/
cl-mock.asd
@@
-1,4
+1,4
@@
-;;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-user; -*-
+;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-user; -*-
(in-package #:cl-user)
\f
(in-package #:cl-user)
\f
diff --git
a/src/facade.lisp
b/src/facade.lisp
index
8e73de9
..
e14c4ea
100644
(file)
--- a/
src/facade.lisp
+++ b/
src/facade.lisp
@@
-1,4
+1,4
@@
-;;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-mock; -*-
+;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-mock; -*-
(in-package #:cl-mock)
\f
(in-package #:cl-mock)
\f
diff --git
a/src/functions.lisp
b/src/functions.lisp
index
cd8c772
..
803a3f2
100644
(file)
--- a/
src/functions.lisp
+++ b/
src/functions.lisp
@@
-1,4
+1,4
@@
-;;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-mock; -*-
+;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-mock; -*-
(in-package #:cl-mock)
\f
(in-package #:cl-mock)
\f
diff --git
a/src/methods.lisp
b/src/methods.lisp
index
351938f
..
4688d2b
100644
(file)
--- a/
src/methods.lisp
+++ b/
src/methods.lisp
@@
-1,4
+1,4
@@
-;;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-mock; -*-
+;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-mock; -*-
(in-package #:cl-mock)
\f
(in-package #:cl-mock)
\f
diff --git
a/src/mock.lisp
b/src/mock.lisp
index
ae9522d
..
e10bb32
100644
(file)
--- a/
src/mock.lisp
+++ b/
src/mock.lisp
@@
-1,4
+1,4
@@
-;;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-mock; -*-
+;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-mock; -*-
(in-package #:cl-mock)
\f
(in-package #:cl-mock)
\f
@@
-25,8
+25,8
@@
and executes it. If no mock was found, no values are returned instead."
(defun call-with-mocks (mock-bindings function &key (recordp T))
"Calls FUNCTION with the given MOCK-BINDINGS established and returns
(defun call-with-mocks (mock-bindings function &key (recordp T))
"Calls FUNCTION with the given MOCK-BINDINGS established and returns
-its first return value, if any. If RECORDP is set, all invocations will
-be recorded and returned as the second return value, else NIL."
+its return values as a LIST. If RECORDP is set, all invocations will be
+recorded and returned as the second return value, else NIL."
(let* ((mocks (mock-bindings-mocks mock-bindings))
(functions (mapcar #'car mocks))
(previous (mapcar #'maybe-fdefinition functions)))
(let* ((mocks (mock-bindings-mocks mock-bindings))
(functions (mapcar #'car mocks))
(previous (mapcar #'maybe-fdefinition functions)))
@@
-41,10
+41,19
@@
be recorded and returned as the second return value, else NIL."
mocks previous)
(lambda ()
(values
mocks previous)
(lambda ()
(values
- (funcall function)
+ (multiple-value-list
+ (funcall function))
(invocations)))
previous))))
(invocations)))
previous))))
+(defmacro with-mocks ((mock-bindings &key (recordp T)) form &body body)
+ `(multiple-value-bind (,values ,calls)
+ (call-with-mocks
+ ,mock-bindings
+ (lambda () ,form)
+ :recordp ,recordp)
+ ,@body))
+
(defun register-mock (mock-bindings name)
"Registers a mocked function under NAME. The mocked function will
return no values. See IF-CALLED to add some behaviour to it."
(defun register-mock (mock-bindings name)
"Registers a mocked function under NAME. The mocked function will
return no values. See IF-CALLED to add some behaviour to it."
diff --git
a/src/package.lisp
b/src/package.lisp
index
498b4e1
..
a499a26
100644
(file)
--- a/
src/package.lisp
+++ b/
src/package.lisp
@@
-1,14
+1,14
@@
-;;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-user; -*-
+;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-user; -*-
(in-package #:cl-user)
\f
(defpackage #:cl-mock
(:use #:closer-common-lisp #:alexandria)
(:import-from #:arnesi #:with-collector)
(in-package #:cl-user)
\f
(defpackage #:cl-mock
(:use #:closer-common-lisp #:alexandria)
(:import-from #:arnesi #:with-collector)
- (:export ;;; regular functions
+ (:export ;; regular functions
#:progf
#:dflet
#:progf
#:dflet
- ;;; mocking of regular functions
- ;;; mocking of generic functions
+ ;; mocking of regular functions
+ ;; mocking of generic functions
))
))
diff --git
a/tests/facade.lisp
b/tests/facade.lisp
index
5db3530
..
fea5625
100644
(file)
--- a/
tests/facade.lisp
+++ b/
tests/facade.lisp
@@
-1,4
+1,4
@@
-;;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-mock-tests; -*-
+;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-mock-tests; -*-
(in-package #:cl-mock-tests)
\f
(in-package #:cl-mock-tests)
\f
diff --git
a/tests/functions.lisp
b/tests/functions.lisp
index
3e5f23b
..
21761f2
100644
(file)
--- a/
tests/functions.lisp
+++ b/
tests/functions.lisp
@@
-1,4
+1,4
@@
-;;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-mock-tests; -*-
+;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-mock-tests; -*-
(in-package #:cl-mock-tests)
\f
(in-package #:cl-mock-tests)
\f
diff --git
a/tests/methods.lisp
b/tests/methods.lisp
index
89c0860
..
681712c
100644
(file)
--- a/
tests/methods.lisp
+++ b/
tests/methods.lisp
@@
-1,4
+1,4
@@
-;;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-mock-tests; -*-
+;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-mock-tests; -*-
(in-package #:cl-mock-tests)
\f
(in-package #:cl-mock-tests)
\f
diff --git
a/tests/package.lisp
b/tests/package.lisp
index
5c47243
..
1198756
100644
(file)
--- a/
tests/package.lisp
+++ b/
tests/package.lisp
@@
-1,15
+1,14
@@
-;;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-user; -*-
+;; -*- mode: lisp; syntax: common-lisp; coding: utf-8-unix; package: cl-user; -*-
(in-package #:cl-user)
\f
(defpackage #:cl-mock-tests
(:use #:cl #:cl-mock #:fiveam)
(in-package #:cl-user)
\f
(defpackage #:cl-mock-tests
(:use #:cl #:cl-mock #:fiveam)
- (:import-from
- #:cl-mock
- #:call-with-mocks
- #:progm
- #:make-mock-bindings
- #:if-called
- #:when-called
- #:call-previous
- #:register-mock))
+ (:import-from #:cl-mock
+ #:call-with-mocks
+ #:progm
+ #:make-mock-bindings
+ #:if-called
+ #:when-called
+ #:call-previous
+ #:register-mock))