在emacs buttercup中生成测试

在emacs buttercup中生成测试,emacs,elisp,emacs-buttercup,Emacs,Elisp,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

我有一个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)
执行时。字符串在那里,因此至少测试字符串是 正确通过。然而,另一个似乎有问题 争论

手册中的相关章节:

示例功能:

(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)))))

通过

您需要查看代码。它是否使用
词法绑定
?错误表示
act
未绑定,这表示
(expect act…
在出现的词法上下文的另一个上下文中进行计算。可以确认,使用
词法let
。因此使用
词法let
或将其放在打开
词法绑定的文件中(如果您有足够新的Emacs版本)。如果您使用后者,则加载文件(或字节编译文件)-不要只是选择一些代码并对其求值,因为这不会从文件头中提取
词法绑定
声明。@Drew想把它写出来作为答案吗?不;我没有时间检查毛茛代码的详细信息等。我想你应该有足够的时间继续。如果没有,也许有人会把它拼出来呃举个例子。