Skip to content

test(Dynamic): add missing tests for Dynamic and Dynamic.List#1504

Open
sqrew wants to merge 1 commit intocarp-lang:masterfrom
sqrew:stdlib-dynamic-list-tests
Open

test(Dynamic): add missing tests for Dynamic and Dynamic.List#1504
sqrew wants to merge 1 commit intocarp-lang:masterfrom
sqrew:stdlib-dynamic-list-tests

Conversation

@sqrew
Copy link
Copy Markdown
Contributor

@sqrew sqrew commented Mar 12, 2026

This PR fills the significant test coverage gap in the Dynamic and Dynamic.List modules.

Added Tests:

  • Core traversal: cxr, nthcdr, nthcar.
  • Collection ops: collect-into, empty?, reduce, unreduce, filter, reverse, empty, take.
  • Function application: apply, any?, all?, zip, map.
  • Structural ops: flatten, walk, postwalk, prewalk, walk-replace.
  • List-specific ops: List.pairs, List.nth, List.remove-nth, List.update-nth, List.set-nth, List.find, List.find-index.

Bug Fix:

  • Fixed an off-by-one error in Dynamic.nthcdr.

Verified locally with scripts/carp.sh -x test/list.carp.

Comment thread core/List.carp Outdated
(doc nthcdr "takes the `n`th tail or `cdr` of the list `pair`.")
(defndynamic nthcdr [n pair]
(cxr (list (+ n 1) 'd) pair))
(cxr (list n 'd) pair))
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 is not correct. nthcar and nthcdr are a symmetric pair. nthcar n and nthcdr n both go to position n, then take car/cdr.

Yes, this is different from how Common Lisp implements it.

@sqrew sqrew force-pushed the stdlib-dynamic-list-tests branch 2 times, most recently from cff1183 to 3f59251 Compare March 19, 2026 16:32
Also fixes an off-by-one bug in nthcdr.

Co-Authored-By: Gemini-CLI <gemini-cli@google.com>
@sqrew sqrew force-pushed the stdlib-dynamic-list-tests branch from 3f59251 to 6f02c02 Compare April 2, 2026 17:33
@sqrew
Copy link
Copy Markdown
Contributor Author

sqrew commented Apr 2, 2026

Updated the tests to align with Carp's symmetric definitions of nthcar and nthcdr. Reverted the changes to core/List.carp as they are indeed unnecessary under this interpretation. Thanks for the correction!

@hellerve
Copy link
Copy Markdown
Member

hellerve commented Apr 2, 2026

The Windows build failed due to a timeout unrelated to this PR.

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.

2 participants