在 emacs buttercup 中生成测试

Generating tests in emacs buttercup

我有一个 emacs buttercup 测试:

(describe
"Test"
(defun test-some (test-string actual expected)
  (let ((act actual) (exp expected))
    (it test-string
        (expect act
                :to-equal
                exp))))

(test-some
  "should be equal"
  1
  1))

然而,它给了我

Test should be equal
error: (void-variable act)

执行时。字符串在那里,所以至少 test-string 是 正确通过。不过另外一个好像有问题 参数。

手册中的相关部分:https://github.com/jorgenschaefer/emacs-buttercup/#its-just-functions

示例函数:

(cl-defun indent-and-compare (test-string file-name &key (uncompleted-indent 4))
  (lexical-let ((act (concat file-name "-actual.nim")) (exp (concat file-name "-expected.nim"))
                (indent uncompleted-indent))
    (it test-string
        (setq nim-uncompleted-condition-indent indent)
        (insert-file-contents-literally act)
        (indent-region (point-min) (point-max))

        (expect (buffer-string)
                :to-equal
                (file-to-string exp)))))

通过https://github.com/nim-lang/nim-mode/blob/ada2f827507397a8f20587af7c07d4de26e96394/tests/test-indent.el#L10-L20