Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Clojure 用于在重新帧运行测试同步不工作的情况下包装测试的宏_Clojure_Macros - Fatal编程技术网

Clojure 用于在重新帧运行测试同步不工作的情况下包装测试的宏

Clojure 用于在重新帧运行测试同步不工作的情况下包装测试的宏,clojure,macros,Clojure,Macros,我的代码中有以下习惯用法: (deftest my-test (run-test-sync (is (= 1 2)) ;; etc. ) 创建一个宏似乎是一个好主意,它可以这样复制: (deftest-sync my-test (is (= 1 2)) ) 我试过这样做: (defmacro deftest-sync [name test] `(deftest ~name ~(run-test-sync ~test)) ) 但在行动上: (macro

我的代码中有以下习惯用法:

(deftest my-test
   (run-test-sync
       (is (= 1 2)) ;; etc.
   )
创建一个宏似乎是一个好主意,它可以这样复制:

(deftest-sync my-test
   (is (= 1 2))
)
我试过这样做:

(defmacro deftest-sync [name test]
  `(deftest ~name ~(run-test-sync ~test))
  )
但在行动上:

(macroexpand '(deftest-sync some-test (is (= 1 1))))
我得到的结果是:

(deftest-sync some-test (is (= 1 1)))
我做错了什么

--编辑-- 我的第二次尝试是:

(defmacro deftest-sync [name & test]
  `(deftest ~name (run-test-sync ~@test))
  )

但宏观扩张仍然是:

(deftest-sync some-test (is (= 1 1)))

我做错了什么?

我觉得你的第二个版本还可以。我用苹果酒在Clojure(JVM)REPL上测试了这一点:

(ns macrodemo.core)
(defmacro deftest sync[名称和测试]
`(deftest~name(运行测试同步~@test)))
;; (宏扩展’(deftest sync some test(is(=1)))
;; => (macodemo.core/deftest一些测试(macodemo.core/run-test-sync(is(=1)))
;;
;; ... 基本上是:
;; (定义某些测试(运行测试同步(is(=1)))

我想你的第二个版本还可以。我用苹果酒在Clojure(JVM)REPL上测试了这一点:

(ns macrodemo.core)
(defmacro deftest sync[名称和测试]
`(deftest~name(运行测试同步~@test)))
;; (宏扩展’(deftest sync some test(is(=1)))
;; => (macodemo.core/deftest一些测试(macodemo.core/run-test-sync(is(=1)))
;;
;; ... 基本上是:
;; (定义某些测试(运行测试同步(is(=1)))