test(fjl): #124 assert $-prefixed methods are actually curried - #133
Open
elycruz wants to merge 1 commit into
Open
test(fjl): #124 assert $-prefixed methods are actually curried#133elycruz wants to merge 1 commit into
$-prefixed methods are actually curried#133elycruz wants to merge 1 commit into
Conversation
…curried Adds a shared, data-driven currying assertion helper plus a suite that derives its target list from the package's public export surface at runtime, so curried methods added later are covered automatically. - `tests/curry-helpers.ts` - `assertCurriedCase` asserts, per argument case, that (1) every application before the last returns a function, (2) the fully applied curried method agrees with its un-curried sibling, and (3) a partially applied method is re-usable. Argument fixtures are factories, so methods that mutate their arguments get fresh args per invocation. - `tests/test-currying.ts` - fixture registry for all 109 `$`-prefixed exports (+ the 9 `$`-prefixed `Object` statics on `fjl.native`), and meta-tests keeping the registry and the export surface in sync. Doc corrections (no behaviour changes): - `$trampoline` documented as *not* idiomatically curried (it takes the same `(fn, fnName?)` tuple as `trampoline`). - `$assignDeep` (and its alias `$objUnion`) annotated with a known-bug `@todo`: rest-args are forwarded as a single array, so `$assignDeep(a)(b, c)` merges `[b, c]` into `a`. Pinned with `it.failing` rather than fixed here - needs its own ticket. - `_platform/object` doc-block: `$defineProperties` et al. live on `native`, they are not top-level `fjl` exports. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a shared currying assertion helper and a data-driven suite that asserts every
$-prefixed export infjlis actually curried. The target list is derived from the package's public export surface at runtime (not hand-written), so curried methods added later are picked up automatically and fail the suite until they get argument fixtures.Closes #124
Work-unit id:
124-curry-testsHow the helper works
packages/fjl/tests/curry-helpers.tsexportsassertCurriedCase(curried, uncurried, case, reusablePartial).fjluses idiomatic currying (f(a)(b)(c)) rather than the deprecatedcurry*/argument-tuple form, so the assertions are written against that. Per argument case it asserts:$f(a)(b)(c)deep-equalsf(a, b, c).Fixture shape (
CurryCase/CurrySpec):argsis an argument factory, not a literal list, so methods that mutate their arguments (push,pushN,defineProp, …) get clean args for every one of the ~5 invocations an assertion makes.groupsdescribes the application split, e.g.[1, 2]⇒f(a)(b, c)— needed for the variadic-tail methods ($append,$complement,$zipN,$zipWithN,$toShortest,$pushN,$range,$objComplement,$bind) and the deeper ones ($defineProp⇒[1, 1, 2],$errorIfNotType⇒[1, 1, 1, 2]).finalizemaps a result into something comparable — for methods returning functions ($bind,$trampoline), generators ($iterate), or communicating by side effect ($forEach).sibling/uncurriedhandle the methods whose un-curried counterpart isn't simply the$-name minus its$($normalizeStep→normalizeStepOrThrow;$getErrorIfNotType(s)Thrower, whose un-curried equivalent needs assembling).knownFailureregisters the case viait.failing, so a real bug is pinned rather than papered over — and the suite goes red if the method is ever fixed without removing the note.notCurrieddocuments a$-prefixed method that verifiably isn't curried.packages/fjl/tests/test-currying.tsholds the registry and the driver. Two meta-tests keep registry and export surface in sync:$-prefixed export" — fails listing any uncovered$export.Coverage
118 of 118 curried methods asserted:
$-prefixed top-level exports ofpackages/fjl/src(list/,list/utils/,object/,string/,boolean/,number/,function/,errorThrowing/,_platform/).$-prefixed, flipped-and-curriedObjectstatics on thefjl.nativeexport ($assign,$create,$defineProperties,$defineProperty,$getOwnPropertyDescriptor,$groupBy,$hasOwn,$is,$setPrototypeOf) — same convention, same helper.(The ~112
$identifiers greppable insrcinclude$zip4/zip4, whichlist/index.tsnever re-exports,$concat, which is shadowed bylist/concat.tsand reachable only as$append, and the$UnionBy/$definePropertiestype/doc mentions.)Methods that failed the currying assertion
1.
$assignDeep— real behavioural bug (registeredit.failing, not fixed here)assignDeep's signature is(obj0, ...objs), so the curried version merges the arrayobjsintoobj0:2.
$objUnion— same bug (alias)object/setTheory.tsdefines$objUnion = $assignDeep, so it inherits the defect:What I did: per the work-unit brief, no library behaviour was changed (a one-character fix here would collide with concurrent work on
32-type-system-cleanup/121-generators). Both are registered withit.failingand aknownFailurereason, andsrc/object/assignDeep.tscarries a@todoknown-bug doc note. These two need their own ticket; when fixed, theit.failingregistrations must be dropped (the suite will go red otherwise, by design).3.
$trampoline— not curried; documentation correctedIt takes the same argument tuple as
trampoline, i.e. it's an alias, not an idiomatically curried sibling.$trampoline(fn)reads curried only becausefnNameis optional — it does not return a function awaitingfnName. Nothing documented it as curried, so per acceptance criterion 3 the documentation was corrected: a doc-block now states it explicitly, and the suite pins the non-curried arity vianotCurried.Other documentation corrections (no behaviour changes)
src/_platform/object/index.ts— thenativedoc-block told users toimport {defineProperties, $defineProperties} from 'fjl'; those aren't top-level exports, they live onnative. Example corrected.Test layout
Follows the dominant existing convention (
packages/fjl/tests/**,test-*.ts) — no new convention, and no attempt at the co-location migration (#77 / #125).Testing evidence
Baseline (
origin/main):This branch (
pnpm test):+1suite,+371tests, all green.pnpm buildexits0.eslintandtsc-files --noEmitare clean on all five changed/added files (repo-widepnpm lintfailures are pre-existing onmainand untouched). No git hooks were bypassed.🤖 Generated with Claude Code