Skip to content

Experiment with disallowing subject chaining #1895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

natebosch
Copy link
Member

Remove the return value from nest and nestAsync, for passing the
nested condition ahead of time.

This interacts really poorly with has. We should only consider doing
this if we can find a workaround to allow inference for has or if we
expect that the vast majority of users will use codegen and we can hide
it from them.

I do like how this eliminates the which calls for some async
expectations.

Remove the return value from `nest` and `nestAsync`, for passing the
nested condition ahead of time.

This interacts really poorly with `has`. We should only consider doing
this if we can find a workaround to allow inference for `has` or if we
expect that the vast majority of users will use codegen and we can hide
it from them.

I do like how this eliminates the `which` calls for some async
expectations.
Add a `HasCheck` class which only has a `which` method. Since `has` is
annotated with `useResult` this method must be called (or some other
awkward workaround like assigning to a variable)
@@ -19,7 +19,8 @@ extension StringChecks on Subject<String> {
});
}

Subject<int> get length => has((m) => m.length, 'length');
void hasLengthWhich(Condition<int> lengthCondition) =>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would probably also add

void hasLength(int expectedLength) {

@natebosch
Copy link
Member Author

#1896 does this for only async nesting

@natebosch
Copy link
Member Author

#2073 (comment) shows a use case for assigning a Subject to a variable. We'd lose the described advantage over expect if we disallow chaining for synchronous expectations.

I don't think we should make this change. I think in practice the distinction between sync and async expectations is not a problem.

@natebosch natebosch closed this Aug 16, 2023
@natebosch natebosch deleted the take-condition-over-chain branch August 16, 2023 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant