Skip to content

Add tests for repeatedly#878

Open
E-A-Griffin wants to merge 2 commits into
jank-lang:mainfrom
E-A-Griffin:egriffin/repeatedly
Open

Add tests for repeatedly#878
E-A-Griffin wants to merge 2 commits into
jank-lang:mainfrom
E-A-Griffin:egriffin/repeatedly

Conversation

@E-A-Griffin
Copy link
Copy Markdown
Collaborator

@E-A-Griffin E-A-Griffin commented May 13, 2026

Closes #456

@E-A-Griffin E-A-Griffin changed the title Repeatedly Add tests for repeatedly May 13, 2026
@jeaye jeaye requested review from Copilot and dgr May 13, 2026 00:59
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 core test namespace to cover clojure.core/repeatedly behavior across supported dialects, addressing Issue #456.

Changes:

  • Introduce clojure.core-test.repeatedly with tests for laziness, side effects, arity behavior, and error cases.
  • Gate the suite behind when-var-exists for portability across runtimes.

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

Comment thread test/clojure/core_test/repeatedly.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.

Thanks for the help, Emma!

Comment thread test/clojure/core_test/repeatedly.cljc Outdated
Comment on lines +19 to +20
(catch #?(:cljs :default
:default Exception) _ nil))
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.

This isn't going to work for some dialects, like jank. We have p/thrown? to handle exception details. Perhaps we can rework this test to use p/thrown?. If not, I think we should add a (p/exception) or similar, to get the base exception type for any given dialect.

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.

Yeah I think we should probably implement p/exception anyways, and I can make and take a cleanup issue for it

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yea, exceptions are difficult to deal with in Clojure dialects. This is one area where dialects should maybe try to come together, otherwise portable code is pretty much impossible. You basically just have to avoid anything throwing.

Comment thread test/clojure/core_test/repeatedly.cljc
Comment thread test/clojure/core_test/repeatedly.cljc Outdated
Copy link
Copy Markdown
Collaborator

@dgr dgr left a comment

Choose a reason for hiding this comment

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

Overall, looks good.

Comment thread test/clojure/core_test/repeatedly.cljc Outdated
Comment on lines +19 to +20
(catch #?(:cljs :default
:default Exception) _ nil))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yea, exceptions are difficult to deal with in Clojure dialects. This is one area where dialects should maybe try to come together, otherwise portable code is pretty much impossible. You basically just have to avoid anything throwing.

Comment thread test/clojure/core_test/repeatedly.cljc Outdated
Comment on lines +28 to +29
(testing "Single argument"
(is (= 0 (first (repeatedly +)))))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You might want to test the remainder of the seq for laziness.

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.

How would you recommend doing this?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think you generate an infinite seq ((range)) and then realize the first element and test that. If it doesn't throw, you're good to go. If it realizes the whole thing, then you'll get an OOM exception.

@E-A-Griffin
Copy link
Copy Markdown
Collaborator Author

Hm, I just went to https://cljs.io/ and tried 1/3 and it gave 0.333333. I then cross-referenced that with the differences from Clojure doc which says Ratio isn't supported.

So I used this to see that CLJS supports reading ratios, but doesn't have a ratio object and instead just reads them into floats.

When I ran it on the test suite locally I got an exception so I think the local CLJS we're using doesn't support it

@jeaye
Copy link
Copy Markdown
Member

jeaye commented May 15, 2026

Hm, I just went to https://cljs.io/ and tried 1/3 and it gave 0.333333. I then cross-referenced that with the differences from Clojure doc which says Ratio isn't supported.
So I used this to see that CLJS supports reading ratios, but doesn't have a ratio object and instead just reads them into floats.

When I ran it on the test suite locally I got an exception so I think the local CLJS we're using doesn't support it

Okie dokie! Let's not worry about it for now then.

@dgr
Copy link
Copy Markdown
Collaborator

dgr commented May 15, 2026

Hm, I just went to https://cljs.io/ and tried 1/3 and it gave 0.333333. I then cross-referenced that with the differences from Clojure doc which says Ratio isn't supported.
So I used this to see that CLJS supports reading ratios, but doesn't have a ratio object and instead just reads them into floats.

When I ran it on the test suite locally I got an exception so I think the local CLJS we're using doesn't support it

Okie dokie! Let's not worry about it for now then.

Maybe shoot a quick Slack message out to #cljs-dev.

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/repeatedly

4 participants