aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/test/clojure/clojure/contrib/test_io.clj26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/test/clojure/clojure/contrib/test_io.clj b/src/test/clojure/clojure/contrib/test_io.clj
index 53347658..199cbfc5 100644
--- a/src/test/clojure/clojure/contrib/test_io.clj
+++ b/src/test/clojure/clojure/contrib/test_io.clj
@@ -1,5 +1,7 @@
(ns clojure.contrib.test-io
- (:use clojure.test clojure.contrib.io))
+ (:use clojure.test clojure.contrib.io)
+ (:import (java.io File)
+ (java.net URL URI)))
(deftest file-str-backslash
(is (= (java.io.File.
@@ -7,3 +9,25 @@
"Documents" java.io.File/separator
"file.txt"))
(file-str "C:\\Documents\\file.txt"))))
+
+(deftest test-as-file
+ (testing "strings"
+ (is (= (File. "foo") (as-file "foo"))))
+ (testing "Files"
+ (is (= (File. "bar") (as-file (File. "bar"))))))
+
+(deftest test-as-url
+ (are [result expr] (= result expr)
+ (URL. "http://foo") (as-url (URL. "http://foo"))
+ (URL. "http://foo") (as-url "http://foo")
+ (URL. "http://foo") (as-url (URI. "http://foo"))
+ (URL. "file:/foo") (as-url (File. "/foo"))))
+
+(deftest test-delete-file
+ (let [file (File/createTempFile "test" "deletion")
+ not-file (File. (str (java.util.UUID/randomUUID)))]
+ (delete-file (.getAbsolutePath file))
+ (is (not (.exists file)))
+ (is (thrown? ArithmeticException (/ 1 0)))
+ (is (thrown? java.io.IOException (delete-file not-file)))
+ (is (delete-file not-file :silently))))