-
Notifications
You must be signed in to change notification settings - Fork 27
Port arithmetic operators for jank #828
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
base: main
Are you sure you want to change the base?
Changes from all commits
f5594c1
3a6d889
47d24c5
1a5a346
7e2af5e
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 |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| ;; In CLJS, all numbers are really doubles and integer? and int? | ||
| ;; return true if the fractional part of the double is zero | ||
| #?(:cljs (integer? n) | ||
| :jank (cpp/jank.runtime.is_big_integer n) | ||
| :default | ||
| (and (integer? n) | ||
| (not (int? n))))) | ||
|
Collaborator
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. If we're going to switch to this predicate, I think we could do a better job than this. Personally I think the default should be something like (= (type 0N) (type n))
Contributor
Author
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. I'm not quite sure why this is better? As long as we make sure the check in the compiler for
Contributor
Author
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. Ah! Are you referring to the |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| (ns clojure.core-test.star-squote | ||
| (:require [clojure.test :as t :refer [are deftest is]] | ||
| [clojure.core-test.number-range :as r] | ||
| [clojure.core-test.portability #?(:cljs :refer-macros :default :refer) [when-var-exists]])) | ||
| [clojure.core-test.portability :as p #?(:cljs :refer-macros :default :refer) [when-var-exists]])) | ||
|
|
||
| (when-var-exists *' | ||
| (deftest test-*' | ||
|
|
@@ -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 (p/big-int? (*' 0 1N))) | ||
| (is (p/big-int? (*' 0N 1))) | ||
| (is (p/big-int? (*' 0N 1N))) | ||
| (is (p/big-int? (*' 1N 1))) | ||
| (is (p/big-int? (*' 1 1N))) | ||
| (is (p/big-int? (*' 1N 1N))) | ||
| (is (p/big-int? (*' 1 5N))) | ||
| (is (p/big-int? (*' 1N 5))) | ||
| (is (p/big-int? (*' 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 (p/big-int? (*' -1 r/min-int))) | ||
| (is (p/big-int? (*' r/min-int -1))) | ||
| #?(:jank nil ;; Currently `long` hasn't been ported in jank. | ||
|
Contributor
Author
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. I can port |
||
| :default (is (p/big-int? (*' (long (/ r/min-int 2)) 3)))) | ||
| #?(:jank nil | ||
| :default (is (p/big-int? (*' 3 (long (/ r/min-int 2)))))))) | ||
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.
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?
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.
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.
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.
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.