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

Strange output of String#underscore with strings of uppercased letters and numbers #4278

Closed
olbat opened this issue Apr 12, 2017 · 2 comments
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib

Comments

@olbat
Copy link
Contributor

olbat commented Apr 12, 2017

I'm not really sure what the output of String#underscore should be with uppercased strings containing numbers, but I think that the current behavior is wrong:

$ crystal eval 'p "ABC123".underscore'
"ab_c123"

$ crystal --version
Crystal 0.21.1 [3c6c75e] (2017-03-06) LLVM 3.5.0

Here is how Rails String#underscore behaves:

$ ruby -rrails -e 'p "ABC123".underscore'
"abc123"

$ ruby --version
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]
$ ruby -rrails -e 'puts Rails.version'
5.0.1
@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib labels Apr 12, 2017
@bew
Copy link
Contributor

bew commented Apr 12, 2017

Minimal version:

puts "AB1".underscore

Gives a_b1 (https://carc.in/#/r/1uq9)

makenowjust added a commit to makenowjust/crystal that referenced this issue Apr 12, 2017
Treat digit as downcase character. But in upcase characters it treats
like upcase character. It works fine.
olbat added a commit to olbat/crystal that referenced this issue Apr 13, 2017
The String#underscore method does not behave correctly when handling
strings containing non-letter characters such as digits (i.e. "FOO123")
@olbat
Copy link
Contributor Author

olbat commented Apr 13, 2017

Oops, sorry for the second PR, I worked offline and didn't check before pushing it 😳

mverzilli pushed a commit that referenced this issue Jun 2, 2017
* Treat digit as downcase character. 
* Add missing test case: digit between upcase letters
* Rename OpenSSL constants for String#underscore changes
olbat added a commit to olbat/libgen that referenced this issue Aug 3, 2017
olbat added a commit to olbat/libgen that referenced this issue Aug 3, 2017
olbat added a commit to olbat/libgen that referenced this issue Aug 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib
Projects
None yet
Development

No branches or pull requests

3 participants