-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f02afe3
commit df5740d
Showing
3 changed files
with
60 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
36 changes: 36 additions & 0 deletions
36
packages/fpdart/test/src/effect/effect_do_notation_test.dart
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import "package:fpdart/fpdart.dart"; | ||
import "package:test/test.dart"; | ||
|
||
void main() { | ||
group( | ||
"Effect do notation", | ||
() { | ||
group('provide', () { | ||
test('remove dependency', () { | ||
final main = Effect<String, String, int>.gen(($) { | ||
final env = $.sync(Effect.env()); | ||
return env.length; | ||
}); | ||
|
||
final program = main.provide("abc"); | ||
final result = program.runSyncVoid(); | ||
expect(result, 3); | ||
}); | ||
}); | ||
|
||
group('mapEnv', () { | ||
test('adapt dependency from another program', () { | ||
final subMain = | ||
Effect<int, String, int>.from((env) => Right(env + 1)); | ||
final main = Effect<String, String, int>.gen(($) { | ||
final value = $.sync(subMain.mapEnv((env) => env.length)); | ||
return value; | ||
}); | ||
|
||
final result = main.runSync("abc"); | ||
expect(result, 4); | ||
}); | ||
}); | ||
}, | ||
); | ||
} |