Mercurial > lasercutter
comparison src/clojure/test_clojure/test_fixtures.clj @ 10:ef7dbbd6452c
added clojure source goodness
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 21 Aug 2010 06:25:44 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
9:35cf337adfcf | 10:ef7dbbd6452c |
---|---|
1 ; Copyright (c) Rich Hickey. All rights reserved. | |
2 ; The use and distribution terms for this software are covered by the | |
3 ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) | |
4 ; which can be found in the file epl-v10.html at the root of this distribution. | |
5 ; By using this software in any fashion, you are agreeing to be bound by | |
6 ; the terms of this license. | |
7 ; You must not remove this notice, or any other, from this software. | |
8 ; | |
9 ;;; test_fixtures.clj: unit tests for fixtures in test.clj | |
10 | |
11 ;; by Stuart Sierra | |
12 ;; March 28, 2009 | |
13 | |
14 (ns clojure.test-clojure.test-fixtures | |
15 (:use clojure.test)) | |
16 | |
17 (declare *a* *b* *c* *d*) | |
18 | |
19 (def *n* 0) | |
20 | |
21 (defn fixture-a [f] | |
22 (binding [*a* 3] (f))) | |
23 | |
24 (defn fixture-b [f] | |
25 (binding [*b* 5] (f))) | |
26 | |
27 (defn fixture-c [f] | |
28 (binding [*c* 7] (f))) | |
29 | |
30 (defn fixture-d [f] | |
31 (binding [*d* 11] (f))) | |
32 | |
33 (defn inc-n-fixture [f] | |
34 (binding [*n* (inc *n*)] (f))) | |
35 | |
36 (use-fixtures :once fixture-a fixture-b) | |
37 | |
38 (use-fixtures :each fixture-c fixture-d inc-n-fixture) | |
39 (use-fixtures :each fixture-c fixture-d inc-n-fixture) | |
40 | |
41 (deftest can-use-once-fixtures | |
42 (is (= 3 *a*)) | |
43 (is (= 5 *b*))) | |
44 | |
45 (deftest can-use-each-fixtures | |
46 (is (= 7 *c*)) | |
47 (is (= 11 *d*))) | |
48 | |
49 (deftest use-fixtures-replaces | |
50 (is (= *n* 1))) |