Skip to content
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

Wait uses Double instead of Number #570

Closed
mkutz opened this issue Mar 21, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@mkutz
Copy link

commented Mar 21, 2019

I stumbled upon this while playing around with @CompileStatic. I noticed that every call like this browser.waitFor(3) { myPage.button } failed while browser.waitFor(3d) { myPage.button } works since the interface of waitFor actually requires a Double parameter.

Even without @CompileStatic Idea cannot determine the return type of waitFor and assumes Object, which prevents a lot of auto-completion and causes several warning in the IDE.

I don't see any reason why Wait cannot use Number instead of Double to fix this. If there are no objections, I'd file a PR for this.

@erdi

This comment has been minimized.

Copy link
Member

commented Mar 22, 2019

@mkutz

This comment has been minimized.

Copy link
Author

commented Mar 22, 2019

Why do you think it won't be backwards compatible? Number is a super-type of Double, so calling waitFor with Doubles will still work.

mkutz added a commit to mkutz/geb that referenced this issue Mar 22, 2019

Use Number instead of Double in Wait
There is no reason to restrict timeout and interval to Double values.
In the documentation there never was any example using Double, but
Integer (e.g. 5) or Float (e.g. 0.1). While the calls actually worked
due to Groovy's dynamic typing, they cause errors when using strict
typing and cause irritations in Idea, which cannot find the right
method and assumes that waitFor will return Object instead of the return
type of the given Closure.

Switching to Number allows to use any Number type and will solve these
issues.

Contributes to geb/issues#570
@erdi

This comment has been minimized.

Copy link
Member

commented Mar 31, 2019

Sorry for a late response, I've been on holiday.

You are probably right, changing from double to a wider type of Number is not a breaking change.

@erdi erdi closed this Mar 31, 2019

@erdi erdi reopened this Mar 31, 2019

@mkutz

This comment has been minimized.

Copy link
Author

commented Mar 31, 2019

I'm just back from Greach as well.

mkutz added a commit to mkutz/geb that referenced this issue Apr 1, 2019

Make Wait.toMilliseconds return int
This saves some formally necessary casts and additional calculations.

Contributes to geb/issues#570

@erdi erdi added the Improvement label Apr 4, 2019

@erdi erdi added this to the 2.4 milestone Apr 4, 2019

@erdi erdi closed this Apr 4, 2019

@erdi erdi modified the milestones: 2.4, 3.0 May 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.