Skip to content

Add tests for partition#893

Open
dgr wants to merge 4 commits into
jank-lang:mainfrom
dgr:dgr-partition
Open

Add tests for partition#893
dgr wants to merge 4 commits into
jank-lang:mainfrom
dgr:dgr-partition

Conversation

@dgr
Copy link
Copy Markdown
Collaborator

@dgr dgr commented May 22, 2026

Closes #389

@dgr dgr requested review from E-A-Griffin and jeaye May 22, 2026 00:55
@jeaye jeaye requested a review from Copilot May 22, 2026 01:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new clojure.core/partition test namespace to cover expected behavior across its supported arities and validate laziness characteristics (issue #389).

Changes:

  • Introduces a new partition.cljc test file guarded by (when-var-exists partition ...).
  • Adds assertions for arities 2/3/4 including overlapping partitions, padding behavior, and empty/nil collection inputs.
  • Includes checks that the result is a lazy seq and initially unrealized.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/clojure/core_test/partition.cljc
Comment thread test/clojure/core_test/partition.cljc Outdated
Copy link
Copy Markdown
Member

@jeaye jeaye left a comment

Choose a reason for hiding this comment

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

Nice work!

Comment thread test/clojure/core_test/partition.cljc
Comment thread test/clojure/core_test/partition.cljc Outdated
(testing "arity 4 - (partition n step pad coll"
;; Use padding for the last element
(is (= '((0 1 2) (1 2 3) (2 3 4) (3 4 :a)) (partition 3 1 [:a :a :a] (range 5))))
(is (= '((0 1 2) (3 4 5) (6 7 8) (9 :a :a)) (partition 3 3 [:a :a :a] (range 10))))
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.

Potential test: What if pad collection is too small?

Potential test: What if pad collection is empty?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, added.

Comment thread test/clojure/core_test/partition.cljc Outdated
Comment thread test/clojure/core_test/partition.cljc
@dgr
Copy link
Copy Markdown
Collaborator Author

dgr commented May 23, 2026

I believe this is ready to merge.

@dgr dgr requested a review from jeaye May 23, 2026 17:05
@jeaye
Copy link
Copy Markdown
Member

jeaye commented May 23, 2026

I'm not convinced we want the TODO for the floating point value support, since I gather that the fn is intended to only accept integral values. CLJS just happens to support it since there's only one number type for JS.

I think we should remove the floating point case, and the TODO. Keeping the big integer case is good, though, since it's an integral type.

@E-A-Griffin
Copy link
Copy Markdown
Collaborator

I'm not convinced we want the TODO for the floating point value support, since I gather that the fn is intended to only accept integral values. CLJS just happens to support it since there's only one number type for JS.

I think we should remove the floating point case, and the TODO. Keeping the big integer case is good, though, since it's an integral type.

I think the test is good to keep but the TODO should be dropped as I don't think non CLJS are obligated to do any particular behavior with floats, that being said, I think CLJS' behavior is interesting and worth documenting here (could see this causing a real bug in the wild for someone)

Copy link
Copy Markdown
Collaborator

@E-A-Griffin E-A-Griffin left a comment

Choose a reason for hiding this comment

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

I think we should add a test for (partition 0 ...) akin to what's shown here: https://clojuredocs.org/clojure.core/partition#example-57aa75fae4b0bafd3e2a04d3

Copy link
Copy Markdown
Collaborator

@E-A-Griffin E-A-Griffin left a comment

Choose a reason for hiding this comment

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

Mostly looks good, left some optional suggestions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clojure.core/partition

4 participants