Skip to content

Consolidate redundant Data, Chunk.getUnsafe and Metric.track tests - #10280

Merged
tim-smart merged 2 commits into
mainfrom
agent/nelson-effect-bot/70b557ed6619
Nov 2, 2026
Merged

tim-smart merged 2 commits into
mainfrom
agent/nelson-effect-bot/70b557ed6619

Conversation

@effect-bot

@effect-bot effect-bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Test-only cleanup in four packages/effect suites. No production code or runner config changes. The suite has 37 fewer tests (Data 38 → 22, Chunk.getUnsafe 15 → 3, Metric track* 12 → 3). Every assertion that was dropped is either kept in a merged test or duplicated something that is still checked.

What changed

test/Data.test.ts (38 → 22 tests)

Removed / merged Coverage kept in
Class "assigns fields from constructor args", "fields are enumerable" "copies own enumerable string and symbol keys only, as enumerable fields" now asserts name, age, Object.keys and Reflect.ownKeys
Class "structural equality via Equal.equals", "not equal when fields differ" "compares instances structurally" (equal and unequal cases)
TaggedClass "sets _tag", "assigns fields" "sets _tag to the provided tag and assigns fields"
TaggedClass "structural equality includes _tag", "different tags are not equal" "compares instances structurally, including _tag"
taggedEnum constructors (2 tests) "constructors create tagged variants" (deepStrictEqual on both variants)
taggedEnum $is (3 tests) "$is only accepts values with the named tag" (same 6 inputs)
taggedEnum $match (3 tests) "$match dispatches on _tag, data-last and data-first" covers both variants in both forms. The old Circle case used Math.PI * 25 as the expected value, which restated the handler, so it now uses literal results.
taggedEnum no-field variant (2 tests) "constructs and matches variants without fields"
Error "is an instance", "assigns fields", "has a stack trace" "is a globalThis.Error with a stack trace and the provided fields"
TaggedError "sets _tag", "assigns fields", "is an instance", "sets .name" "is a globalThis.Error named after its _tag, with the provided fields"

The declaration-emit test, __proto__, .pipe(), no-arg constructors, toJSON, yieldable and catchTag tests are unchanged.

test/Chunk.test.ts, getUnsafe (15 → 3 tests)

Removed / merged Coverage kept in
In-bounds singleton, array, prepend, append examples (6 tests, 2 with the same name) "returns the element at an in-bounds index": singleton, array, prepend and append examples plus the concat property that checks every index
make(0,1,2) + append(3) / prepend(3) at index 1 Covered by the concat property (array ++ singleton) and the append/prepend examples
Fractional index "floors a fractional index" (unchanged)
Out-of-bounds for empty, appended, singleton, array (4 tests), NaN, concat property "throws for an out-of-bounds or non-finite index"
Out-of-bounds property over repeated prepend Dropped. The bounds check runs on self.length before dispatching on the backing, and prepend builds the same concat backing the concat property covers.

test/Metric.test.ts, track* (12 → 3 tests)

There were two describe("track") blocks with identical bodies; one test was named "maps exits while preserving the instrumented effect result" but did not map exits. The second block is removed, and track, trackErrors and trackDefects are now one table-driven test each that runs success, failure and defect against the same counter and asserts the running count ([1,2,3], [0,1,1], [0,0,1]). Each test uses the data-last form (self.pipe(Effect.track*(counter))), as the removed tests did, and asserts the three exits are Exit.succeed(1), Exit.fail(1) and Exit.die(1), so a combinator that changes the result of the effect it wraps still fails.

test/Stream.test.ts

The Stream.buffer dropping and sliding tests were filed under the bufferArray - dropping / bufferArray - sliding describes, which gave them the same names as the bufferArray tests. They now sit under buffer - dropping / buffer - sliding. No test bodies changed.

Regression check

I mutated production code temporarily and confirmed the consolidated tests fail:

  • Chunk.getUnsafe bound < → <=: 1 failure
  • getUnchecked IArray returns array[0]: 4 failures
  • getUnchecked IConcat skips the - left.length offset: 1 failure
  • taggedEnum constructor drops _tag: 4 failures
  • trackErrors uses tapCause (counts defects): 1 failure
  • trackDefects dies after a successful effect (metric updates unchanged): 1 failure
  • trackDefects dual always takes the data-first path, breaking the curried form: 1 failure

Timings

Affected files only, vitest run --project effect <files>, 3 runs each, median per-file wall time on an 8-core machine:

File Tests before → after Before (ms) After (ms)
Data.test.ts 38 → 22 5312 4637
Chunk.test.ts 121 → 109 618 345
Metric.test.ts 72 → 63 285 197
Stream.test.ts 395 → 395 1818 1567

Only the Chunk drop is clearly real (one fewer fast-check property). The rest is within run-to-run noise: Stream.test.ts bodies are unchanged, and Data.test.ts wall time is dominated by the declaration-emit test, which spawns tsc for about 4.5 s. This PR is about removing duplication, not suite speed.

Checks

  • vitest run on the four files: pass
  • tsc -b tsconfig.tests.json: pass
  • oxlint, dprint check on the changed files: pass

Closes EFF-3282

@changeset-bot

changeset-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: cccb785

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@effect-janitor effect-janitor Bot added the 4.0 label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 39.41 KB 39.41 KB 0.00 KB (0.00%)
basic.ts 7.23 KB 7.23 KB 0.00 KB (0.00%)
batching.ts 11.08 KB 11.08 KB 0.00 KB (0.00%)
brand.ts 6.87 KB 6.87 KB 0.00 KB (0.00%)
cache.ts 11.54 KB 11.54 KB 0.00 KB (0.00%)
config.ts 22.84 KB 22.84 KB 0.00 KB (0.00%)
differ.ts 22.00 KB 22.00 KB 0.00 KB (0.00%)
http-client.ts 26.93 KB 26.93 KB 0.00 KB (0.00%)
http-router.ts 37.00 KB 37.00 KB 0.00 KB (0.00%)
logger.ts 12.01 KB 12.01 KB 0.00 KB (0.00%)
metric.ts 9.47 KB 9.47 KB 0.00 KB (0.00%)
optic.ts 7.10 KB 7.10 KB 0.00 KB (0.00%)
pubsub.ts 16.02 KB 16.02 KB 0.00 KB (0.00%)
queue.ts 12.82 KB 12.82 KB 0.00 KB (0.00%)
schedule.ts 11.80 KB 11.80 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 14.14 KB 14.14 KB 0.00 KB (0.00%)
schema-binary.ts 41.67 KB 41.67 KB 0.00 KB (0.00%)
schema-class.ts 21.73 KB 21.73 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 29.60 KB 29.60 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 27.99 KB 27.99 KB 0.00 KB (0.00%)
schema-string-transformation.ts 15.35 KB 15.35 KB 0.00 KB (0.00%)
schema-string.ts 12.34 KB 12.34 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.27 KB 16.27 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 38.95 KB 38.95 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 26.15 KB 26.15 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 20.90 KB 20.90 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 21.05 KB 21.05 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.14 KB 21.14 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 26.17 KB 26.17 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.23 KB 21.23 KB 0.00 KB (0.00%)
schema.ts 20.82 KB 20.82 KB 0.00 KB (0.00%)
stm.ts 14.20 KB 14.20 KB 0.00 KB (0.00%)
stream.ts 10.38 KB 10.38 KB 0.00 KB (0.00%)

@tim-smart
tim-smart merged commit e5b1bcf into main Nov 2, 2026
17 checks passed
@tim-smart
tim-smart deleted the agent/nelson-effect-bot/70b557ed6619 branch November 2, 2026 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants