branch: scratch/el-mock commit e3017494230cb90c5f542acc07c539be1497123b Merge: 9e4d092179 84a743cfcb Author: Philipp <p.stephani2+git...@gmail.com> Commit: GitHub <nore...@github.com>
Merge pull request #21 from phst/compile-error Switch to lexical binding, and fix compiler warnings --- el-mock.el | 6 +++--- test/el-mock-test.el | 43 +++++++++++++++++++++++++++++-------------- test/test-helper.el | 2 ++ 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/el-mock.el b/el-mock.el index bb95d1e27b..812cc12c3f 100644 --- a/el-mock.el +++ b/el-mock.el @@ -1,4 +1,4 @@ -;;; el-mock.el --- Tiny Mock and Stub framework in Emacs Lisp +;;; el-mock.el --- Tiny Mock and Stub framework in Emacs Lisp -*- lexical-binding: t; -*- ;; Copyright (C) 2008, 2010, 2012 rubikitch @@ -106,8 +106,8 @@ (when (fboundp funcsym) (put funcsym 'mock-original-func (symbol-function funcsym))) (fset funcsym - `(lambda (&rest actual-args) - (signal 'mock-error '(called)))))))) + (lambda (&rest _actual-args) + (signal 'mock-error '(called)))))))) (defalias 'mock/teardown 'stub/teardown) diff --git a/test/el-mock-test.el b/test/el-mock-test.el index 9eeaa0967c..f71fa54d60 100644 --- a/test/el-mock-test.el +++ b/test/el-mock-test.el @@ -1,3 +1,22 @@ +;; -*- lexical-binding: t; -*- + +(declare-function foo "el-mock-test") +(declare-function foox "el-mock-test") +(declare-function hogehoges "el-mock-test") +(declare-function fooz "el-mock-test") +(declare-function hoge "el-mock-test") +(declare-function me "el-mock-test") +(declare-function foom "el-mock-test") +(declare-function bar "el-mock-test") +(declare-function f "el-mock-test") +(declare-function vi "el-mock-test") +(declare-function test1 "el-mock-test") +(declare-function defined-func "el-mock-test") +(declare-function a "el-mock-test") +(declare-function b "el-mock-test") +(declare-function blah "el-mock-test") +(declare-function fugaga "el-mock-test") + (expectations (desc "stub setup/teardown") (expect 2 @@ -60,7 +79,7 @@ (mock (bar 7) => 1) (+ (foo 5) (bar 7)))) (expect 3 - (flet ((plus () (+ (foo 5) (bar 7)))) + (cl-flet ((plus () (+ (foo 5) (bar 7)))) (with-mock (mock (foo 5) => 2) (mock (bar 7) => 1) @@ -163,7 +182,7 @@ (mocklet ((foo => 2)) (foo 1 2 3))) (expect 3 - (defun defined-func (x) 3) + (defun defined-func (_x) 3) (prog1 (mocklet ((defined-func => 3)) (defined-func 3)) @@ -184,9 +203,8 @@ (expect "xxx" (defun blah (x) (* x 2)) (prog1 - (let ((orig (symbol-function 'blah))) - (mocklet ((blah => "xxx")) - (blah "xx"))) + (mocklet ((blah => "xxx")) + (blah "xx")) (fmakunbound 'blah))) (expect t (defun blah (x) (* x 2)) @@ -205,9 +223,8 @@ (defadvice fugaga (around test activate) (setq ad-return-value (concat "[" ad-return-value "]"))) (prog1 - (let ((orig (symbol-function 'fugaga))) - (mocklet ((fugaga => "xxx")) - (fugaga "aaaaa"))) + (mocklet ((fugaga => "xxx")) + (fugaga "aaaaa")) (fmakunbound 'fugaga))))) (expect t (mock-suppress-redefinition-message @@ -230,9 +247,8 @@ (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"))) + (mocklet (((fugaga "aaaaa") => "xx")) + (fugaga "aaaaa")) (fmakunbound 'fugaga))))) (expect t (mock-suppress-redefinition-message @@ -273,9 +289,8 @@ (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")) + (mocklet ((fugaga not-called)) + "not-called") (fmakunbound 'fugaga))))) (expect t (mock-suppress-redefinition-message diff --git a/test/test-helper.el b/test/test-helper.el index c409abd212..a2332e315a 100644 --- a/test/test-helper.el +++ b/test/test-helper.el @@ -1,3 +1,5 @@ +;; -*- lexical-binding: t; -*- + (require 'f) (require 'ert-expectations)