Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion test/clojure/core_test/number_range.cljc
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
(ns clojure.core-test.number-range)

;; TODO jank support blocked on https://github.com/jank-lang/jank/issues/195
#?(:jank (cpp/raw "#include <limits>"))
Comment thread
shantanu-sardesai marked this conversation as resolved.
Outdated

(def ^:const max-int #?(:clj Long/MAX_VALUE
:cljr Int64/MaxValue
:cljs js/Number.MAX_SAFE_INTEGER
:jank (cpp/value "std::numeric_limits<jank::i64>::max()")
:default 0x7FFFFFFFFFFFFFFF))

(def ^:const min-int #?(:clj Long/MIN_VALUE
:cljr Int64/MinValue
:cljs js/Number.MIN_SAFE_INTEGER
:jank (cpp/value "std::numeric_limits<jank::i64>::min()")
:default 0x8000000000000000))

(def ^:const all-ones-int #?(:cljs 0xFFFFFFFF
Expand All @@ -24,10 +26,12 @@
(def ^:const max-double #?(:clj Double/MAX_VALUE
:cljr Double/MaxValue
:cljs js/Number.MAX_VALUE
:jank (cpp/value "std::numeric_limits<jank::f64>::max()")
:default 1.7976931348623157e+308))

(def ^:const min-double #?(:clj Double/MIN_VALUE
:cljr Double/Epsilon ; NOTE: definitely not Double/MinValue -- ouch!
:cljs js/Number.MIN_VALUE
:jank (cpp/value "std::numeric_limits<jank::f64>::min()")
:default 4.9e-324))

27 changes: 14 additions & 13 deletions test/clojure/core_test/plus_squote.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,19 @@
6N 1N 5
6N 1N 5N)

(is (thrown? #?(:cljs :default :clj Exception :cljr Exception) (+' 1 nil)))
(is (thrown? #?(:cljs :default :clj Exception :cljr Exception) (+' nil 1)))
#?(:jank []
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocked by the jank-lang/jank#558.

@jeaye

I was thinking, maybe it would be better to have a specific issue ticket in jank (Maybe a child of this ticket) dedicated to updating all the Clojure test suite test cases for jank with support for catching specific exception types once the blocking feature is merged and in the meanwhile we merge these blocked PRs (this one, #790, and more incomming). That way we have a reminder to update these test cases and benefit from the plethora of other test cases.

What do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just see that as part of jank-lang/jank#415. It's not done until jank is running all of the tests we have in this repo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's fine, so we can merge these PRs and just revisit these tests once jank can catch exceptions by type. Till then I can just keep a list of tests (in the comments of the ticket) that need to be updated.

:default [(is (thrown? #?(:cljs :default :clj Exception :cljr Exception) (+' 1 nil)))
(is (thrown? #?(:cljs :default :clj Exception :cljr Exception) (+' nil 1)))])

(is (instance? clojure.lang.BigInt (+' 0 1N)))
(is (instance? clojure.lang.BigInt (+' 0N 1)))
(is (instance? clojure.lang.BigInt (+' 0N 1N)))
(is (instance? clojure.lang.BigInt (+' 1N 1)))
(is (instance? clojure.lang.BigInt (+' 1 1N)))
(is (instance? clojure.lang.BigInt (+' 1N 1N)))
(is (instance? clojure.lang.BigInt (+' 1 5N)))
(is (instance? clojure.lang.BigInt (+' 1N 5)))
(is (instance? clojure.lang.BigInt (+' 1N 5N)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (+' 0 1N)))
Comment thread
shantanu-sardesai marked this conversation as resolved.
Outdated
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (+' 0N 1)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (+' 0N 1N)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (+' 1N 1)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (+' 1 1N)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (+' 1N 1N)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (+' 1 5N)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (+' 1N 5)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (+' 1N 5N)))

(is (instance? clojure.lang.BigInt (+' -1 r/min-int)))
(is (instance? clojure.lang.BigInt (+' r/min-int -1)))))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (+' -1 r/min-int)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (+' r/min-int -1)))))
33 changes: 18 additions & 15 deletions test/clojure/core_test/star_squote.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,23 @@
5 1N 5
5 1N 5N)

(is (thrown? #?(:cljs :default :default Exception) (*' 1 nil)))
(is (thrown? #?(:cljs :default :default Exception) (*' nil 1)))
#?(:jank []
:default [(is (thrown? #?(:cljs :default :clj Exception :cljr Exception) (*' 1 nil)))
(is (thrown? #?(:cljs :default :clj Exception :cljr Exception) (*' nil 1)))])

(is (instance? clojure.lang.BigInt (*' 0 1N)))
(is (instance? clojure.lang.BigInt (*' 0N 1)))
(is (instance? clojure.lang.BigInt (*' 0N 1N)))
(is (instance? clojure.lang.BigInt (*' 1N 1)))
(is (instance? clojure.lang.BigInt (*' 1 1N)))
(is (instance? clojure.lang.BigInt (*' 1N 1N)))
(is (instance? clojure.lang.BigInt (*' 1 5N)))
(is (instance? clojure.lang.BigInt (*' 1N 5)))
(is (instance? clojure.lang.BigInt (*' 1N 5N)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (*' 0 1N)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (*' 0N 1)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (*' 0N 1N)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (*' 1N 1)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (*' 1 1N)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (*' 1N 1N)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (*' 1 5N)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (*' 1N 5)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (*' 1N 5N)))

(is (instance? clojure.lang.BigInt (*' -1 r/min-int)))
(is (instance? clojure.lang.BigInt (*' r/min-int -1)))
(is (instance? clojure.lang.BigInt (*' (long (/ r/min-int 2)) 3)))
(is (instance? clojure.lang.BigInt (*' 3 (long (/ r/min-int 2)))))))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (*' -1 r/min-int)))
(is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (*' r/min-int -1)))
#?(:jank nil ;; Currently `long` hasn't been ported in jank.
Comment thread
shantanu-sardesai marked this conversation as resolved.
:default (is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (*' (long (/ r/min-int 2)) 3))))
#?(:jank nil
:default (is (#?@(:jank [cpp/jank.runtime.is_big_integer] :default [instance? clojure.lang.BigInt]) (*' 3 (long (/ r/min-int 2))))))))