branch: scratch/el-mock
commit 47c04b9cae5a71743ecd030828c54b311c550a16
Author: Philipp Stephani <p...@google.com>
Commit: Philipp Stephani <p...@google.com>

    Check for argument count mismatch.
    
    Fixes #5
---
 el-mock.el           | 3 +++
 test/el-mock-test.el | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/el-mock.el b/el-mock.el
index 78fd34ecd8..953bcde7d1 100644
--- a/el-mock.el
+++ b/el-mock.el
@@ -123,6 +123,9 @@
         (apply 'mock-verify-args args)))
 
 (defun mock-verify-args (funcsym expected-args actual-args expected-times)
+  (unless (= (length expected-args) (length actual-args))
+    (signal 'mock-error (list (cons funcsym expected-args)
+                              (cons funcsym actual-args))))
   (loop for e in expected-args
         for a in actual-args
         do
diff --git a/test/el-mock-test.el b/test/el-mock-test.el
index cb58e24c4f..70c202e43b 100644
--- a/test/el-mock-test.el
+++ b/test/el-mock-test.el
@@ -357,4 +357,10 @@
          (with-mock
           (mock (foo 1) => 2 :times 2)
           'ok))
+
+ (desc "too few arguments")
+ (expect (error mock-error '((foo 1) (foo)))
+   (with-mock
+     (mock (foo 1))
+     (foo)))
  )

Reply via email to