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

Fix bug in word() #282

Merged
merged 6 commits into from Oct 11, 2019
Merged

Fix bug in word() #282

merged 6 commits into from Oct 11, 2019

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).

@@ -10,3 +10,9 @@ test_that("word extraction", {
test_that("words past end return NA", {
expect_equal(word("a b c", 4), NA_character_)
})

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.

None yet

2 participants