-
Notifications
You must be signed in to change notification settings - Fork 23
Additional edits for ClojureCLR tests #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
076c2d4
66957f7
029111c
23711b3
e1bd5e1
98e1f59
d33f41f
1b6759f
45d7295
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{:deps {} | ||
|
||
:aliases | ||
{:test | ||
{:extra-paths ["test"] | ||
:extra-deps {io.github.dmiller/test-runner {:git/sha "c055ea13d19c6a9b9632aa2370fcc2215c8043c3"}} | ||
;; :main-opts {"-m" "cognitect.test-runner" "-d" "test"} | ||
|
||
:exec-fn cognitect.test-runner.api/test | ||
:exec-args {:dirs ["test"] | ||
:patterns [".*test.*"]}}} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,16 +13,17 @@ | |
:cljr (is (instance? System.Byte (byte 0)))) | ||
|
||
;; Check conversions and rounding from other numeric types | ||
;; In ClojureCLR, Byte is unsigned, so we have to wipe all tests of negative values | ||
(are [expected x] (= expected (byte x)) | ||
-128 -128 | ||
#?@(:cljr [] :default [-128 -128]) | ||
0 0 | ||
127 127 | ||
1 1N | ||
0 0N | ||
-1 -1N | ||
#?@(:cljr [] :default [-1 -1N]) | ||
|
||
1 1.0M | ||
0 0.0M | ||
-1 -1.0M | ||
#?@(:cljr [] :default [-1 -1.0M]) | ||
|
||
;; Clojurescript `byte` is a "dummy cast" which doesn't do | ||
;; anything (no-op). Thus, there is no conversion, no truncation | ||
;; of decimal values, etc. | ||
|
@@ -34,14 +35,14 @@ | |
-1.1 -1.1M] | ||
:default | ||
[1 1.1 | ||
-1 -1.1 | ||
#?@(:cljr [] :default [-1 -1.1]) | ||
1 1.9 | ||
1 3/2 | ||
-1 -3/2 | ||
#?@(:cljr [] :default [-1 -3/2]) | ||
0 1/10 | ||
0 -1/10 | ||
#?@(:cljr [] :default [0 -1/10]) | ||
1 1.1M | ||
-1 -1.1M])) | ||
#?@(:cljr [] :default [-1 -1.1M])])) | ||
|
||
|
||
#?@(:cljs | ||
[ ;; ClojureScript `byte` just returns its argument | ||
|
@@ -53,15 +54,26 @@ | |
(is (= :0 (byte :0))) | ||
(is (= [0] (byte [0]))) | ||
(is (= nil (byte nil)))] | ||
:bb [] ;; byte constructions goes via boxed argument | ||
:cljr | ||
[ ;; `byte` throws outside the range of 127 ... -128. | ||
(is (thrown? Exception (byte -128.000001))) | ||
(is (thrown? Exception (byte -129))) | ||
(is (= 128 (byte 128))) | ||
(is (= 127(byte 127.000001))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spacing is weird |
||
;; Check handling of other types | ||
(is (= 0 (byte "0"))) | ||
(is (thrown? Exception (byte :0))) | ||
(is (thrown? Exception (byte [0]))) | ||
(is (thrown? Exception (byte nil)))] | ||
:bb [] ;; byte constructions goes via boxed argument | ||
:default | ||
[ ;; `byte` throws outside the range of 127 ... -128. | ||
(is (thrown? #?(:clj Exception :cljr Exception) (byte -128.000001))) | ||
(is (thrown? #?(:clj Exception :cljr Exception) (byte -129))) | ||
(is (thrown? #?(:clj Exception :cljr Exception) (byte 128))) | ||
(is (thrown? #?(:clj Exception :cljr Exception) (byte 127.000001))) | ||
(is (thrown? Exception (byte -128.000001))) | ||
(is (thrown? Exception (byte -129))) | ||
(is (thrown? Exception (byte 128))) | ||
(is (thrown? Exception (byte 127.000001))) | ||
;; Check handling of other types | ||
(is (thrown? #?(:clj Exception :cljr Exception) (byte "0"))) | ||
(is (thrown? #?(:clj Exception :cljr Exception) (byte :0))) | ||
(is (thrown? #?(:clj Exception :cljr Exception) (byte [0]))) | ||
(is (thrown? #?(:clj Exception :cljr Exception) (byte nil)))]))) | ||
(is (thrown? Exception (byte "0"))) | ||
(is (thrown? Exception (byte :0))) | ||
(is (thrown? Exception (byte [0]))) | ||
(is (thrown? Exception (byte nil)))]))) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,24 @@ | |
(:require [clojure.test :as t :refer [deftest testing is are]] | ||
[clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) | ||
|
||
;; This is part of clojure.test-helpers, but I couldn't figure out how to :require or :use that library. | ||
;; Copied here for now | ||
|
||
#?(:cljr | ||
(let [nl Environment/NewLine] ;;; (System/getProperty "line.separator")] | ||
(defn platform-newlines [s] (.Replace ^String s "\n" nl))) ;;; .replace, add type hint | ||
:clj | ||
(let [nl (System/getProperty "line.separator")] | ||
(defn platform-newlines [s] (.replace s "\n" nl))) | ||
|
||
:default ;; does ClojureScript have its own version? | ||
(defn platform-newlines [s] s)) | ||
|
||
|
||
|
||
(when-var-exists clojure.core/with-out-str | ||
(deftest test-with-out-str | ||
(is (= (str "some sample :text here" \newline | ||
"[:a :b] {:c :d} #{:e} (:f)" \newline) | ||
(is (= (platform-newlines (str "some sample :text here" \newline | ||
"[:a :b] {:c :d} #{:e} (:f)" \newline)) | ||
(with-out-str | ||
(println "some" "sample" :text 'here) | ||
(prn [:a :b] {:c :d} #{:e} '(:f))))))) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,8 @@ | |
(is (true? (str/blank? nil))) | ||
(is (false? (str/blank? "֎"))) | ||
(testing "U+2007" | ||
(is (#?(:cljs true? :cljr true :default false?) (str/blank? " "))) | ||
(is (#?(:cljs true? :cljr true :default false?) (str/blank? "\u2007")))) | ||
(is (#?(:cljs true? :cljr true? :default false?) (str/blank? " "))) | ||
(is (#?(:cljs true? :cljr true? :default false?) (str/blank? "\u2007")))) | ||
|
||
(is (true? (str/blank? " "))) | ||
(is (true? (str/blank? " \t "))) | ||
#?(:cljs (do (is (true? (str/blank? (symbol "")))) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird spacing and indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix as you wish.
a copy of a copy of a copy from somewhere someone else used the test-runner