Skip to content

Fix bug in word()#282

Merged
hadley merged 6 commits intotidyverse:masterfrom
pdelboca:245-bug-word-function
Oct 11, 2019
Merged

Fix bug in word()#282
hadley merged 6 commits intotidyverse:masterfrom
pdelboca:245-bug-word-function

Conversation

@pdelboca
Copy link
Contributor

Fixing unconsistent behavior described in #245 and adding some test.

Copy link
Member

@hadley hadley left a comment

Choose a reason for hiding this comment

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

Can you please add a bullet to NEWS? It should briefly describe the change and end with (@yourname, #issuenumber).

})

test_that("negative parameters", {
expect_equal("moon",word("walk the moon", -1, -1))
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add the missing space before word()?

Also you only need the first line here as the other two test the same code path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Although I will suggest to keep the other two lines since they test a specific behavior: return all the sentence if the negative start parameter is greater than the number of words. Important to have a consistent API with str_sub.

Let me know if you want to remove it anyways!

@hadley hadley changed the title 245 bug word function Fix bug in word() Oct 10, 2019
@pdelboca
Copy link
Contributor Author

Made all the changes. Let me know if anything else is needed!

@hadley hadley merged commit 9ae51b8 into tidyverse:master Oct 11, 2019
@hadley
Copy link
Member

hadley commented Oct 11, 2019

Thanks!

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.

2 participants