Bylabel exact#1459
Conversation
|
Issue: #1454 I have no confidence if my English is right. Please correct any sentences you feel unconfortable. |
|
Well, |
|
Sounds good to me
…On Sun, Dec 3, 2017, 11:00 AM rounddelta ***@***.***> wrote:
Well, fileByLabel also uses T.isInfixOf. Should I create the exact
version for this, too?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1459 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AADBB4ZlHQKRg9db-XnxTQAGFGYwNn5Eks5s8mMogaJpZM4QzP8h>
.
|
yesod-test/Yesod/Test.hs
Outdated
| nameFromLabel :: T.Text -> RequestBuilder site T.Text | ||
| nameFromLabel label = do | ||
| -- | ||
| -- @since 1.5.9 |
There was a problem hiding this comment.
You don't need to give @since annotations for non-exported functions
Edit: unless this is meant to be exported?
There was a problem hiding this comment.
No. I understand the rule. I'll do so:)
|
|
||
| -- | | ||
| -- @since 1.5.9 | ||
| byLabelWithMatch :: (T.Text -> T.Text -> Bool) -- ^ The matching method which is used to find labels (i.e. exact, contains) |
There was a problem hiding this comment.
Is this meant to be exported? It seems really useful
yesod-test/Yesod/Test.hs
Outdated
| -- > byLabel "Nickname" "Snoyberger" | ||
| -- | ||
| -- Therefore, this function is deprecated. Please consider using 'byLabelExact', | ||
| -- which performs the exact match over the given word. |
There was a problem hiding this comment.
I think we should use a GHC DEPRECATED pragma, and recommend byLabelWithMatch Data.Text.contains for the old behavior and byLabelExact for the new behavior
There was a problem hiding this comment.
recommend byLabelWithMatch Data.Text.contains for the old behavior and byLabelExact for the new behavior
Actually, byLabelWithMatch is the abstraction of the matching methods and byLabel performs the old behavior (contain) as before, unless users will be forced to rewrite their tests to use byLabelContain or whatever. And yes, byLabelExact is for the new behavior.
So,
byLabel -> deprecated
byLabelExact -> recommanded
Is this okay?
I think we should use a GHC DEPRECATED pragma
NiceXD. I even didn't know that. I'll modify the code.
yesod-test/Yesod/Test.hs
Outdated
| -- > </form> | ||
| -- | ||
| -- Note that this function finds the labels in which contain the given word. | ||
| -- It might choice labels unexpectedly or just fail in the circumstances like below: |
There was a problem hiding this comment.
Can you make this more explicit about how the function would fail? Something like the following:
Warning: This function looks for any label that contains a subset of the provided text. If multiple labels contain that subset, this function will throw an error, as in the example below:
Site note since it sounds like you're working on your English skills:
"labels in which contain" should be "labels which contain"
"It might choice labels" should be "It might choose labels"
There was a problem hiding this comment.
Can you make this more explicit about how the function would fail?
Sure.
And thank you for your advice about my English. It helps me a lot.
|
@snoyberg Should I create another PR? |
|
I don't think a new PR is necessary, I'd say just update this one. |
|
@MaxGabriel Following your advices, I updated haddocks. What do you think? |
yesod-test/Yesod/Test.hs
Outdated
| -- > <label>Please submit an image <input type="file" name="f1"> </label> | ||
| -- > </form> | ||
| -- | ||
| -- Warning: There exists the same issue of 'byLabel'. Please use 'fileByLabelExact' instead. |
There was a problem hiding this comment.
It would sound better to say "This function has the same issue as 'byLabel'"
|
I made one small comment. Otherwise LGTM! |
|
@MaxGabriel Noted with thanks! |
|
@snoyberg @MaxGabriel I guess I've done. Would you review changes? |
|
@pythonissam what’s the other bug in byLabel? |
|
@MaxGabriel Please consider the following situation <html>
<form>
<label>foo2<input type=text name="bar2"></label>
<label>foo <input type=text name="bar" ></label>
</form>
</html>Then The cause is around here: -- In genericNameFromLabel
case mfor of
for:[] -> ...
[] ->
case filter (/= "") $ mlabel >>= (child >=> C.element "input" >=> attribute "name") of
[] -> failure $ "No label contained: " <> label
name:_ -> return name
_ -> ...Using Finally, |
|
Same here, the fundamental cause is that we decided to use |
|
Hi. What's the status of this? CI looks like it failed. |
snoyberg
left a comment
There was a problem hiding this comment.
It looks good to me, I just had a minor comment on the deprecation notices. Thanks!
yesod-test/Yesod/Test.hs
Outdated
| type HasCallStack = (() :: Constraint) | ||
| #endif | ||
|
|
||
| {-# DEPRECATED byLabel "This function seems to have multiple bugs. Use byLabelExact instead" #-} |
There was a problem hiding this comment.
How about including a link to this PR in the deprecation notices?
There was a problem hiding this comment.
It sounds good
|
@snoyberg Is this okay? |
|
Looks great, thanks! |
|
Thanks @pyhtonissam! |
|
@snoyberg @MaxGabriel Yay! Thank you, too! |
Fix Haddock syntax error and test failures introduced by #1459
Before submitting your PR, check that you've:
@sincedeclarations to the HaddockAfter submitting your PR: