Description:
Add property-based testing (and fix a bug).
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -0,0 +1,27 | |||||
|
|
1 | (ns project-checkup.core-property-test | ||
|
|
2 | (:gen-class) | ||
|
|
3 | (:require [clojure.test :refer :all] | ||
|
|
4 | [project-checkup.core :refer :all] | ||
|
|
5 | [clojure.test.check :as tc] | ||
|
|
6 | [clojure.test.check.generators :as gen] | ||
|
|
7 | [clojure.test.check.properties :as prop] | ||
|
|
8 | [clojure.test.check.clojure-test :refer :all])) | ||
|
|
9 | |||
|
|
10 | |||
|
|
11 | ;arguably redundant | ||
|
|
12 | (defspec get-extension-returns-string | ||
|
|
13 | 100 | ||
|
|
14 | (prop/for-all [st (gen/not-empty gen/string-ascii) | ||
|
|
15 | ext (gen/not-empty gen/string-alphanumeric) ] | ||
|
|
16 | (string? (get-extension (str st \. ext ))) )) | ||
|
|
17 | |||
|
|
18 | |||
|
|
19 | (defspec get-extension-returns-extension | ||
|
|
20 | 100 | ||
|
|
21 | (prop/for-all [st (gen/not-empty gen/string-ascii) | ||
|
|
22 | ext (gen/not-empty gen/string-alphanumeric) ] | ||
|
|
23 | (= (get-extension (str st \. ext )) | ||
|
|
24 | (str \. ext)) )) | ||
|
|
25 | |||
|
|
26 | |||
|
|
27 |
@@ -6,7 +6,8 | |||||
|
6 | :dependencies [[org.clojure/clojure "1.8.0"] |
|
6 | :dependencies [[org.clojure/clojure "1.8.0"] |
|
7 | [org.clojure/clojurescript "1.9.521"] |
|
7 | [org.clojure/clojurescript "1.9.521"] |
|
8 | ; [andare "0.9.0"] |
|
8 | ; [andare "0.9.0"] |
|
9 |
[org.clojure/core.async "0.4.474"] |
|
9 | [org.clojure/core.async "0.4.474"] |
|
|
10 | [org.clojure/test.check "0.10.0-alpha3"]] | ||
|
10 |
|
11 | ||
|
11 | :plugins [[lein-cljsbuild "1.1.5"]] |
|
12 | :plugins [[lein-cljsbuild "1.1.5"]] |
|
12 |
|
13 |
@@ -4,7 +4,11 | |||||
|
4 | (:require [clojure.java.shell :as shell] |
|
4 | (:require [clojure.java.shell :as shell] |
|
5 | [clojure.string :as string])) |
|
5 | [clojure.string :as string])) |
|
6 |
|
6 | ||
|
7 |
(defn get-extension [path] |
|
7 | (defn get-extension [path] |
|
|
8 | "Extracts the extension of a path. | ||
|
|
9 | Returns the extension with the period, e.g., '.txt' because that's the format | ||
|
|
10 | people are used to seeing extensions in." | ||
|
|
11 | (re-find #"\.[a-zA-Z0-9]+$" path)) | ||
|
8 |
|
12 | ||
|
9 | (defn gather-project-info |
|
13 | (defn gather-project-info |
|
10 | "Creates a dictionary of project information" |
|
14 | "Creates a dictionary of project information" |
@@ -39,6 +39,4 | |||||
|
39 | (is (= (get-extension "test.txt") ".txt")) |
|
39 | (is (= (get-extension "test.txt") ".txt")) |
|
40 | (is (= (get-extension "./test.txt") ".txt")) |
|
40 | (is (= (get-extension "./test.txt") ".txt")) |
|
41 | (is (= (get-extension "test.txt.bak") ".bak")) |
|
41 | (is (= (get-extension "test.txt.bak") ".bak")) |
|
42 | (is (= (get-extension ".hg/test.txt.bak") ".bak")) |
|
42 | (is (= (get-extension ".hg/test.txt.bak") ".bak")))) |
|
43 | ) |
|
||
|
44 | ) |
|
You need to be logged in to leave comments.
Login now