@@ -4,53 +4,41 @@ import * as Effect from "effect/Effect"
44import * as Either from "effect/Either"
55import { pipe } from "effect/Function"
66import * as Option from "effect/Option"
7- import { assertType , satisfies } from "../utils/types.js"
87
98describe ( "Effect" , ( ) => {
109 describe ( "all" , ( ) => {
1110 it . effect ( "should work with one array argument" , ( ) =>
1211 Effect . gen ( function * ( ) {
1312 const res = yield * ( Effect . all ( [ Effect . succeed ( 0 ) , Effect . succeed ( 1 ) ] ) )
1413 deepStrictEqual ( res , [ 0 , 1 ] )
15- satisfies < true > ( assertType < [ number , number ] > ( ) ( res ) )
1614 } ) )
1715 it . effect ( "should work with one empty array argument" , ( ) =>
1816 Effect . gen ( function * ( ) {
1917 const x = yield * ( Effect . all ( [ ] ) )
2018 deepStrictEqual ( x , [ ] )
21- satisfies < true > ( assertType < [ ] > ( ) ( x ) )
2219 } ) )
2320 it . effect ( "should work with an array argument" , ( ) =>
2421 Effect . gen ( function * ( ) {
2522 const y = Effect . all ( [ 0 , 1 , 2 ] . map ( ( n ) => Effect . succeed ( n + 1 ) ) )
2623 const x = yield * y
2724 deepStrictEqual ( x , [ 1 , 2 , 3 ] )
28- satisfies < true > ( assertType < Array < number > > ( ) ( x ) )
2925 } ) )
3026 it . effect ( "should work with one record argument" , ( ) =>
3127 Effect . gen ( function * ( ) {
3228 const result = yield * ( Effect . all ( { a : Effect . succeed ( 0 ) , b : Effect . succeed ( 1 ) } ) )
3329 const { a, b } = result
3430 deepStrictEqual ( a , 0 )
3531 deepStrictEqual ( b , 1 )
36- satisfies < true > (
37- assertType < {
38- readonly a : number
39- readonly b : number
40- } > ( ) ( result )
41- )
4232 } ) )
4333 it . effect ( "should work with one iterable argument" , ( ) =>
4434 Effect . gen ( function * ( ) {
4535 const result = yield * ( Effect . all ( new Set ( [ Effect . succeed ( 0 ) , Effect . succeed ( 1 ) ] ) ) )
4636 deepStrictEqual ( result , [ 0 , 1 ] )
47- satisfies < true > ( assertType < Array < number > > ( ) ( result ) )
4837 } ) )
4938 it . effect ( "should work with one empty record" , ( ) =>
5039 Effect . gen ( function * ( ) {
5140 const x = yield * ( Effect . all ( { } ) )
5241 deepStrictEqual ( x , { } )
53- satisfies < true > ( assertType < { } > ( ) ( x ) )
5442 } ) )
5543 } )
5644 describe ( "all/ concurrency" , ( ) => {
@@ -60,15 +48,13 @@ describe("Effect", () => {
6048 concurrency : "unbounded"
6149 } ) )
6250 deepStrictEqual ( res , [ 0 , 1 ] )
63- satisfies < true > ( assertType < [ number , number ] > ( ) ( res ) )
6451 } ) )
6552 it . effect ( "should work with one empty array argument" , ( ) =>
6653 Effect . gen ( function * ( ) {
6754 const x = yield * ( Effect . all ( [ ] , {
6855 concurrency : "unbounded"
6956 } ) )
7057 deepStrictEqual ( x , [ ] )
71- satisfies < true > ( assertType < [ ] > ( ) ( x ) )
7258 } ) )
7359 it . effect ( "should work with one record argument" , ( ) =>
7460 Effect . gen ( function * ( ) {
@@ -78,45 +64,30 @@ describe("Effect", () => {
7864 const { a, b } = result
7965 deepStrictEqual ( a , 0 )
8066 deepStrictEqual ( b , 1 )
81- satisfies < true > (
82- assertType < {
83- a : number
84- b : number
85- } > ( ) ( result )
86- )
8767 } ) )
8868 it . effect ( "should work with one empty record" , ( ) =>
8969 Effect . gen ( function * ( ) {
9070 const x = yield * ( Effect . all ( { } , { concurrency : "unbounded" } ) )
9171 deepStrictEqual ( x , { } )
92- satisfies < true > ( assertType < { } > ( ) ( x ) )
9372 } ) )
9473 } )
9574 describe ( "all/ validate mode" , ( ) => {
9675 it . effect ( "should work with one array argument" , ( ) =>
9776 Effect . gen ( function * ( ) {
9877 const res = yield * ( Effect . all ( [ Effect . succeed ( 0 ) , Effect . succeed ( 1 ) ] , { mode : "validate" } ) )
9978 deepStrictEqual ( res , [ 0 , 1 ] )
100- satisfies < true > ( assertType < [ number , number ] > ( ) ( res ) )
10179 } ) )
10280 it . effect ( "failure should work with one array argument" , ( ) =>
10381 Effect . gen ( function * ( ) {
10482 const res = yield * ( Effect . flip ( Effect . all ( [ Effect . fail ( 0 ) , Effect . succeed ( 1 ) ] , { mode : "validate" } ) ) )
10583 deepStrictEqual ( res , [ Option . some ( 0 ) , Option . none ( ) ] )
106- satisfies < true > ( assertType < [ Option . Option < number > , Option . Option < never > ] > ( ) ( res ) )
10784 } ) )
10885 it . effect ( "should work with one record argument" , ( ) =>
10986 Effect . gen ( function * ( ) {
11087 const result = yield * ( Effect . all ( { a : Effect . succeed ( 0 ) , b : Effect . succeed ( 1 ) } , { mode : "validate" } ) )
11188 const { a, b } = result
11289 deepStrictEqual ( a , 0 )
11390 deepStrictEqual ( b , 1 )
114- satisfies < true > (
115- assertType < {
116- readonly a : number
117- readonly b : number
118- } > ( ) ( result )
119- )
12091 } ) )
12192 it . effect ( "failure should work with one record argument" , ( ) =>
12293 Effect . gen ( function * ( ) {
@@ -126,45 +97,30 @@ describe("Effect", () => {
12697 const { a, b } = result
12798 assertSome ( a , 0 )
12899 assertNone ( b )
129- satisfies < true > (
130- assertType < {
131- readonly a : Option . Option < number >
132- readonly b : Option . Option < never >
133- } > ( ) ( result )
134- )
135100 } ) )
136101 it . effect ( "should work with one iterable argument" , ( ) =>
137102 Effect . gen ( function * ( ) {
138103 const result = yield * ( Effect . all ( new Set ( [ Effect . succeed ( 0 ) , Effect . succeed ( 1 ) ] ) , { mode : "validate" } ) )
139104 deepStrictEqual ( result , [ 0 , 1 ] )
140- satisfies < true > ( assertType < Array < number > > ( ) ( result ) )
141105 } ) )
142106 } )
143107 describe ( "all/ either mode" , ( ) => {
144108 it . effect ( "should work with one array argument" , ( ) =>
145109 Effect . gen ( function * ( ) {
146110 const res = yield * ( Effect . all ( [ Effect . succeed ( 0 ) , Effect . succeed ( 1 ) ] , { mode : "either" } ) )
147111 deepStrictEqual ( res , [ Either . right ( 0 ) , Either . right ( 1 ) ] )
148- satisfies < true > ( assertType < [ Either . Either < number > , Either . Either < number > ] > ( ) ( res ) )
149112 } ) )
150113 it . effect ( "failure should work with one array argument" , ( ) =>
151114 Effect . gen ( function * ( ) {
152115 const res = yield * ( Effect . all ( [ Effect . fail ( 0 ) , Effect . succeed ( 1 ) ] , { mode : "either" } ) )
153116 deepStrictEqual ( res , [ Either . left ( 0 ) , Either . right ( 1 ) ] )
154- satisfies < true > ( assertType < [ Either . Either < never , number > , Either . Either < number > ] > ( ) ( res ) )
155117 } ) )
156118 it . effect ( "should work with one record argument" , ( ) =>
157119 Effect . gen ( function * ( ) {
158120 const result = yield * ( Effect . all ( { a : Effect . succeed ( 0 ) , b : Effect . succeed ( 1 ) } , { mode : "either" } ) )
159121 const { a, b } = result
160122 assertRight ( a , 0 )
161123 assertRight ( b , 1 )
162- satisfies < true > (
163- assertType < {
164- readonly a : Either . Either < number >
165- readonly b : Either . Either < number >
166- } > ( ) ( result )
167- )
168124 } ) )
169125 it . effect ( "failure should work with one record argument" , ( ) =>
170126 Effect . gen ( function * ( ) {
@@ -174,18 +130,11 @@ describe("Effect", () => {
174130 const { a, b } = result
175131 assertLeft ( a , 0 )
176132 assertRight ( b , 1 )
177- satisfies < true > (
178- assertType < {
179- readonly a : Either . Either < never , number >
180- readonly b : Either . Either < number >
181- } > ( ) ( result )
182- )
183133 } ) )
184134 it . effect ( "should work with one iterable argument" , ( ) =>
185135 Effect . gen ( function * ( ) {
186136 const result = yield * ( Effect . all ( new Set ( [ Effect . succeed ( 0 ) , Effect . succeed ( 1 ) ] ) , { mode : "either" } ) )
187137 deepStrictEqual ( result , [ Either . right ( 0 ) , Either . right ( 1 ) ] )
188- satisfies < true > ( assertType < Array < Either . Either < number > > > ( ) ( result ) )
189138 } ) )
190139 } )
191140 describe ( "allWith" , ( ) => {
@@ -196,7 +145,6 @@ describe("Effect", () => {
196145 Effect . allWith ( )
197146 )
198147 deepStrictEqual ( res , [ 0 , 1 ] )
199- satisfies < true > ( assertType < [ number , number ] > ( ) ( res ) )
200148 } ) )
201149 } )
202150} )
0 commit comments