[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] scratch/el-mock 13eb3a9288 17/64: Merge branch 'testing'
From: |
Stefan Monnier |
Subject: |
[nongnu] scratch/el-mock 13eb3a9288 17/64: Merge branch 'testing' |
Date: |
Mon, 28 Aug 2023 23:01:39 -0400 (EDT) |
branch: scratch/el-mock
commit 13eb3a9288fe4a8986481bfca5b34eda3b9dcfbc
Merge: 70ef9873cd 86444bfdfc
Author: Johan Andersson <johan.rejeep@gmail.com>
Commit: Johan Andersson <johan.rejeep@gmail.com>
Merge branch 'testing'
---
.travis.yml | 11 ++
Cask | 6 +
Makefile | 6 +
README.md | 10 ++
el-mock.el | 366 ---------------------------------------------------
test/el-mock-test.el | 360 ++++++++++++++++++++++++++++++++++++++++++++++++++
test/test-helper.el | 4 +
7 files changed, 397 insertions(+), 366 deletions(-)
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000000..3fa912c46b
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,11 @@
+language: emacs-lisp
+before_install:
+ - curl -fsSkL https://gist.github.com/rejeep/7736123/raw > travis.sh &&
source ./travis.sh
+ - evm install $EVM_EMACS --use --skip
+ - cask
+env:
+ - EVM_EMACS=emacs-24.4-bin
+ - EVM_EMACS=emacs-24.5-bin
+script:
+ - emacs --version
+ - make test
diff --git a/Cask b/Cask
index 0a9c118fc9..e8dece3e4a 100644
--- a/Cask
+++ b/Cask
@@ -1,3 +1,9 @@
+(source gnu)
(source melpa)
(package-file "el-mock.el")
+
+(development
+ (depends-on "f")
+ (depends-on "ert-runner")
+ (depends-on "ert-expectations"))
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000000..878f1d1487
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,6 @@
+CASK ?= cask
+
+test:
+ $(CASK) exec ert-runner
+
+.PHONY: test
diff --git a/README.md b/README.md
index 3ea0bc139a..ac7745b1d4 100644
--- a/README.md
+++ b/README.md
@@ -6,3 +6,13 @@ _NOTE: El mock has moved from
[@rejeep](https://github.com/rejeep)._
El mock is a mocking library for Emacs.
+
+## Contribution
+
+Be sure to!
+
+Install [Cask](https://github.com/cask/cask) if you haven't already.
+
+Run the unit tests with:
+
+ $ make test
diff --git a/el-mock.el b/el-mock.el
index a78b98c9e9..78fd34ecd8 100644
--- a/el-mock.el
+++ b/el-mock.el
@@ -322,372 +322,6 @@ Example:
(put 'mocklet 'lisp-indent-function 1)
(put 'stublet 'lisp-indent-function 1)
-;;;; unit test
-(dont-compile
- (when (fboundp 'expectations)
- (expectations
- (desc "stub setup/teardown")
- (expect 2
- (stub/setup 'foo 2)
- (prog1
- (foo 1 2 3)
- (stub/teardown 'foo)))
- (expect nil
- (stub/setup 'foox 2)
- (foox 1 2 3)
- (stub/teardown 'foox)
- (fboundp 'foox))
- (desc "with-mock interface")
- (expect 9801
- (with-mock
- 9801))
- (desc "stub macro")
- (expect nil
- (with-mock
- (stub hogehoges)
- (hogehoges 75)))
- (expect 2
- (with-mock
- (stub fooz => 2)
- (fooz 9999)))
- (expect nil
- (with-mock
- (stub fooz => 2)
- (fooz 3))
- (fboundp 'fooz))
- (expect nil
- (with-mock
- (stub hoge) ;omission of return value
- (hoge)))
- (expect 'hoge
- (with-mock
- (stub me => 'hoge)
- (me 1)))
- (expect 34
- (with-mock
- (stub me => (+ 3 31))
- (me 1)))
- ;; TODO defie mock-syntax-error / detect mock-syntax-error in
expectations
- (desc "abused stub macro")
- (expect (error mock-syntax-error '("Use `(stub FUNC)' or `(stub FUNC =>
RETURN-VALUE)'"))
- (with-mock
- (stub fooz 7)))
- (expect (error-message "Do not use `stub' outside")
- (let (in-mocking) ; while executing `expect', `in-mocking' is t.
- (stub hahahaha)))
- (desc "mock macro")
- (expect 2
- (with-mock
- (mock (foom 5) => 2)
- (foom 5)))
- (expect 3
- (with-mock
- (mock (foo 5) => 2)
- (mock (bar 7) => 1)
- (+ (foo 5) (bar 7))))
- (expect 3
- (flet ((plus () (+ (foo 5) (bar 7))))
- (with-mock
- (mock (foo 5) => 2)
- (mock (bar 7) => 1)
- (plus))))
- (expect 1
- (with-mock
- (mock (f * 2) => 1)
- (f 1 2)))
- (expect 1
- (with-mock
- (mock (f * (1+ 1)) => (+ 0 1)) ;evaluated
- (f 1 2)))
- (expect nil
- (with-mock
- (mock (f 2)) ;omission of return value
- (f 2)))
- (expect 'hoge
- (with-mock
- (mock (me 1) => 'hoge)
- (me 1)))
- (expect 34
- (with-mock
- (mock (me 1) => (+ 3 31))
- (me 1)))
-
- (desc "unfulfilled mock")
- (expect (error mock-error '((foom 5) (foom 6)))
- (with-mock
- (mock (foom 5) => 2)
- (foom 6)))
- (expect (error mock-error '((bar 7) (bar 8)))
- (with-mock
- (mock (foo 5) => 2)
- (mock (bar 7) => 1)
- (+ (foo 5) (bar 8))))
- (expect (error mock-error '(not-called foo))
- (with-mock
- (mock (foo 5) => 2)))
- (expect (error mock-error '(not-called foo))
- (with-mock
- (mock (vi 5) => 2)
- (mock (foo 5) => 2)
- (vi 5)))
- (expect (error mock-error '((f 2) (f 4)))
- (with-mock
- (mock (f 2)) ;omission of return value
- (f 4)))
- (expect (error-message "error-in-test1")
- (defun test1 () (error "error-in-test1"))
- (with-mock
- (mock (test2))
- (test1)))
- (desc "abused mock macro")
- (expect (error mock-syntax-error '("Use `(mock FUNC-SPEC)' or `(mock
FUNC-SPEC => RETURN-VALUE)'"))
- (with-mock
- (mock (fooz) 7)))
- (expect (error-message "Do not use `mock' outside")
- (let (in-mocking) ; while executing `expect', `in-mocking' is t.
- (mock (hahahaha))))
-
- (desc "mock with stub")
- (expect 8
- (with-mock
- (mock (f 1 2) => 3)
- (stub hoge => 5)
- (+ (f 1 2) (hoge 'a))))
- (expect (error mock-error '((f 1 2) (f 3 4)))
- (with-mock
- (mock (f 1 2) => 3)
- (stub hoge => 5)
- (+ (f 3 4) (hoge 'a))))
-
- (desc "with-stub is an alias of with-mock")
- (expect 'with-mock
- (symbol-function 'with-stub))
-
- (desc "stublet is an alias of mocklet")
- (expect 'mocklet
- (symbol-function 'stublet))
-
- (desc "mock-parse-spec")
- (expect '(progn
- (mock (f 1 2) => 3)
- (stub hoge => 5))
- (mock-parse-spec
- '(((f 1 2) => 3)
- (hoge => 5))))
- (expect '(progn
- (not-called g))
- (mock-parse-spec
- '((g not-called))))
-
- (desc "mocklet")
- (expect 8
- (mocklet (((f 1 2) => 3)
- (hoge => 5))
- (+ (f 1 2) (hoge 'a))))
- (expect 2
- (mocklet ((foo => 2))
- (foo 1 2 3)))
- (expect 3
- (defun defined-func (x) 3)
- (prog1
- (mocklet ((defined-func => 3))
- (defined-func 3))
- (fmakunbound 'defined-func)))
- (expect nil
- (mocklet ((f)) ;omission of return value
- (f 91)))
- (expect nil
- (mocklet (((f 76))) ;omission of return value
- (f 76)))
- (expect 5
- (mocklet ((a => 3)
- (b => 2))
- 1 ;multiple exprs
- (+ (a 999) (b 7))))
-
- (desc "stub for defined function")
- (expect "xxx"
- (defun blah (x) (* x 2))
- (prog1
- (let ((orig (symbol-function 'blah)))
- (mocklet ((blah => "xxx"))
- (blah "xx")))
- (fmakunbound 'blah)))
- (expect t
- (defun blah (x) (* x 2))
- (prog1
- (let ((orig (symbol-function 'blah)))
- (mocklet ((blah => "xx"))
- (blah "xx"))
- (equal orig (symbol-function 'blah)))
- (fmakunbound 'blah)))
-
- (desc "stub for adviced function")
- (expect "xxx"
- (mock-suppress-redefinition-message ;silence redefinition warning
- (lambda ()
- (defun fugaga (x) (* x 2))
- (defadvice fugaga (around test activate)
- (setq ad-return-value (concat "[" ad-return-value "]")))
- (prog1
- (let ((orig (symbol-function 'fugaga)))
- (mocklet ((fugaga => "xxx"))
- (fugaga "aaaaa")))
- (fmakunbound 'fugaga)))))
- (expect t
- (mock-suppress-redefinition-message
- (lambda ()
- (defun fugaga (x) (* x 2))
- (defadvice fugaga (around test activate)
- (setq ad-return-value (concat "[" ad-return-value "]")))
- (prog1
- (let ((orig (symbol-function 'fugaga)))
- (mocklet ((fugaga => "xx"))
- (fugaga "aaaaa"))
- (equal orig (symbol-function 'fugaga)))
- (fmakunbound 'fugaga)))))
-
- (desc "mock for adviced function")
- (expect "xx"
- (mock-suppress-redefinition-message
- (lambda ()
- (defun fugaga (x) (* x 2))
- (defadvice fugaga (around test activate)
- (setq ad-return-value (concat "[" ad-return-value "]")))
- (prog1
- (let ((orig (symbol-function 'fugaga)))
- (mocklet (((fugaga "aaaaa") => "xx"))
- (fugaga "aaaaa")))
- (fmakunbound 'fugaga)))))
- (expect t
- (mock-suppress-redefinition-message
- (lambda ()
- (defun fugaga (x) (* x 2))
- (defadvice fugaga (around test activate)
- (setq ad-return-value (concat "[" ad-return-value "]")))
- (prog1
- (let ((orig (symbol-function 'fugaga)))
- (mocklet (((fugaga "aaaaa") => "xx"))
- (fugaga "aaaaa"))
- (equal orig (symbol-function 'fugaga)))
- (fmakunbound 'fugaga)))))
- (desc "not-called macro")
- (expect 'ok
- (with-mock
- (not-called foom)
- 'ok))
- (desc "mocklet/notcalled")
- (expect 'ok
- (mocklet ((foom not-called))
- 'ok))
- (desc "unfulfilled not-called")
- (expect (error mock-error '(called))
- (with-mock
- (not-called hoge)
- (hoge 1)))
- (desc "abused not-called macro")
- (expect (error-message "Do not use `not-called' outside")
- (let (in-mocking) ; while executing `expect', `in-mocking' is t.
- (not-called hahahaha)))
- (desc "not-called for adviced function")
- (expect "not-called"
- (mock-suppress-redefinition-message ;silence redefinition warning
- (lambda ()
- (defun fugaga (x) (* x 2))
- (defadvice fugaga (around test activate)
- (setq ad-return-value (concat "[" ad-return-value "]")))
- (prog1
- (let ((orig (symbol-function 'fugaga)))
- (mocklet ((fugaga not-called))
- "not-called"))
- (fmakunbound 'fugaga)))))
- (expect t
- (mock-suppress-redefinition-message
- (lambda ()
- (defun fugaga (x) (* x 2))
- (defadvice fugaga (around test activate)
- (setq ad-return-value (concat "[" ad-return-value "]")))
- (prog1
- (let ((orig (symbol-function 'fugaga)))
- (mocklet ((fugaga not-called))
- "not-called")
- (equal orig (symbol-function 'fugaga)))
- (fmakunbound 'fugaga)))))
- (desc ":times mock")
- (expect 'ok
- (with-mock
- (mock (foo 1) => 2 :times 2)
- (foo 1)
- (foo 1)
- 'ok))
- (expect 'ok
- (with-mock
- (mock (foo *) => 2 :times 2)
- (foo 1)
- (foo 2)
- 'ok))
- (expect 'ok
- (with-mock
- (mock (foo 1) :times 2)
- (foo 1)
- (foo 1)
- 'ok))
- (expect 'ok
- (with-mock
- (mock (foo *) :times 2)
- (foo 1)
- (foo 2)
- 'ok))
- ;; FIXME
- ;; (expect 'ok
- ;; (with-mock
- ;; (mock (foo 1) => 2 :times 2)
- ;; (foo 1)
- ;; (foo 1)
- ;; (foo 2)
- ;; 'ok))
- (expect (error mock-error '((foo 1) :expected-times 2 :actual-times 1))
- (with-mock
- (mock (foo 1) :times 2)
- (foo 1)
- 'ok))
- (expect (error mock-error '((foo *) :expected-times 2 :actual-times 1))
- (with-mock
- (mock (foo *) :times 2)
- (foo 1)
- 'ok))
- (expect (error mock-error '((foo 1) (foo 2)))
- (with-mock
- (mock (foo 1) :times 2)
- (foo 2)
- 'ok))
- (expect (error mock-error '(not-called foo))
- (with-mock
- (mock (foo 1) :times 2)
- 'ok))
- (expect (error mock-error '((foo 1) :expected-times 2 :actual-times 1))
- (with-mock
- (mock (foo 1) => 2 :times 2)
- (foo 1)
- 'ok))
- (expect (error mock-error '((foo *) :expected-times 2 :actual-times 1))
- (with-mock
- (mock (foo *) => 2 :times 2)
- (foo 1)
- 'ok))
- (expect (error mock-error '((foo 1) (foo 2)))
- (with-mock
- (mock (foo 1) => 2 :times 2)
- (foo 2)
- 'ok))
- (expect (error mock-error '(not-called foo))
- (with-mock
- (mock (foo 1) => 2 :times 2)
- 'ok))
- )))
-
(provide 'el-mock)
-;; How to save (DO NOT REMOVE!!)
-;; (emacswiki-post "el-mock.el")
;;; el-mock.el ends here
diff --git a/test/el-mock-test.el b/test/el-mock-test.el
new file mode 100644
index 0000000000..cb58e24c4f
--- /dev/null
+++ b/test/el-mock-test.el
@@ -0,0 +1,360 @@
+(expectations
+ (desc "stub setup/teardown")
+ (expect 2
+ (stub/setup 'foo 2)
+ (prog1
+ (foo 1 2 3)
+ (stub/teardown 'foo)))
+ (expect nil
+ (stub/setup 'foox 2)
+ (foox 1 2 3)
+ (stub/teardown 'foox)
+ (fboundp 'foox))
+ (desc "with-mock interface")
+ (expect 9801
+ (with-mock
+ 9801))
+ (desc "stub macro")
+ (expect nil
+ (with-mock
+ (stub hogehoges)
+ (hogehoges 75)))
+ (expect 2
+ (with-mock
+ (stub fooz => 2)
+ (fooz 9999)))
+ (expect nil
+ (with-mock
+ (stub fooz => 2)
+ (fooz 3))
+ (fboundp 'fooz))
+ (expect nil
+ (with-mock
+ (stub hoge) ;omission of return value
+ (hoge)))
+ (expect 'hoge
+ (with-mock
+ (stub me => 'hoge)
+ (me 1)))
+ (expect 34
+ (with-mock
+ (stub me => (+ 3 31))
+ (me 1)))
+ ;; ;; TODO defie mock-syntax-error / detect mock-syntax-error in expectations
+ ;; (desc "abused stub macro")
+ ;; (expect (error mock-syntax-error '("Use `(stub FUNC)' or `(stub FUNC =>
RETURN-VALUE)'"))
+ ;; (with-mock
+ ;; (stub fooz 7)))
+ (expect (error-message "Do not use `stub' outside")
+ (let (in-mocking) ; while executing `expect', `in-mocking' is t.
+ (stub hahahaha)))
+ (desc "mock macro")
+ (expect 2
+ (with-mock
+ (mock (foom 5) => 2)
+ (foom 5)))
+ (expect 3
+ (with-mock
+ (mock (foo 5) => 2)
+ (mock (bar 7) => 1)
+ (+ (foo 5) (bar 7))))
+ (expect 3
+ (flet ((plus () (+ (foo 5) (bar 7))))
+ (with-mock
+ (mock (foo 5) => 2)
+ (mock (bar 7) => 1)
+ (plus))))
+ (expect 1
+ (with-mock
+ (mock (f * 2) => 1)
+ (f 1 2)))
+ (expect 1
+ (with-mock
+ (mock (f * (1+ 1)) => (+ 0 1)) ;evaluated
+ (f 1 2)))
+ (expect nil
+ (with-mock
+ (mock (f 2)) ;omission of return value
+ (f 2)))
+ (expect 'hoge
+ (with-mock
+ (mock (me 1) => 'hoge)
+ (me 1)))
+ (expect 34
+ (with-mock
+ (mock (me 1) => (+ 3 31))
+ (me 1)))
+
+ (desc "unfulfilled mock")
+ (expect (error mock-error '((foom 5) (foom 6)))
+ (with-mock
+ (mock (foom 5) => 2)
+ (foom 6)))
+ (expect (error mock-error '((bar 7) (bar 8)))
+ (with-mock
+ (mock (foo 5) => 2)
+ (mock (bar 7) => 1)
+ (+ (foo 5) (bar 8))))
+ (expect (error mock-error '(not-called foo))
+ (with-mock
+ (mock (foo 5) => 2)))
+ (expect (error mock-error '(not-called foo))
+ (with-mock
+ (mock (vi 5) => 2)
+ (mock (foo 5) => 2)
+ (vi 5)))
+ (expect (error mock-error '((f 2) (f 4)))
+ (with-mock
+ (mock (f 2)) ;omission of return value
+ (f 4)))
+ (expect (error-message "error-in-test1")
+ (defun test1 () (error "error-in-test1"))
+ (with-mock
+ (mock (test2))
+ (test1)))
+ ;; (desc "abused mock macro")
+ ;; (expect (error mock-syntax-error '("Use `(mock FUNC-SPEC)' or `(mock
FUNC-SPEC => RETURN-VALUE)'"))
+ ;; (with-mock
+ ;; (mock (fooz) 7)))
+ (expect (error-message "Do not use `mock' outside")
+ (let (in-mocking) ; while executing `expect', `in-mocking' is t.
+ (mock (hahahaha))))
+
+ (desc "mock with stub")
+ (expect 8
+ (with-mock
+ (mock (f 1 2) => 3)
+ (stub hoge => 5)
+ (+ (f 1 2) (hoge 'a))))
+ (expect (error mock-error '((f 1 2) (f 3 4)))
+ (with-mock
+ (mock (f 1 2) => 3)
+ (stub hoge => 5)
+ (+ (f 3 4) (hoge 'a))))
+
+ (desc "with-stub is an alias of with-mock")
+ (expect 'with-mock
+ (symbol-function 'with-stub))
+
+ (desc "stublet is an alias of mocklet")
+ (expect 'mocklet
+ (symbol-function 'stublet))
+
+ (desc "mock-parse-spec")
+ (expect '(progn
+ (mock (f 1 2) => 3)
+ (stub hoge => 5))
+ (mock-parse-spec
+ '(((f 1 2) => 3)
+ (hoge => 5))))
+ (expect '(progn
+ (not-called g))
+ (mock-parse-spec
+ '((g not-called))))
+
+ (desc "mocklet")
+ (expect 8
+ (mocklet (((f 1 2) => 3)
+ (hoge => 5))
+ (+ (f 1 2) (hoge 'a))))
+ (expect 2
+ (mocklet ((foo => 2))
+ (foo 1 2 3)))
+ (expect 3
+ (defun defined-func (x) 3)
+ (prog1
+ (mocklet ((defined-func => 3))
+ (defined-func 3))
+ (fmakunbound 'defined-func)))
+ (expect nil
+ (mocklet ((f)) ;omission of return value
+ (f 91)))
+ (expect nil
+ (mocklet (((f 76))) ;omission of return value
+ (f 76)))
+ (expect 5
+ (mocklet ((a => 3)
+ (b => 2))
+ 1 ;multiple exprs
+ (+ (a 999) (b 7))))
+
+ (desc "stub for defined function")
+ (expect "xxx"
+ (defun blah (x) (* x 2))
+ (prog1
+ (let ((orig (symbol-function 'blah)))
+ (mocklet ((blah => "xxx"))
+ (blah "xx")))
+ (fmakunbound 'blah)))
+ (expect t
+ (defun blah (x) (* x 2))
+ (prog1
+ (let ((orig (symbol-function 'blah)))
+ (mocklet ((blah => "xx"))
+ (blah "xx"))
+ (equal orig (symbol-function 'blah)))
+ (fmakunbound 'blah)))
+
+ (desc "stub for adviced function")
+ (expect "xxx"
+ (mock-suppress-redefinition-message ;silence redefinition warning
+ (lambda ()
+ (defun fugaga (x) (* x 2))
+ (defadvice fugaga (around test activate)
+ (setq ad-return-value (concat "[" ad-return-value "]")))
+ (prog1
+ (let ((orig (symbol-function 'fugaga)))
+ (mocklet ((fugaga => "xxx"))
+ (fugaga "aaaaa")))
+ (fmakunbound 'fugaga)))))
+ (expect t
+ (mock-suppress-redefinition-message
+ (lambda ()
+ (defun fugaga (x) (* x 2))
+ (defadvice fugaga (around test activate)
+ (setq ad-return-value (concat "[" ad-return-value "]")))
+ (prog1
+ (let ((orig (symbol-function 'fugaga)))
+ (mocklet ((fugaga => "xx"))
+ (fugaga "aaaaa"))
+ (equal orig (symbol-function 'fugaga)))
+ (fmakunbound 'fugaga)))))
+
+ (desc "mock for adviced function")
+ (expect "xx"
+ (mock-suppress-redefinition-message
+ (lambda ()
+ (defun fugaga (x) (* x 2))
+ (defadvice fugaga (around test activate)
+ (setq ad-return-value (concat "[" ad-return-value "]")))
+ (prog1
+ (let ((orig (symbol-function 'fugaga)))
+ (mocklet (((fugaga "aaaaa") => "xx"))
+ (fugaga "aaaaa")))
+ (fmakunbound 'fugaga)))))
+ (expect t
+ (mock-suppress-redefinition-message
+ (lambda ()
+ (defun fugaga (x) (* x 2))
+ (defadvice fugaga (around test activate)
+ (setq ad-return-value (concat "[" ad-return-value "]")))
+ (prog1
+ (let ((orig (symbol-function 'fugaga)))
+ (mocklet (((fugaga "aaaaa") => "xx"))
+ (fugaga "aaaaa"))
+ (equal orig (symbol-function 'fugaga)))
+ (fmakunbound 'fugaga)))))
+ (desc "not-called macro")
+ (expect 'ok
+ (with-mock
+ (not-called foom)
+ 'ok))
+ (desc "mocklet/notcalled")
+ (expect 'ok
+ (mocklet ((foom not-called))
+ 'ok))
+ (desc "unfulfilled not-called")
+ (expect (error mock-error '(called))
+ (with-mock
+ (not-called hoge)
+ (hoge 1)))
+ (desc "abused not-called macro")
+ (expect (error-message "Do not use `not-called' outside")
+ (let (in-mocking) ; while executing `expect', `in-mocking' is t.
+ (not-called hahahaha)))
+ (desc "not-called for adviced function")
+ (expect "not-called"
+ (mock-suppress-redefinition-message ;silence redefinition warning
+ (lambda ()
+ (defun fugaga (x) (* x 2))
+ (defadvice fugaga (around test activate)
+ (setq ad-return-value (concat "[" ad-return-value "]")))
+ (prog1
+ (let ((orig (symbol-function 'fugaga)))
+ (mocklet ((fugaga not-called))
+ "not-called"))
+ (fmakunbound 'fugaga)))))
+ (expect t
+ (mock-suppress-redefinition-message
+ (lambda ()
+ (defun fugaga (x) (* x 2))
+ (defadvice fugaga (around test activate)
+ (setq ad-return-value (concat "[" ad-return-value "]")))
+ (prog1
+ (let ((orig (symbol-function 'fugaga)))
+ (mocklet ((fugaga not-called))
+ "not-called")
+ (equal orig (symbol-function 'fugaga)))
+ (fmakunbound 'fugaga)))))
+ (desc ":times mock")
+ (expect 'ok
+ (with-mock
+ (mock (foo 1) => 2 :times 2)
+ (foo 1)
+ (foo 1)
+ 'ok))
+ (expect 'ok
+ (with-mock
+ (mock (foo *) => 2 :times 2)
+ (foo 1)
+ (foo 2)
+ 'ok))
+ (expect 'ok
+ (with-mock
+ (mock (foo 1) :times 2)
+ (foo 1)
+ (foo 1)
+ 'ok))
+ (expect 'ok
+ (with-mock
+ (mock (foo *) :times 2)
+ (foo 1)
+ (foo 2)
+ 'ok))
+ ;; FIXME
+ ;; (expect 'ok
+ ;; (with-mock
+ ;; (mock (foo 1) => 2 :times 2)
+ ;; (foo 1)
+ ;; (foo 1)
+ ;; (foo 2)
+ ;; 'ok))
+ (expect (error mock-error '((foo 1) :expected-times 2 :actual-times 1))
+ (with-mock
+ (mock (foo 1) :times 2)
+ (foo 1)
+ 'ok))
+ (expect (error mock-error '((foo *) :expected-times 2 :actual-times 1))
+ (with-mock
+ (mock (foo *) :times 2)
+ (foo 1)
+ 'ok))
+ (expect (error mock-error '((foo 1) (foo 2)))
+ (with-mock
+ (mock (foo 1) :times 2)
+ (foo 2)
+ 'ok))
+ (expect (error mock-error '(not-called foo))
+ (with-mock
+ (mock (foo 1) :times 2)
+ 'ok))
+ (expect (error mock-error '((foo 1) :expected-times 2 :actual-times 1))
+ (with-mock
+ (mock (foo 1) => 2 :times 2)
+ (foo 1)
+ 'ok))
+ (expect (error mock-error '((foo *) :expected-times 2 :actual-times 1))
+ (with-mock
+ (mock (foo *) => 2 :times 2)
+ (foo 1)
+ 'ok))
+ (expect (error mock-error '((foo 1) (foo 2)))
+ (with-mock
+ (mock (foo 1) => 2 :times 2)
+ (foo 2)
+ 'ok))
+ (expect (error mock-error '(not-called foo))
+ (with-mock
+ (mock (foo 1) => 2 :times 2)
+ 'ok))
+ )
diff --git a/test/test-helper.el b/test/test-helper.el
new file mode 100644
index 0000000000..c409abd212
--- /dev/null
+++ b/test/test-helper.el
@@ -0,0 +1,4 @@
+(require 'f)
+(require 'ert-expectations)
+
+(require 'el-mock (f-expand "el-mock.el" (f-parent (f-parent (f-this-file)))))
- [nongnu] scratch/el-mock bd129d9a63 08/64: Merge branch 'ad-safe-fset-obsolete', (continued)
- [nongnu] scratch/el-mock bd129d9a63 08/64: Merge branch 'ad-safe-fset-obsolete', Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 718e821e9c 09/64: Release v1.25.0., Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 6d040af21e 10/64: Skip empty messages, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock b61b8f76a1 14/64: Remove how to save note, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 5ee1a1a5de 15/64: Move tests from el-mock.el, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock e349674b8a 18/64: Add LICENSE file, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 8e9f1fbfec 31/64: Fix tests for Emacs 25.1, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock e072098b76 06/64: Add Cask., Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 12aa28e785 11/64: Merge branch 'gracjan-empty-message', Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 70ef9873cd 13/64: Remove outdated bug report information, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 13eb3a9288 17/64: Merge branch 'testing',
Stefan Monnier <=
- [nongnu] scratch/el-mock 86444bfdfc 16/64: Add Travis config, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 47c04b9cae 19/64: Check for argument count mismatch., Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock d43353c2aa 21/64: Add How to use it section to readme, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 992db170a3 20/64: Merge branch 'bug5', Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 4c54b7247b 22/64: Merge branch 'patch-1', Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock a091520345 23/64: Update Travis config, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 5cb160b9bd 24/64: Don't use sudo on Travis, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 8cb59fc562 25/64: ©setup cask-package-toolset and update gitignore, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock a303e198a7 26/64: Setup coverage, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 8309faf0be 27/64: Add Continous Integration Badges, Stefan Monnier, 2023/08/28