在emacs毛茛中生成测试

时间:2015-06-27 03:22:48

标签: emacs elisp emacs-buttercup

我有一个emacs毛茛测试:

(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

1 个答案:

答案 0 :(得分:0)

示例功能:

(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