From adc2a0e2158e5455ece4da25cf2b53f98bc98907 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Sat, 21 Jan 2023 16:08:28 -0700 Subject: [PATCH 1/6] replace potemkin --- .clj-kondo/config.edn | 3 - .github/workflows/cljs.yaml | 2 +- CHANGELOG.md | 58 +++---- CONTRIBUTORS.md | 2 +- README.md | 4 +- deps.edn | 3 +- doc/basics/clojurescript.adoc | 2 +- doc/basics/using_sicmutils.adoc | 2 +- doc/cljdoc.edn | 2 +- doc/contributing.adoc | 8 +- .../sicmutils/sicmutils/config.edn | 2 + src/pattern/rule.cljc | 6 +- src/sicmutils/calculus/derivative.cljc | 2 +- src/sicmutils/complex.cljc | 2 +- src/sicmutils/env.cljc | 3 +- src/sicmutils/env/sci/macros.cljc | 7 +- src/sicmutils/expression/compile.cljc | 2 +- src/sicmutils/numbers.cljc | 4 +- src/sicmutils/polynomial.cljc | 2 +- src/sicmutils/quaternion.cljc | 4 +- src/sicmutils/ratio.cljc | 4 +- src/sicmutils/util/def.cljc | 146 ++++++++++++++++-- src/sicmutils/value.cljc | 2 +- test/pattern/match_test.cljc | 2 +- test/sicmutils/complex_test.cljc | 2 +- test/sicmutils/differential_test.cljc | 2 +- test/sicmutils/env_test.cljc | 2 +- .../examples/double_pendulum_test.cljc | 2 +- 28 files changed, 201 insertions(+), 81 deletions(-) diff --git a/.clj-kondo/config.edn b/.clj-kondo/config.edn index 263efaacb..c84c31fc8 100644 --- a/.clj-kondo/config.edn +++ b/.clj-kondo/config.edn @@ -7,9 +7,6 @@ :output {:exclude-files ["src/data_readers.clj"]} - :hooks - {:analyze-call {potemkin/import-def - hooks.sicmutils.util.def/import-def}} :linters {:unsorted-required-namespaces {:level :warning} :redundant-fn-wrapper {:level :warning} diff --git a/.github/workflows/cljs.yaml b/.github/workflows/cljs.yaml index 30a1c1acb..7acb07415 100644 --- a/.github/workflows/cljs.yaml +++ b/.github/workflows/cljs.yaml @@ -36,7 +36,7 @@ jobs: - name: Install dependencies run: npm install - - name: Clojurescript tests + - name: ClojureScript tests run: npm run-script test env: NODE_OPTIONS: --max-old-space-size=8192 diff --git a/CHANGELOG.md b/CHANGELOG.md index ebbc88337..b73771a20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -702,7 +702,7 @@ `sicmutils.algebra.fold/kbk-n` in the SCI environment (you'll need to turn on access to `js/Math` or `java.lang.Math`). - - Fixed a type inference warning in Clojurescript in `sicmutils.complex`. + - Fixed a type inference warning in ClojureScript in `sicmutils.complex`. - Added support for `sicmutils.util.def` and its `fork` macro to the default SCI environment provided by SICMUtils. Helpful for macro-writing! @@ -873,7 +873,7 @@ permutation relative to its sorted version. - `sicmutils.complex/complex` can now take a single string argument in both - Clojure and Clojurescript. + Clojure and ClojureScript. - Expands the complex number literal parser to take these forms, in addition to the previously-supported string argument: @@ -914,7 +914,7 @@ - Converts many of the `sicmutils.fdg` test namespaces to use the new `define-coordinates` macro, making for a presentation closer to the book's. - - Fixes a Clojurescript warning in `sicmutils.util` warning due to + - Fixes a ClojureScript warning in `sicmutils.util` warning due to redefinition of `clojure.core/uuid` - #386: @@ -1029,7 +1029,7 @@ The new `cljsjs` dependency has code compatible with advanced compilation. ## 0.19.1 -This is an incremental bugfix release to get Clojurescript advanced compilation +This is an incremental bugfix release to get ClojureScript advanced compilation into shape. - #371: @@ -1158,7 +1158,7 @@ for the detailed notes, and enjoy version 0.19.0! - `v/kind` now works for `sorted-map` instances. - - GCD in Clojurescript is now fast and efficient between all combinations of + - GCD in ClojureScript is now fast and efficient between all combinations of `js/BigInt` and `js/Number`, and in Clojure between all combinations of `clojure.lang.BigInt`, `BigInteger`, `Long` and `Integer`. @@ -1328,13 +1328,13 @@ for the detailed notes, and enjoy version 0.19.0! `sicmutils.abstract.function`, making the Bianchi identity benchmarks run 40% faster. - - In Clojurescript, `Range` instances now implement `sicmutils.value.Value` + - In ClojureScript, `Range` instances now implement `sicmutils.value.Value` and `sicmutils.differential.IPerturbed`, allowing them to be returned from derivative-taking functions - Major, unexpected performance improvement - it turns out `sicmutils.value/number?` was quite slow in Clojure (less so in - Clojurescript). Changing this function from an `isa?` check to a series of + ClojureScript). Changing this function from an `isa?` check to a series of explicit `instance?` checks cut the build time in half. This makes the numeric tower less extensible... but it wasn't terribly extensible to start with, and needs some attention to make it so. A big win! @@ -1415,8 +1415,8 @@ for the detailed notes, and enjoy version 0.19.0! - #358: - - Converts the Clojurescript test build and REPL command from `lein-cljsbuild` - to `shadow-cljs`. This enables more formerly-slow tests for Clojurescript; + - Converts the ClojureScript test build and REPL command from `lein-cljsbuild` + to `shadow-cljs`. This enables more formerly-slow tests for ClojureScript; these are now fast enough to run, thanks to the performance improvements described below. @@ -1435,7 +1435,7 @@ for the detailed notes, and enjoy version 0.19.0! failure. - fixed a heisenbug in `sicmutils.expression.analyze/make-analyzer` where, in - Clojurescript, using expressions containing a `js/BigInt` as a hashmap key + ClojureScript, using expressions containing a `js/BigInt` as a hashmap key caused certain simplifications to fail. (This is vague, but the bug was _really_ subtle.) The fix was to make sure we freeze keys in the symbol cache. This is now noted in the function body. @@ -1849,12 +1849,12 @@ Enjoy the release! this operation - #309: `sicmutils.util/bigint` is aliased as `sicmutils.env/bigint` in - Clojurescript only. This is available natively in Clojure. + ClojureScript only. This is available natively in Clojure. - #308 and #310 add: - `sicmutils.ratio/{numerator,denominator,ratio?,rationalize}` and are now - aliased into `sicmutils.env` in Clojurescript. These are available natively + aliased into `sicmutils.env` in ClojureScript. These are available natively in Clojure. `sicmutils.complex/complex?` is aliased into `sicmutils.env` for both platforms. @@ -2163,7 +2163,7 @@ Detailed release notes: - #279: Function aliases in `sicmutils.env` now properly mirror over docstrings and other `Var` metadata, thanks to [Potemkin](https://github.com/clj-commons/potemkin)'s `import-def`. This - doesn't quite work in Clojurescript since we can't use `resolve` inside of a + doesn't quite work in ClojureScript since we can't use `resolve` inside of a macro (special form!). - Add a proper namespace to `demo.clj`, to make it easier to use outside of @@ -2189,7 +2189,7 @@ Detailed release notes: ### Behavior changes, bug fixes - In JVM Clojure (as of #298), `sicmutils.expression.compile` defaults to - `clojure.core/eval` to compile functions, while Clojurescript defaults to + `clojure.core/eval` to compile functions, while ClojureScript defaults to [SCI](https://github.com/borkdude/sci). The performance is much faster for numerical routines and worth the slightly different default behavior. @@ -2243,7 +2243,7 @@ like `Operator`, `Series`, `PowerSeries` and `Structure`. The system is now fully extensible, so if you want to differentiate functions that return custom records or Java collections, it's now no problem. -SICMUtils can now differentiate functions in Clojurescript that use comparison +SICMUtils can now differentiate functions in ClojureScript that use comparison operations like `<`, `=`, `<=` and friends. Clojure can't quite do this yet, but you can differentiate through `v/compare` and `v/=` calls. @@ -2408,9 +2408,9 @@ On to the detailed release notes: - new `sicmutils.value/compare` function exposed in `sicmutils.env` returns a valid comparison bit between native numbers and numbers wrapped in - `Differential` or `Expression` in both JVM Clojure and Clojurescript (#236). + `Differential` or `Expression` in both JVM Clojure and ClojureScript (#236). The behavior matches `clojure.core/compare` for all reals on the JVM; it - doesn't in Clojurescript because native `compare` can't handle + doesn't in ClojureScript because native `compare` can't handle `goog.math.{Long,Integer}` or `js/BigInt`. ### Operator @@ -2584,7 +2584,7 @@ On to the detailed release notes: ### Miscellaneous -- expose `bootstrap-repl!` to Clojurescript, so that this is available in +- expose `bootstrap-repl!` to ClojureScript, so that this is available in self-hosted CLJS (https://github.com/sicmutils/sicmutils/pull/157) - modified `infix.cljc` to wrap forms in `displaystyle` and add proper carriage @@ -2626,12 +2626,12 @@ On to the detailed release notes: - added `sicmutils.value/sqrt-machine-epsilon` ([#170](https://github.com/sicmutils/sicmutils/pull/170)) -- fixed issues in `function.cljc` and `operator.cljc` where the Clojurescript +- fixed issues in `function.cljc` and `operator.cljc` where the ClojureScript `IFn` `-invoke` arguments shadowed either the `this` operator, or some parameter name in the deftype ([#169](https://github.com/sicmutils/sicmutils/pull/169)) -- `g/sqrt` now maintains precision with Clojurescript's rational numbers. +- `g/sqrt` now maintains precision with ClojureScript's rational numbers. `(g/sqrt #sicm/ratio 9/4)` for example returns `#sicm/ratio 3/2`. ([#168](https://github.com/sicmutils/sicmutils/pull/168)) @@ -2964,7 +2964,7 @@ I can now make some comments that clear up my former misunderstandings: - If you want to compare literal numbers and an expression like - `(an/literal-number 12)`, use `v/=`. In Clojurescript, this will work with + `(an/literal-number 12)`, use `v/=`. In ClojureScript, this will work with the built in `=` as well, since equality is implemented with a protocol that we can extend. For example: @@ -3075,12 +3075,12 @@ the three). ## 0.13.0 -The main announcement for this release is _Clojurescript Support!_. Implementing +The main announcement for this release is _ClojureScript Support!_. Implementing this resulted in a few upgrades along the way: - more powerful numerics, specifically `definite-integral` and native minimization routines -- a generic numeric tower for Clojurescript +- a generic numeric tower for ClojureScript - Many more tests! The test coverage was great before, and it's stayed high as we've added new implementations. - added explicit code coverage metrics via Codecov: [![Codecov branch](https://img.shields.io/codecov/c/github/littleredcomputer/sicmutils/master.svg?maxAge=3600)](https://codecov.io/github/littleredcomputer/sicmutils) @@ -3100,13 +3100,13 @@ Here are more explicit details on the release. but expands each term in order `n`. - many, many more tests! -### Clojurescript Support +### ClojureScript Support -Full conversion of SICMUtils to Clojurescript. All functionality from v0.12.1 -now works in both Clojure and Clojurescript! +Full conversion of SICMUtils to ClojureScript. All functionality from v0.12.1 +now works in both Clojure and ClojureScript! Most of the conversion was straightforward. The major missing piece was a -numeric tower implementation for Clojurescript (complex numbers, ratios) that +numeric tower implementation for ClojureScript (complex numbers, ratios) that bring it up to parity with Clojure: - Add the `bigfraction` implementation from @@ -3176,12 +3176,12 @@ provides 3 new data reader literals: Use this with a ratio literal, like `#sicm/ratio 1/2`, or with a string like `#sicm/ratio "1/4"`. If the denominator is `1` this literal will return a -`js/BigInt` in Clojurescript, or a Long in Clojure. +`js/BigInt` in ClojureScript, or a Long in Clojure. - `#sicm/bigint` Use with a number literal, like, `#sicm/bigint 10`, or a string like -`#sicm/bigint "10000012"` to generate a `js/BigInt` in Clojurescript, or a +`#sicm/bigint "10000012"` to generate a `js/BigInt` in ClojureScript, or a `clojure.lang.BigInt` in Clojure. - `#sicm/complex` diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 9d2abec1d..bf26f0cec 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -3,4 +3,4 @@ following for their help: @alexgian: early testing, patience, and excellent advice! @kloimhardt: SICM chapter 1 example notebook -@sritchie: Clojurescript port, functional numerical implementations +@sritchie: ClojureScript port, functional numerical implementations diff --git a/README.md b/README.md index e59c3fb4a..b6175a07b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A Clojure(script) implementation of the [scmutils](https://groups.csail.mit.edu/mac/users/gjs/6946/refman.txt) system -for math and physics investigations in the Clojure and Clojurescript languages. +for math and physics investigations in the Clojure and ClojureScript languages. SICMUtils provides facilities for - [symbolic @@ -75,7 +75,7 @@ Math works as expected (see for the full menu of operations), but notice that the numeric tower includes [complex numbers](https://cljdoc.org/d/sicmutils/sicmutils/CURRENT/doc/data-types/complex), -and proper ratios in Clojurescript: +and proper ratios in ClojureScript: ```clojure (- (* 7 (/ 1 2)) 2) diff --git a/deps.edn b/deps.edn index eb07a9f5f..261776a9c 100644 --- a/deps.edn +++ b/deps.edn @@ -8,8 +8,7 @@ dm3/stopwatch {:mvn/version "0.1.1" :exclusions [org.clojure/clojurescript]} hiccup/hiccup {:mvn/version "1.0.5"} org.apache.commons/commons-math3 {:mvn/version "3.6.1"} - org.babashka/sci {:mvn/version "0.6.37"} - potemkin/potemkin {:mvn/version "0.4.5"}} + org.babashka/sci {:mvn/version "0.6.37"}} :aliases {:dev {:extra-paths ["dev"] diff --git a/doc/basics/clojurescript.adoc b/doc/basics/clojurescript.adoc index c0d173507..9dda47f57 100644 --- a/doc/basics/clojurescript.adoc +++ b/doc/basics/clojurescript.adoc @@ -1,3 +1,3 @@ -= Clojurescript += ClojureScript More info soon. diff --git a/doc/basics/using_sicmutils.adoc b/doc/basics/using_sicmutils.adoc index 3612e6b08..2e96e4aad 100644 --- a/doc/basics/using_sicmutils.adoc +++ b/doc/basics/using_sicmutils.adoc @@ -50,7 +50,7 @@ and hitting ```` in any block, and evaluating the following form: (nextjournal.env/load! :sicmutils) ---- -Any subsequent Clojurescript block will have every function in +Any subsequent ClojureScript block will have every function in https://cljdoc.org/d/sicmutils/sicmutils/CURRENT/api/sicmutils.env[``sicmutils.env``] available. diff --git a/doc/cljdoc.edn b/doc/cljdoc.edn index 14ffdbd37..4965f485d 100644 --- a/doc/cljdoc.edn +++ b/doc/cljdoc.edn @@ -4,7 +4,7 @@ ["Basics" {} ["How to Use SICMUtils" {:file "doc/basics/using_sicmutils.adoc"}] ["Generics" {:file "doc/basics/generics.adoc"}] - ["Clojurescript" {:file "doc/basics/clojurescript.adoc"}] + ["ClojureScript" {:file "doc/basics/clojurescript.adoc"}] ["Data Readers" {:file "doc/basics/data_readers.adoc"}]] ["Data Types" {} ["Number" {:file "doc/types/number.adoc"}] diff --git a/doc/contributing.adoc b/doc/contributing.adoc index 1cc47ed0c..bb96bfa35 100644 --- a/doc/contributing.adoc +++ b/doc/contributing.adoc @@ -7,7 +7,7 @@ Here's a short overview. More info coming soon! === Developing in SICMUtils To run all tests in Clojure, you'll need to install the -https://clojure.org/guides/install_clojure[Clojure CLI tool]. The Clojurescript +https://clojure.org/guides/install_clojure[Clojure CLI tool]. The ClojureScript tests require https://nodejs.org/en/[Node.js]. If you're on a Mac, install https://brew.sh[Homebrew]: @@ -47,9 +47,9 @@ To run the full Clojure test suite: clojure -P -M:test:runner ---- -=== Clojurescript Tests +=== ClojureScript Tests -We run the Clojurescript test suite and check for advanced compilation warnings +We run the ClojureScript test suite and check for advanced compilation warnings using [shadow-cljs]. In the ``sicmutils`` directory, run @@ -59,7 +59,7 @@ In the ``sicmutils`` directory, run npm install ---- -to run the full Clojurescript test suite, call the following command (and make +to run the full ClojureScript test suite, call the following command (and make sure to note any warnings): [source, bash] diff --git a/resources/clj-kondo.exports/sicmutils/sicmutils/config.edn b/resources/clj-kondo.exports/sicmutils/sicmutils/config.edn index 63f108d82..7265fb24e 100644 --- a/resources/clj-kondo.exports/sicmutils/sicmutils/config.edn +++ b/resources/clj-kondo.exports/sicmutils/sicmutils/config.edn @@ -46,6 +46,8 @@ hooks.sicmutils.abstract.function/with-literal-functions sicmutils.util.def/import-def hooks.sicmutils.util.def/import-def + sicmutils.util.def/import-fn hooks.sicmutils.util.def/import-def + sicmutils.util.def/import-macro hooks.sicmutils.util.def/import-def pattern.rule/consequence hooks.pattern.rule/consequence pattern.rule/pattern hooks.pattern.rule/pattern diff --git a/src/pattern/rule.cljc b/src/pattern/rule.cljc index 9f1da955e..36a2d78e7 100644 --- a/src/pattern/rule.cljc +++ b/src/pattern/rule.cljc @@ -5,13 +5,11 @@ matcher combinators declared in [[pattern.match]], along with a series of combinators for building advanced term-rewriting systems." (:refer-clojure :exclude [replace while]) - (:require #?(:clj [potemkin :refer [import-def]]) - [pattern.consequence :as c] + (:require [pattern.consequence :as c] [pattern.match :as m] [pattern.syntax :as ps] [sicmutils.util :as u] - #?(:cljs - [sicmutils.util.def :refer [import-def]])) + [sicmutils.util.def :refer [import-def]]) #?(:cljs (:require-macros [pattern.rule]))) diff --git a/src/sicmutils/calculus/derivative.cljc b/src/sicmutils/calculus/derivative.cljc index 2e31ed2b3..b1690804e 100644 --- a/src/sicmutils/calculus/derivative.cljc +++ b/src/sicmutils/calculus/derivative.cljc @@ -194,7 +194,7 @@ ;; ## Protocol Implementation ;; ;; The implementation for functions handles functions, multimethods, and, in -;; Clojurescript, [[MetaFn]] instances. Metadata in the original function is +;; ClojureScript, [[MetaFn]] instances. Metadata in the original function is ;; preserved through tag replacement and extraction. (extend-protocol d/IPerturbed diff --git a/src/sicmutils/complex.cljc b/src/sicmutils/complex.cljc index c6f3c5292..423eae2dd 100644 --- a/src/sicmutils/complex.cljc +++ b/src/sicmutils/complex.cljc @@ -2,7 +2,7 @@ (ns sicmutils.complex "This namespace provides a number of functions and constructors for working - with [[Complex]] numbers in Clojure and Clojurescript, and + with [[Complex]] numbers in Clojure and ClojureScript, and installs [[Complex]] into the SICMUtils generic arithmetic system. For other numeric extensions, see [[sicmutils.ratio]] diff --git a/src/sicmutils/env.cljc b/src/sicmutils/env.cljc index ed0e1854e..0b5657f73 100644 --- a/src/sicmutils/env.cljc +++ b/src/sicmutils/env.cljc @@ -26,7 +26,6 @@ infinite? abs ref partial =]) (:require [clojure.core :as core] - #?(:clj [potemkin :refer [import-def import-vars]]) [sicmutils.abstract.function :as af] [sicmutils.abstract.number] [sicmutils.algebra.fold] @@ -79,7 +78,7 @@ [sicmutils.structure :as structure] [sicmutils.util] [sicmutils.util.aggregate] - #?(:cljs [sicmutils.util.def :refer [import-def import-vars]]) + [sicmutils.util.def :refer [import-def import-vars]] [sicmutils.util.permute] [sicmutils.util.stream :as us] [sicmutils.value :as v]) diff --git a/src/sicmutils/env/sci/macros.cljc b/src/sicmutils/env/sci/macros.cljc index 673b00f60..6bbcd46ff 100644 --- a/src/sicmutils/env/sci/macros.cljc +++ b/src/sicmutils/env/sci/macros.cljc @@ -178,7 +178,12 @@ (def ns-bindings {'pattern.rule pattern-macros - 'sicmutils.env all + 'sicmutils.env + (select-keys all ['literal-function + 'with-literal-functions + 'let-coordinates + 'using-coordinates + 'define-coordinates]) 'sicmutils.abstract.function (select-keys all ['with-literal-functions]) diff --git a/src/sicmutils/expression/compile.cljc b/src/sicmutils/expression/compile.cljc index 0c983f9fd..8c9197d88 100644 --- a/src/sicmutils/expression/compile.cljc +++ b/src/sicmutils/expression/compile.cljc @@ -425,7 +425,7 @@ #?(:cljs (set! *mode* mode) :clj (alter-var-root #'*mode* (constantly mode)))) -;; Native compilation works on the JVM, and on Clojurescript if you're running +;; Native compilation works on the JVM, and on ClojureScript if you're running ;; in a self-hosted CLJS environment. Enable this mode by wrapping your call in ;; ;; `(binding [*mode* :native] ,,,)` diff --git a/src/sicmutils/numbers.cljc b/src/sicmutils/numbers.cljc index 2ad294738..145810a31 100644 --- a/src/sicmutils/numbers.cljc +++ b/src/sicmutils/numbers.cljc @@ -195,7 +195,7 @@ (defmethod g/remainder [::v/real ::v/real] [a b] (rem a b)) (defmethod g/modulo [::v/real ::v/real] [a b] (mod a b)) -;; This section defines methods that act differently between Clojurescript and +;; This section defines methods that act differently between ClojureScript and ;; Clojure. The clojure methods are all slightly more refined based on Java's ;; type system. #?(:clj @@ -274,7 +274,7 @@ a (r/rationalize 1 a))))) -;; Clojurescript and Javascript have a number of numeric types available that +;; ClojureScript and Javascript have a number of numeric types available that ;; don't respond true to number? These each require their own block of method ;; implementations. #?(:cljs diff --git a/src/sicmutils/polynomial.cljc b/src/sicmutils/polynomial.cljc index bb8d2d89b..e9e1a2cb5 100644 --- a/src/sicmutils/polynomial.cljc +++ b/src/sicmutils/polynomial.cljc @@ -1169,7 +1169,7 @@ #?(:cljs (defn- ->big - "Clojurescript multiplication doesn't autopromote; we expect large values + "ClojureScript multiplication doesn't autopromote; we expect large values in [[pseudo-remainder]], and use [[->big]] to pre-cast the factors to [[util/bigint]] so they don't overflow." [c] diff --git a/src/sicmutils/quaternion.cljc b/src/sicmutils/quaternion.cljc index 0f0ebe4c2..285e2f455 100644 --- a/src/sicmutils/quaternion.cljc +++ b/src/sicmutils/quaternion.cljc @@ -2,7 +2,7 @@ (ns sicmutils.quaternion "This namespace provides a number of functions and constructors for working - with [[Quaternion]] instances in Clojure and Clojurescript, and + with [[Quaternion]] instances in Clojure and ClojureScript, and installs [[Quaternion]] into the SICMUtils generic arithmetic system. For other numeric extensions, see [[sicmutils.ratio]], [[sicmutils.complex]] @@ -1426,7 +1426,7 @@ NOTE this routine uses non-generic [[clojure.core/>=]] and [[clojure.core/max]] internally, so if you use numeric entries (or if your entries simplify down to numbers), make sure that they work with these native - operations. No `BigInt` in Clojurescript for now, for example." + operations. No `BigInt` in ClojureScript for now, for example." [M] (let [[[r11 r12 r13] [r21 r22 r23] [r31 r32 r33]] M q0-2 (g/* quarter (g/+ 1 r11 r22 r33)) diff --git a/src/sicmutils/ratio.cljc b/src/sicmutils/ratio.cljc index e1bad4416..0443c9304 100644 --- a/src/sicmutils/ratio.cljc +++ b/src/sicmutils/ratio.cljc @@ -2,9 +2,9 @@ (ns sicmutils.ratio "This namespace provides a number of functions and constructors for working - with ratios in Clojure and Clojurescript. + with ratios in Clojure and ClojureScript. - [[clojure.lang.Ratio]] is native in Clojure. The Clojurescript implementation + [[clojure.lang.Ratio]] is native in Clojure. The ClojureScript implementation uses [Fraction.js](https://github.com/infusion/Fraction.js/). For other numeric extensions, see [[sicmutils.numbers]] diff --git a/src/sicmutils/util/def.cljc b/src/sicmutils/util/def.cljc index 1abc5172e..27b30a15c 100644 --- a/src/sicmutils/util/def.cljc +++ b/src/sicmutils/util/def.cljc @@ -73,12 +73,86 @@ (defmethod ~f [~kwd-klass] [k#] (~attr k#))))) +#?(:clj + (defn link-vars + "Makes sure that all changes to `src` are reflected in `dst`. + + NOTE that [[link-vars]] comes + from [`potemkin.namespaces`](https://github.com/clj-commons/potemkin/blob/master/src/potemkin/namespaces.clj); + we import it here to avoid importing the full library." + [src dst] + (add-watch + src dst + (fn [_ src _old _new] + (alter-var-root dst (constantly @src)) + (alter-meta! dst merge (dissoc (meta src) :name)))))) + +#?(:clj + (defmacro import-fn + "Given a function in another namespace, defines a function with the same + name in the current namespace. Argument lists, doc-strings, and original + line-numbers are preserved. + + NOTE that [[import-fn]] comes + from [`potemkin.namespaces`](https://github.com/clj-commons/potemkin/blob/master/src/potemkin/namespaces.clj); + we import it here to avoid importing the full library." + ([sym] + `(import-fn ~sym nil)) + ([sym name] + (let [vr (resolve sym) + m (meta vr) + n (or name (:name m)) + arglists (:arglists m) + protocol (:protocol m)] + (when-not vr + (throw (IllegalArgumentException. (str "Don't recognize " sym)))) + (when (:macro m) + (throw (IllegalArgumentException. + (str "Calling import-fn on a macro: " sym)))) + + `(do + (def ~(with-meta n {:arglists arglists + :protocol protocol}) + (deref ~vr)) + (alter-meta! (var ~n) merge (dissoc (meta ~vr) :name)) + (link-vars ~vr (var ~n)) + ~vr))))) + +#?(:clj + (defmacro import-macro + "Given a macro in another namespace, defines a macro with the same name in + the current namespace. Argument lists, doc-strings, and original line-numbers + are preserved. + + NOTE that [[import-macro]] comes + from [`potemkin.namespaces`](https://github.com/clj-commons/potemkin/blob/master/src/potemkin/namespaces.clj); + we import it here to avoid importing the full library." + ([sym] + `(import-macro ~sym nil)) + ([sym name] + (let [vr (resolve sym) + m (meta vr) + n (or name (with-meta (:name m) {}))] + (when-not vr + (throw (IllegalArgumentException. (str "Don't recognize " sym)))) + (when-not (:macro m) + (throw (IllegalArgumentException. + (str "Calling import-macro on a non-macro: " sym)))) + `(do + (def ~n ~(resolve sym)) + (alter-meta! (var ~n) merge (dissoc (meta ~vr) :name)) + (.setMacro (var ~n)) + (link-vars ~vr (var ~n)) + ~vr))))) + (defmacro import-def "Given a regular def'd var from another namespace, defined a new var with the same name in the current namespace. - This macro is modeled after `potemkin.namespaces/import-def` but meant to be - usable from Clojurescript. In Clojurescript, it's not possible to: + NOTE that this macro is taken + from [`potemkin.namespaces/import-def`](https://github.com/clj-commons/potemkin/blob/master/src/potemkin/namespaces.clj) + with an additional internal branch for ClojureScript support. but meant to be + usable from ClojureScript. In ClojureScript, it's not possible to: - alter the metadata of a var after definition - call `resolve` at macro-time @@ -88,16 +162,34 @@ ([sym] `(import-def ~sym nil)) ([sym var-name] - (let [n (or var-name (symbol (name sym)))] - `(def ~n ~sym)))) + (fork + :cljs + (let [n (or var-name (symbol (name sym)))] + `(def ~n ~sym)) + + :clj + (let [vr (resolve sym) + m (meta vr) + n (or var-name (:name m)) + n (with-meta n (if (:dynamic m) {:dynamic true} {}))] + (when-not vr + (throw (IllegalArgumentException. (str "Don't recognize " sym)))) + `(do + (def ~n @~vr) + (alter-meta! (var ~n) merge (dissoc (meta ~vr) :name)) + (link-vars ~vr (var ~n)) + ~vr))))) (defmacro import-vars "import multiple defs from multiple namespaces. works for vars and fns. not macros. - [[import-vars]] has the same syntax as `potemkin.namespaces/import-vars`: + NOTE that [[import-vars]] is a copy + of [`potemkin.namespaces/import-vars`](https://github.com/clj-commons/potemkin/blob/master/src/potemkin/namespaces.clj), + with an additional fork for ClojureScript support. The syntax is the same as + Potemkin's macro: - ```clojure + ```clj (import-vars [m.n.ns1 a b] [x.y.ns2 d e f]) => @@ -108,12 +200,40 @@ ... etc ```" [& imports] - (let [expanded-imports (for [[from-ns & defs] imports - d defs - :let [sym (symbol (str from-ns) - (str d))]] - `(def ~d ~sym))] - `(do ~@expanded-imports))) + (fork + :cljs + (let [expanded-imports (for [[from-ns & defs] imports + d defs + :let [sym (symbol (str from-ns) + (str d))]] + `(def ~d ~sym))] + `(do ~@expanded-imports)) + + :clj + (let [unravel (fn unravel [x] + (if (sequential? x) + (->> x + rest + (mapcat unravel) + (map + #(symbol + (str (first x) + (when-let [n (namespace %)] + (str "." n))) + (name %)))) + [x])) + imports (mapcat unravel imports)] + `(do + ~@(map + (fn [sym] + (let [vr (resolve sym) + m (meta vr)] + (cond + (nil? vr) `(throw (ex-info (format "`%s` does not exist" '~sym) {})) + (:macro m) `(import-macro ~sym) + (:arglists m) `(import-fn ~sym) + :else `(import-def ~sym)))) + imports))))) #_{:clj-kondo/ignore [:redundant-fn-wrapper]} (defn careful-def @@ -129,7 +249,7 @@ `clojure.core`. Symbols bound with `def` that are already imported from other namespaces cause an exception, hence this more careful workaround. - (In Clojurescript, only forms like `(def ~sym ~form)` are emitted, since the + (In ClojureScript, only forms like `(def ~sym ~form)` are emitted, since the compiler does not currently error in case 2 and already handles emitting the warning for us.)" [#?(:clj ns :cljs _)] diff --git a/src/sicmutils/value.cljc b/src/sicmutils/value.cljc index 8b6a87382..a067470d8 100644 --- a/src/sicmutils/value.cljc +++ b/src/sicmutils/value.cljc @@ -385,7 +385,7 @@ :else (throw (js/Error. (str "Cannot compare " this " to " o)))))))) #?(:cljs - ;; Clojurescript-specific implementations of Value. + ;; ClojureScript-specific implementations of Value. (let [big-zero (js/BigInt 0) big-one (js/BigInt 1)] diff --git a/test/pattern/match_test.cljc b/test/pattern/match_test.cljc index dcfacc588..9119f208b 100644 --- a/test/pattern/match_test.cljc +++ b/test/pattern/match_test.cljc @@ -86,7 +86,7 @@ (testing "bind with constraint" (is (= {:x 6} ((m/bind :x integer?) {} 6 identity))) - ;; Clojurescript treats floats with no mantissa as integers. + ;; ClojureScript treats floats with no mantissa as integers. (let [expected #?(:clj nil :cljs {:x 6.0})] (is (= expected ((m/bind :x integer?) {} 6.0 identity)))) diff --git a/test/sicmutils/complex_test.cljc b/test/sicmutils/complex_test.cljc index 135fac631..c9c8b9b03 100644 --- a/test/sicmutils/complex_test.cljc +++ b/test/sicmutils/complex_test.cljc @@ -21,7 +21,7 @@ (testing "parse-complex can round-trip Complex instances. These show up as code snippets when you call `read-string` directly, and aren't evaluated into Clojure. The fork in the test here captures the different behavior that will - appear in evaluated Clojure, vs self-hosted Clojurescript." + appear in evaluated Clojure, vs self-hosted ClojureScript." (is (= #?(:clj '(sicmutils.complex/complex 1.0 2.0) :cljs '(sicmutils.complex/complex 1 2)) diff --git a/test/sicmutils/differential_test.cljc b/test/sicmutils/differential_test.cljc index da6fc06b2..bc52cd9ca 100644 --- a/test/sicmutils/differential_test.cljc +++ b/test/sicmutils/differential_test.cljc @@ -253,7 +253,7 @@ (deftest differential-fn-tests (testing "differentials can take branches inside functions, PROVIDED (with clojure.core/=) the perturbed variable is on the - left! (Clojurescript can handle equals on either side.)" + left! (ClojureScript can handle equals on either side.)" (let [f (fn [x] (let [g (if #?(:clj (= x 10) :cljs (= 10 x)) (g/* x g/square) diff --git a/test/sicmutils/env_test.cljc b/test/sicmutils/env_test.cljc index 304f88f96..99ccd7345 100644 --- a/test/sicmutils/env_test.cljc +++ b/test/sicmutils/env_test.cljc @@ -49,7 +49,7 @@ (is (= [] (ref [])))) :clj - ;; Clojurescript doesn't have refs. + ;; ClojureScript doesn't have refs. (testing "works clojure-style" (let [r (ref []) s (ref {} :meta {:a "apple"})] diff --git a/test/sicmutils/examples/double_pendulum_test.cljc b/test/sicmutils/examples/double_pendulum_test.cljc index ab1b2bf67..6d73557fd 100644 --- a/test/sicmutils/examples/double_pendulum_test.cljc +++ b/test/sicmutils/examples/double_pendulum_test.cljc @@ -107,7 +107,7 @@ #?(:clj ;; even with the deterministic flag, this is not quite reproducing in - ;; Clojurescript. + ;; ClojureScript. (is (= (str "function(theta, psi, p_theta, p_psi) {\n" " var _0004 = - theta;\n" " var _000d = Math.pow(l_1, 2);\n" From 3d965645d0fde33ef33de5bd6188f9d21235b686 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Sat, 21 Jan 2023 16:21:40 -0700 Subject: [PATCH 2/6] move examples --- deps.edn | 6 +++--- {src => test}/sicmutils/examples/central_potential.cljc | 0 {src => test}/sicmutils/examples/double_pendulum.cljc | 0 {src => test}/sicmutils/examples/driven_pendulum.cljc | 0 {src => test}/sicmutils/examples/pendulum.cljc | 0 {src => test}/sicmutils/examples/rigid_rotation.cljc | 0 {src => test}/sicmutils/examples/top.cljc | 0 7 files changed, 3 insertions(+), 3 deletions(-) rename {src => test}/sicmutils/examples/central_potential.cljc (100%) rename {src => test}/sicmutils/examples/double_pendulum.cljc (100%) rename {src => test}/sicmutils/examples/driven_pendulum.cljc (100%) rename {src => test}/sicmutils/examples/pendulum.cljc (100%) rename {src => test}/sicmutils/examples/rigid_rotation.cljc (100%) rename {src => test}/sicmutils/examples/top.cljc (100%) diff --git a/deps.edn b/deps.edn index 261776a9c..d5fc8d50a 100644 --- a/deps.edn +++ b/deps.edn @@ -6,7 +6,6 @@ org.clojure/math.numeric-tower {:mvn/version "0.0.4"} com.taoensso/timbre {:mvn/version "6.0.4"} dm3/stopwatch {:mvn/version "0.1.1" :exclusions [org.clojure/clojurescript]} - hiccup/hiccup {:mvn/version "1.0.5"} org.apache.commons/commons-math3 {:mvn/version "3.6.1"} org.babashka/sci {:mvn/version "0.6.37"}} @@ -34,13 +33,14 @@ ;; dependencies needed to run the tests. {:extra-paths ["test"] :extra-deps - {io.github.cognitect-labs/test-runner + {com.gfredericks/test.chuck {:mvn/version "0.2.13"} + io.github.cognitect-labs/test-runner {:git/tag "v0.5.0" :git/sha "b3fd0d2"} io.github.nextjournal/clerk {:git/sha "d08c26043efe19a92fe33dd9eb4499e304e4cff7"} org.clojure/test.check {:mvn/version "1.1.1"} - com.gfredericks/test.chuck {:mvn/version "0.2.13"} + hiccup/hiccup {:mvn/version "1.0.5"} same/ish {:mvn/version "0.1.4"}}} :build diff --git a/src/sicmutils/examples/central_potential.cljc b/test/sicmutils/examples/central_potential.cljc similarity index 100% rename from src/sicmutils/examples/central_potential.cljc rename to test/sicmutils/examples/central_potential.cljc diff --git a/src/sicmutils/examples/double_pendulum.cljc b/test/sicmutils/examples/double_pendulum.cljc similarity index 100% rename from src/sicmutils/examples/double_pendulum.cljc rename to test/sicmutils/examples/double_pendulum.cljc diff --git a/src/sicmutils/examples/driven_pendulum.cljc b/test/sicmutils/examples/driven_pendulum.cljc similarity index 100% rename from src/sicmutils/examples/driven_pendulum.cljc rename to test/sicmutils/examples/driven_pendulum.cljc diff --git a/src/sicmutils/examples/pendulum.cljc b/test/sicmutils/examples/pendulum.cljc similarity index 100% rename from src/sicmutils/examples/pendulum.cljc rename to test/sicmutils/examples/pendulum.cljc diff --git a/src/sicmutils/examples/rigid_rotation.cljc b/test/sicmutils/examples/rigid_rotation.cljc similarity index 100% rename from src/sicmutils/examples/rigid_rotation.cljc rename to test/sicmutils/examples/rigid_rotation.cljc diff --git a/src/sicmutils/examples/top.cljc b/test/sicmutils/examples/top.cljc similarity index 100% rename from src/sicmutils/examples/top.cljc rename to test/sicmutils/examples/top.cljc From a28488a34f8bf6bc5c94099987dfe2848efa73e5 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Sat, 21 Jan 2023 21:11:54 -0700 Subject: [PATCH 3/6] fix potemkin --- .github/workflows/cljs.yaml | 2 +- deps.edn | 2 +- doc/contributing.adoc | 2 +- src/sicmutils/util/def.cljc | 53 +++++++++---------- test/pattern/match_test.cljc | 3 +- test/pattern/rule_test.cljc | 3 +- test/sicmutils/abstract/function_test.cljc | 3 +- test/sicmutils/abstract/number_test.cljc | 3 +- test/sicmutils/algebra/fold_test.cljc | 3 +- test/sicmutils/calculus/manifold_test.cljc | 3 +- test/sicmutils/collection_test.cljc | 3 +- test/sicmutils/complex_test.cljc | 3 +- test/sicmutils/differential_test.cljc | 3 +- test/sicmutils/expression_test.cljc | 3 +- test/sicmutils/function_test.cljc | 3 +- test/sicmutils/generic_test.cljc | 3 +- test/sicmutils/laws.cljc | 3 +- test/sicmutils/matrix_test.cljc | 3 +- test/sicmutils/mechanics/hamilton_test.cljc | 3 +- test/sicmutils/mechanics/lagrange_test.cljc | 3 +- test/sicmutils/modint_test.cljc | 3 +- test/sicmutils/numbers_test.cljc | 3 +- .../numerical/unimin/bracket_test.cljc | 3 +- .../numerical/unimin/brent_test.cljc | 3 +- .../numerical/unimin/golden_test.cljc | 3 +- test/sicmutils/operator_test.cljc | 3 +- test/sicmutils/polynomial/exponent_test.cljc | 3 +- test/sicmutils/polynomial/gcd_test.cljc | 3 +- test/sicmutils/polynomial_test.cljc | 3 +- test/sicmutils/quaternion_test.cljc | 3 +- test/sicmutils/ratio_test.cljc | 3 +- test/sicmutils/rational_function_test.cljc | 3 +- test/sicmutils/series_test.cljc | 3 +- test/sicmutils/special/elliptic_test.cljc | 3 +- test/sicmutils/special/factorial_test.cljc | 3 +- test/sicmutils/sr/boost_test.cljc | 3 +- test/sicmutils/structure_test.cljc | 3 +- test/sicmutils/util/aggregate_test.cljc | 3 +- test/sicmutils/util/permute_test.cljc | 3 +- test/sicmutils/util/stream_test.cljc | 3 +- test/sicmutils/util/vector_set_test.cljc | 3 +- test/sicmutils/util_test.cljc | 3 +- test/sicmutils/value_test.cljc | 3 +- 43 files changed, 67 insertions(+), 109 deletions(-) diff --git a/.github/workflows/cljs.yaml b/.github/workflows/cljs.yaml index 7acb07415..6bf2ec141 100644 --- a/.github/workflows/cljs.yaml +++ b/.github/workflows/cljs.yaml @@ -37,6 +37,6 @@ jobs: run: npm install - name: ClojureScript tests - run: npm run-script test + run: npm run test env: NODE_OPTIONS: --max-old-space-size=8192 diff --git a/deps.edn b/deps.edn index d5fc8d50a..92eefec9c 100644 --- a/deps.edn +++ b/deps.edn @@ -33,7 +33,7 @@ ;; dependencies needed to run the tests. {:extra-paths ["test"] :extra-deps - {com.gfredericks/test.chuck {:mvn/version "0.2.13"} + {com.gfredericks/test.chuck {:mvn/version "0.2.14"} io.github.cognitect-labs/test-runner {:git/tag "v0.5.0" :git/sha "b3fd0d2"} diff --git a/doc/contributing.adoc b/doc/contributing.adoc index bb96bfa35..d01adc309 100644 --- a/doc/contributing.adoc +++ b/doc/contributing.adoc @@ -64,7 +64,7 @@ sure to note any warnings): [source, bash] ---- -npm run-script test +npm run test ---- The following command will start a process that recompiles the project when any diff --git a/src/sicmutils/util/def.cljc b/src/sicmutils/util/def.cljc index 27b30a15c..6fd189621 100644 --- a/src/sicmutils/util/def.cljc +++ b/src/sicmutils/util/def.cljc @@ -102,17 +102,14 @@ (let [vr (resolve sym) m (meta vr) n (or name (:name m)) - arglists (:arglists m) protocol (:protocol m)] (when-not vr (throw (IllegalArgumentException. (str "Don't recognize " sym)))) (when (:macro m) (throw (IllegalArgumentException. (str "Calling import-fn on a macro: " sym)))) - `(do - (def ~(with-meta n {:arglists arglists - :protocol protocol}) + (def ~(with-meta n {:protocol protocol}) (deref ~vr)) (alter-meta! (var ~n) merge (dissoc (meta ~vr) :name)) (link-vars ~vr (var ~n)) @@ -210,30 +207,30 @@ `(do ~@expanded-imports)) :clj - (let [unravel (fn unravel [x] - (if (sequential? x) - (->> x - rest - (mapcat unravel) - (map - #(symbol - (str (first x) - (when-let [n (namespace %)] - (str "." n))) - (name %)))) - [x])) - imports (mapcat unravel imports)] - `(do - ~@(map - (fn [sym] - (let [vr (resolve sym) - m (meta vr)] - (cond - (nil? vr) `(throw (ex-info (format "`%s` does not exist" '~sym) {})) - (:macro m) `(import-macro ~sym) - (:arglists m) `(import-fn ~sym) - :else `(import-def ~sym)))) - imports))))) + (letfn [(unravel [x] + (if (sequential? x) + (->> x + rest + (mapcat unravel) + (map + #(symbol + (str (first x) + (when-let [n (namespace %)] + (str "." n))) + (name %)))) + [x]))] + (let [imports (mapcat unravel imports)] + `(do + ~@(map + (fn [sym] + (let [vr (resolve sym) + m (meta vr)] + (cond + (nil? vr) `(throw (ex-info (format "`%s` does not exist" '~sym) {})) + (:macro m) `(import-macro ~sym) + (:arglists m) `(import-fn ~sym) + :else `(import-def ~sym)))) + imports)))))) #_{:clj-kondo/ignore [:redundant-fn-wrapper]} (defn careful-def diff --git a/test/pattern/match_test.cljc b/test/pattern/match_test.cljc index 9119f208b..753b41fb8 100644 --- a/test/pattern/match_test.cljc +++ b/test/pattern/match_test.cljc @@ -3,8 +3,7 @@ (ns pattern.match-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test - :refer [checking] :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [pattern.match :as m] [pattern.syntax :as ps])) diff --git a/test/pattern/rule_test.cljc b/test/pattern/rule_test.cljc index 3afd0f7e4..db6591294 100644 --- a/test/pattern/rule_test.cljc +++ b/test/pattern/rule_test.cljc @@ -3,8 +3,7 @@ (ns pattern.rule-test (:require [clojure.test :as t :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test - :refer [checking] :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [pattern.match :as m] [pattern.rule :as r :refer [=> !=>]] [sicmutils.ratio])) diff --git a/test/sicmutils/abstract/function_test.cljc b/test/sicmutils/abstract/function_test.cljc index b2ae0f172..476dfd6e0 100644 --- a/test/sicmutils/abstract/function_test.cljc +++ b/test/sicmutils/abstract/function_test.cljc @@ -4,8 +4,7 @@ (:refer-clojure :exclude [partial =]) (:require [clojure.test :refer [is deftest testing use-fixtures]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test - :refer [checking] :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [sicmutils.abstract.function :as af] [sicmutils.calculus.derivative :refer [D partial]] [sicmutils.generators :as sg] diff --git a/test/sicmutils/abstract/number_test.cljc b/test/sicmutils/abstract/number_test.cljc index 95c6ad9bb..f0413df87 100644 --- a/test/sicmutils/abstract/number_test.cljc +++ b/test/sicmutils/abstract/number_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.abstract.number-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test - :refer [checking] :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [pattern.rule :as rule :refer [=>]] [same :refer [ish?]] [sicmutils.abstract.number :as an] diff --git a/test/sicmutils/algebra/fold_test.cljc b/test/sicmutils/algebra/fold_test.cljc index f4d8df81f..93e440eec 100644 --- a/test/sicmutils/algebra/fold_test.cljc +++ b/test/sicmutils/algebra/fold_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.algebra.fold-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test - :refer [checking] :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [sicmutils.algebra.fold :as af] [sicmutils.numbers])) diff --git a/test/sicmutils/calculus/manifold_test.cljc b/test/sicmutils/calculus/manifold_test.cljc index a93f96a39..a26abb00d 100644 --- a/test/sicmutils/calculus/manifold_test.cljc +++ b/test/sicmutils/calculus/manifold_test.cljc @@ -5,8 +5,7 @@ (:require [clojure.string :as cs] [clojure.test :refer [is deftest testing use-fixtures]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test - :refer [checking] :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish?]] [sicmutils.abstract.number :refer [literal-number]] [sicmutils.calculus.manifold :as m] diff --git a/test/sicmutils/collection_test.cljc b/test/sicmutils/collection_test.cljc index 208defc58..c452974da 100644 --- a/test/sicmutils/collection_test.cljc +++ b/test/sicmutils/collection_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.collection-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test - :refer [checking] :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish?]] [sicmutils.calculus.derivative :refer [D]] [sicmutils.collection :as collection] diff --git a/test/sicmutils/complex_test.cljc b/test/sicmutils/complex_test.cljc index c9c8b9b03..bc6567abc 100644 --- a/test/sicmutils/complex_test.cljc +++ b/test/sicmutils/complex_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.complex-test (:require [clojure.test :refer [is deftest testing]] #?(:cljs [cljs.reader :refer [read-string]]) - [com.gfredericks.test.chuck.clojure-test - :refer [checking] :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish? with-comparator] :include-macros true] [sicmutils.complex :as c] [sicmutils.generators :as sg] diff --git a/test/sicmutils/differential_test.cljc b/test/sicmutils/differential_test.cljc index bc52cd9ca..f1c34f999 100644 --- a/test/sicmutils/differential_test.cljc +++ b/test/sicmutils/differential_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.differential-test (:require [clojure.test :refer [is deftest testing use-fixtures]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish? with-comparator] :include-macros true] [sicmutils.differential :as d] [sicmutils.generators :as sg] diff --git a/test/sicmutils/expression_test.cljc b/test/sicmutils/expression_test.cljc index b31a57d99..33831dc9c 100644 --- a/test/sicmutils/expression_test.cljc +++ b/test/sicmutils/expression_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.expression-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test - :refer [checking] :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [sicmutils.abstract.number :as an] [sicmutils.expression :as e] [sicmutils.generic :as g] diff --git a/test/sicmutils/function_test.cljc b/test/sicmutils/function_test.cljc index dc086489c..3933c3818 100644 --- a/test/sicmutils/function_test.cljc +++ b/test/sicmutils/function_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.function-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test - :refer [checking] :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish? with-comparator] :include-macros true] [sicmutils.function :as f] [sicmutils.generators :as sg] diff --git a/test/sicmutils/generic_test.cljc b/test/sicmutils/generic_test.cljc index 8ddf3ff88..3842c1702 100644 --- a/test/sicmutils/generic_test.cljc +++ b/test/sicmutils/generic_test.cljc @@ -4,8 +4,7 @@ (:refer-clojure :exclude [+ - * / zero?]) (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test - :refer [checking] :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [sicmutils.generic :as g] [sicmutils.value :as v])) diff --git a/test/sicmutils/laws.cljc b/test/sicmutils/laws.cljc index 8a359747e..e633a9504 100644 --- a/test/sicmutils/laws.cljc +++ b/test/sicmutils/laws.cljc @@ -5,8 +5,7 @@ that implement the sicmutils.generic operations, and the additive and multiplicative options in sicmutils.value.Value." (:require [clojure.test :refer [is]] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish?]] [sicmutils.generic :as g] [sicmutils.value :as v])) diff --git a/test/sicmutils/matrix_test.cljc b/test/sicmutils/matrix_test.cljc index 4e49ab3bd..71dee096c 100644 --- a/test/sicmutils/matrix_test.cljc +++ b/test/sicmutils/matrix_test.cljc @@ -5,8 +5,7 @@ [clojure.test.check.clojure-test :as ct :refer [defspec]] [clojure.test.check.generators :as gen] [clojure.test.check.properties :as prop] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish?]] [sicmutils.function :as f] [sicmutils.generators :as sg] diff --git a/test/sicmutils/mechanics/hamilton_test.cljc b/test/sicmutils/mechanics/hamilton_test.cljc index dece8e576..23fc48b46 100644 --- a/test/sicmutils/mechanics/hamilton_test.cljc +++ b/test/sicmutils/mechanics/hamilton_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.mechanics.hamilton-test (:refer-clojure :exclude [+ - * / partial]) (:require [clojure.test :refer [is deftest testing use-fixtures]] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [sicmutils.abstract.function :as f] [sicmutils.calculus.derivative :refer [D]] [sicmutils.generators :as sg] diff --git a/test/sicmutils/mechanics/lagrange_test.cljc b/test/sicmutils/mechanics/lagrange_test.cljc index d28e66b45..41d80d161 100644 --- a/test/sicmutils/mechanics/lagrange_test.cljc +++ b/test/sicmutils/mechanics/lagrange_test.cljc @@ -4,8 +4,7 @@ (:refer-clojure :exclude [partial + - * /]) (:require [clojure.test :refer [is deftest testing use-fixtures]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish?] :include-macros true] [sicmutils.abstract.function :as f] [sicmutils.calculus.derivative :refer [D partial]] diff --git a/test/sicmutils/modint_test.cljc b/test/sicmutils/modint_test.cljc index 903f5b54f..ac61358b5 100644 --- a/test/sicmutils/modint_test.cljc +++ b/test/sicmutils/modint_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.modint-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [sicmutils.generators :as sg] [sicmutils.generic :as g] [sicmutils.modint :as m] diff --git a/test/sicmutils/numbers_test.cljc b/test/sicmutils/numbers_test.cljc index e1ad4f59a..e724ede56 100644 --- a/test/sicmutils/numbers_test.cljc +++ b/test/sicmutils/numbers_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.numbers-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish? with-comparator] :include-macros true] [sicmutils.complex :as c] [sicmutils.generators :as sg] diff --git a/test/sicmutils/numerical/unimin/bracket_test.cljc b/test/sicmutils/numerical/unimin/bracket_test.cljc index 02e2bc783..1356a483f 100644 --- a/test/sicmutils/numerical/unimin/bracket_test.cljc +++ b/test/sicmutils/numerical/unimin/bracket_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.numerical.unimin.bracket-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish? with-comparator] :include-macros true] [sicmutils.calculus.derivative :refer [D]] [sicmutils.function] diff --git a/test/sicmutils/numerical/unimin/brent_test.cljc b/test/sicmutils/numerical/unimin/brent_test.cljc index 4bf9262c6..7c08ef0b7 100644 --- a/test/sicmutils/numerical/unimin/brent_test.cljc +++ b/test/sicmutils/numerical/unimin/brent_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.numerical.unimin.brent-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish? zeroish? with-comparator] :include-macros true] [sicmutils.calculus.derivative :refer [D]] [sicmutils.generic :as g] diff --git a/test/sicmutils/numerical/unimin/golden_test.cljc b/test/sicmutils/numerical/unimin/golden_test.cljc index 3b57ff350..53ea3aef0 100644 --- a/test/sicmutils/numerical/unimin/golden_test.cljc +++ b/test/sicmutils/numerical/unimin/golden_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.numerical.unimin.golden-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish? zeroish? with-comparator] :include-macros true] [sicmutils.generic :as g] [sicmutils.numerical.unimin.bracket :as b] diff --git a/test/sicmutils/operator_test.cljc b/test/sicmutils/operator_test.cljc index 07f0cb927..782d770a9 100644 --- a/test/sicmutils/operator_test.cljc +++ b/test/sicmutils/operator_test.cljc @@ -4,8 +4,7 @@ (:refer-clojure :exclude [+ - * / partial]) (:require [clojure.test :refer [is deftest testing use-fixtures]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish?]] [sicmutils.abstract.function :as f] [sicmutils.calculus.derivative :refer [D partial]] diff --git a/test/sicmutils/polynomial/exponent_test.cljc b/test/sicmutils/polynomial/exponent_test.cljc index 07aade503..d3e917dda 100644 --- a/test/sicmutils/polynomial/exponent_test.cljc +++ b/test/sicmutils/polynomial/exponent_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.polynomial.exponent-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [sicmutils.generators :as sg] [sicmutils.polynomial.exponent :as xpt])) diff --git a/test/sicmutils/polynomial/gcd_test.cljc b/test/sicmutils/polynomial/gcd_test.cljc index 238e0c69f..ef4aa39ab 100644 --- a/test/sicmutils/polynomial/gcd_test.cljc +++ b/test/sicmutils/polynomial/gcd_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.polynomial.gcd-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [sicmutils.generators :as sg] [sicmutils.generic :as g] [sicmutils.modint :as mi] diff --git a/test/sicmutils/polynomial_test.cljc b/test/sicmutils/polynomial_test.cljc index 132afb2a0..d9b11d1a9 100644 --- a/test/sicmutils/polynomial_test.cljc +++ b/test/sicmutils/polynomial_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.polynomial-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish?] :include-macros true] [sicmutils.abstract.number :as an] [sicmutils.calculus.derivative :refer [D]] diff --git a/test/sicmutils/quaternion_test.cljc b/test/sicmutils/quaternion_test.cljc index bf9a23d85..c2b868de1 100644 --- a/test/sicmutils/quaternion_test.cljc +++ b/test/sicmutils/quaternion_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.quaternion-test (:require [clojure.test :refer [is deftest testing use-fixtures]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish? with-comparator] :include-macros true] [sicmutils.calculus.derivative :refer [D]] [sicmutils.complex :as sc] diff --git a/test/sicmutils/ratio_test.cljc b/test/sicmutils/ratio_test.cljc index 957cb6e52..3b64f7081 100644 --- a/test/sicmutils/ratio_test.cljc +++ b/test/sicmutils/ratio_test.cljc @@ -4,8 +4,7 @@ (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] #?(:cljs [cljs.reader :refer [read-string]]) - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish?]] [sicmutils.generators :as sg] [sicmutils.generic :as g] diff --git a/test/sicmutils/rational_function_test.cljc b/test/sicmutils/rational_function_test.cljc index 7c0a22c48..aac4d60f5 100644 --- a/test/sicmutils/rational_function_test.cljc +++ b/test/sicmutils/rational_function_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.rational-function-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [sicmutils.abstract.number :as an] [sicmutils.calculus.derivative :as deriv :refer [D]] [sicmutils.complex :as c] diff --git a/test/sicmutils/series_test.cljc b/test/sicmutils/series_test.cljc index 1fa2f8664..98227f8d0 100644 --- a/test/sicmutils/series_test.cljc +++ b/test/sicmutils/series_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.series-test (:require [clojure.test :refer [is deftest testing use-fixtures]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish? with-comparator] :include-macros true] [sicmutils.calculus.derivative] [sicmutils.function :as f] diff --git a/test/sicmutils/special/elliptic_test.cljc b/test/sicmutils/special/elliptic_test.cljc index 7b31d7886..923e6d8e9 100644 --- a/test/sicmutils/special/elliptic_test.cljc +++ b/test/sicmutils/special/elliptic_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.special.elliptic-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish? with-comparator] :include-macros true] [sicmutils.generators :as sg] [sicmutils.generic :as g] diff --git a/test/sicmutils/special/factorial_test.cljc b/test/sicmutils/special/factorial_test.cljc index 97dcb536c..3614dae28 100644 --- a/test/sicmutils/special/factorial_test.cljc +++ b/test/sicmutils/special/factorial_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.special.factorial-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [sicmutils.generic :as g] [sicmutils.polynomial :as poly] [sicmutils.series :as series] diff --git a/test/sicmutils/sr/boost_test.cljc b/test/sicmutils/sr/boost_test.cljc index 96c3d8217..d4bfc8233 100644 --- a/test/sicmutils/sr/boost_test.cljc +++ b/test/sicmutils/sr/boost_test.cljc @@ -4,8 +4,7 @@ (:refer-clojure :exclude [+ - * /]) (:require [clojure.test :refer [is deftest testing use-fixtures]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [sicmutils.function :as f] [sicmutils.generators :as sg] [sicmutils.generic :as g :refer [-]] diff --git a/test/sicmutils/structure_test.cljc b/test/sicmutils/structure_test.cljc index abe90561a..69433b285 100644 --- a/test/sicmutils/structure_test.cljc +++ b/test/sicmutils/structure_test.cljc @@ -4,8 +4,7 @@ (:refer-clojure :exclude [+ - * /]) (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [pattern.match :as pm] [same :refer [ish? with-comparator] :include-macros true] [sicmutils.abstract.number] diff --git a/test/sicmutils/util/aggregate_test.cljc b/test/sicmutils/util/aggregate_test.cljc index a0767e7a4..2bc16f6cd 100644 --- a/test/sicmutils/util/aggregate_test.cljc +++ b/test/sicmutils/util/aggregate_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.util.aggregate-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [sicmutils.algebra.fold :as af] [sicmutils.numbers] [sicmutils.util.aggregate :as ua])) diff --git a/test/sicmutils/util/permute_test.cljc b/test/sicmutils/util/permute_test.cljc index f57c7711f..dc873007c 100644 --- a/test/sicmutils/util/permute_test.cljc +++ b/test/sicmutils/util/permute_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.util.permute-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test :refer [checking] - :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [sicmutils.generic :as g] [sicmutils.util.permute :as p])) diff --git a/test/sicmutils/util/stream_test.cljc b/test/sicmutils/util/stream_test.cljc index f703b6fb6..f85c61fab 100644 --- a/test/sicmutils/util/stream_test.cljc +++ b/test/sicmutils/util/stream_test.cljc @@ -5,8 +5,7 @@ library." (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test - :refer [checking] :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [same :refer [ish?] :include-macros true] [sicmutils.generators :as sg] [sicmutils.generic :as g] diff --git a/test/sicmutils/util/vector_set_test.cljc b/test/sicmutils/util/vector_set_test.cljc index 3c72b44df..58a0d9bfa 100644 --- a/test/sicmutils/util/vector_set_test.cljc +++ b/test/sicmutils/util/vector_set_test.cljc @@ -4,8 +4,7 @@ (:require [clojure.set :as cs] [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test - :refer [checking] :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [sicmutils.generators :as sg] [sicmutils.util.vector-set :as vs])) diff --git a/test/sicmutils/util_test.cljc b/test/sicmutils/util_test.cljc index e64285be0..b62493698 100644 --- a/test/sicmutils/util_test.cljc +++ b/test/sicmutils/util_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.util-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test - :refer [checking] :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] [sicmutils.util :as u])) (deftest dict-tests diff --git a/test/sicmutils/value_test.cljc b/test/sicmutils/value_test.cljc index e3d105bc8..1a4bda57f 100644 --- a/test/sicmutils/value_test.cljc +++ b/test/sicmutils/value_test.cljc @@ -3,8 +3,7 @@ (ns sicmutils.value-test (:require [clojure.test :refer [is deftest testing]] [clojure.test.check.generators :as gen] - [com.gfredericks.test.chuck.clojure-test - :refer [checking] :include-macros true] + [com.gfredericks.test.chuck.clojure-test :refer [checking]] #?(:cljs [cljs.reader :refer [read-string]]) [sicmutils.generators :as sg] [sicmutils.util :as u] From 6548a38ec4511cd606f7d149ba1a3bf9621265a4 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Sat, 21 Jan 2023 21:24:00 -0700 Subject: [PATCH 4/6] fix --- test/sicmutils/env/sci_test.cljc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sicmutils/env/sci_test.cljc b/test/sicmutils/env/sci_test.cljc index 323fcefc9..8d2b73969 100644 --- a/test/sicmutils/env/sci_test.cljc +++ b/test/sicmutils/env/sci_test.cljc @@ -71,7 +71,7 @@ (testing "sci-specific macro definitions" (is (= 2.0 (eval '(do (require '[sicmutils.algebra.fold :as af]) - (let [sum (af/fold->sum-fn (kbk-n 2))] + (let [sum (af/fold->sum-fn (af/kbk-n 2))] (sum [1.0 1e100 1.0 -1e100]))))) "compensated summation with a macro inside SCI") From 230218fc11c004063338a5987a8be923be51afb8 Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Sat, 21 Jan 2023 21:33:21 -0700 Subject: [PATCH 5/6] add changelog --- CHANGELOG.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b73771a20..642977daf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,22 @@ ## unreleased +- #532: + + - Removes the `potemkin` dependency by importing only what we need directly + into `sicmutils.util.def`. This makes sense since our versions add a `fork` + call so that they work for ClojureScript as well. + + - Moves all `examples` into the tests so that we don't ship them with the + library. These will eventually be converted to Clerk notebooks. + + - Removes the `hiccup` dependency. + + - Upgrades `test.chuck` and removes all `:include-macros true` calls for that + library. Only `same/ish` requires them now! + + - Capitalizes the "Script" in ClojureScript everywhere it appears. + - #531: - Fixes a typo in one of the rules in From 3cb99ef6390e224d29b94b0b65ed43e0be65f3fd Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Sat, 21 Jan 2023 23:33:37 -0700 Subject: [PATCH 6/6] kill redundant import-fn --- .../sicmutils/sicmutils/config.edn | 1 - src/sicmutils/util/def.cljc | 50 +++++-------------- 2 files changed, 12 insertions(+), 39 deletions(-) diff --git a/resources/clj-kondo.exports/sicmutils/sicmutils/config.edn b/resources/clj-kondo.exports/sicmutils/sicmutils/config.edn index 7265fb24e..3d656b78d 100644 --- a/resources/clj-kondo.exports/sicmutils/sicmutils/config.edn +++ b/resources/clj-kondo.exports/sicmutils/sicmutils/config.edn @@ -46,7 +46,6 @@ hooks.sicmutils.abstract.function/with-literal-functions sicmutils.util.def/import-def hooks.sicmutils.util.def/import-def - sicmutils.util.def/import-fn hooks.sicmutils.util.def/import-def sicmutils.util.def/import-macro hooks.sicmutils.util.def/import-def pattern.rule/consequence hooks.pattern.rule/consequence diff --git a/src/sicmutils/util/def.cljc b/src/sicmutils/util/def.cljc index 6fd189621..d842e8e10 100644 --- a/src/sicmutils/util/def.cljc +++ b/src/sicmutils/util/def.cljc @@ -87,34 +87,6 @@ (alter-var-root dst (constantly @src)) (alter-meta! dst merge (dissoc (meta src) :name)))))) -#?(:clj - (defmacro import-fn - "Given a function in another namespace, defines a function with the same - name in the current namespace. Argument lists, doc-strings, and original - line-numbers are preserved. - - NOTE that [[import-fn]] comes - from [`potemkin.namespaces`](https://github.com/clj-commons/potemkin/blob/master/src/potemkin/namespaces.clj); - we import it here to avoid importing the full library." - ([sym] - `(import-fn ~sym nil)) - ([sym name] - (let [vr (resolve sym) - m (meta vr) - n (or name (:name m)) - protocol (:protocol m)] - (when-not vr - (throw (IllegalArgumentException. (str "Don't recognize " sym)))) - (when (:macro m) - (throw (IllegalArgumentException. - (str "Calling import-fn on a macro: " sym)))) - `(do - (def ~(with-meta n {:protocol protocol}) - (deref ~vr)) - (alter-meta! (var ~n) merge (dissoc (meta ~vr) :name)) - (link-vars ~vr (var ~n)) - ~vr))))) - #?(:clj (defmacro import-macro "Given a macro in another namespace, defines a macro with the same name in @@ -171,6 +143,9 @@ n (with-meta n (if (:dynamic m) {:dynamic true} {}))] (when-not vr (throw (IllegalArgumentException. (str "Don't recognize " sym)))) + (when (:macro m) + (throw (IllegalArgumentException. + (str "Calling import-def on a macro: " sym)))) `(do (def ~n @~vr) (alter-meta! (var ~n) merge (dissoc (meta ~vr) :name)) @@ -178,8 +153,8 @@ ~vr))))) (defmacro import-vars - "import multiple defs from multiple namespaces. works for vars and fns. not - macros. + "import multiple defs from multiple namespaces. works for vars and fns, macros + only work in Clojure. NOTE that [[import-vars]] is a copy of [`potemkin.namespaces/import-vars`](https://github.com/clj-commons/potemkin/blob/master/src/potemkin/namespaces.clj), @@ -199,12 +174,12 @@ [& imports] (fork :cljs - (let [expanded-imports (for [[from-ns & defs] imports - d defs - :let [sym (symbol (str from-ns) - (str d))]] - `(def ~d ~sym))] - `(do ~@expanded-imports)) + `(do + ~@(for [[from-ns & defs] imports + d defs + :let [sym (symbol (str from-ns) + (str d))]] + `(def ~d ~sym))) :clj (letfn [(unravel [x] @@ -224,11 +199,10 @@ ~@(map (fn [sym] (let [vr (resolve sym) - m (meta vr)] + m (meta vr)] (cond (nil? vr) `(throw (ex-info (format "`%s` does not exist" '~sym) {})) (:macro m) `(import-macro ~sym) - (:arglists m) `(import-fn ~sym) :else `(import-def ~sym)))) imports))))))