Comments (9)
from effect.
Started playing with it in the effect codebase and seems like the expect(<option>).toStrictEqual(<another option>)
always succeeds independently of what are the option values, for example this succeeds in the test/Option.test.ts
expect(_.some(1)).toStrictEqual(_.some(2))
expect(_.none()).toStrictEqual(_.some(2))
from effect.
Okay, seems to be the Symbol.iterator
that makes the difference - which makes sense, that is the thing introduced in 3.0.4 to enable to yield without an adapter, right?
[Symbol.iterator]() {
return new SingleShotGen.SingleShotGen(this) as any
},
When I remove it from the Effect prototype the comparison starts working. cc @mikearnaldi
from effect.
Yup that comes from 3.0.4, I don't see how this could ever be considered a bug of effect, it's behaviour of expect...
from effect.
The Effect way of comparing options is Equals.equals(a, b)
from effect.
In this codebase you rely on the expect().toStrictEqual()
/ Util.deepStrictEqual
etc checks in the tests as well. Therefore, from 3.0.4, tests in here doing checks on options actually test nothing because they all always succeed. And this will apply for all the consumers of effect lib as well.
from effect.
Yeah but that's a bug in expect not in Effect... like I am trying to compare two objects with a[Symbol.iterator] = [1, 2, 3, Math.random()][Symbol.iterator]
and it says that they are equal, why on earth???
from effect.
seems like a vitest issue, jest had a similar jestjs/jest#8280
from effect.
The following works:
import { jestExpect as expect } from "@jest/expect"
import { describe, it } from "vitest"
describe("Vitest Issue", () => {
it("compares", () => {
const a = {
value: 0,
[Symbol.iterator]: [0, 1, 2, Math.random()][Symbol.iterator]
}
const b = {
value: 1,
[Symbol.iterator]: [0, 1, 2, Math.random()][Symbol.iterator]
}
expect(a).toStrictEqual(b)
})
})
from effect.
Related Issues (20)
- RangeError: Invalid array length when calling broadcastDynamic(Infinity) HOT 1
- Scheduler Goes Rogue HOT 1
- Stream.zipLatestAll
- `Schema.hash` / `AST.hash` should not use JSON.stringify HOT 1
- From Discord: Configuring BunHttpServer for HTTPS
- Using timeout in runFork causes warning about unhandled error
- effect/DateRange module HOT 4
- Browser worker are not terminated properly according to `minSize`, `maxSize`, `timeToLive`
- From Discord: Handling Missing 'cause' in @effect/schema Exceptions
- sql: Silently swallows errors HOT 3
- add dual ESM/CJS via package exports field HOT 1
- From Discord: Issue with Optional Props in TypeScript Constructor Using '@effect/schema/Schema'
- Add 'andThen' support for Stream api map / mapEffect, like Effect.andThen
- `Schema.optional` struct prop restricts possible schema operations HOT 4
- Service members from Effect.Tag not behaving like normal effects HOT 2
- tc39 proposal compatible fromObservable for better ecosystem interop. HOT 3
- Schema-based config descriptions HOT 3
- Configurable custom additional span attributes for the sql clients
- TaggedEnum.WithGenerics does not have $is and $match helpers HOT 1
- Unexpected NodeJS process hanging HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from effect.