mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
* Make nimIdentNormalize return "" when passed ""; fixes #19067 Fixes #19067 * Add tests for nimIdentNormalize
This commit is contained in:
committed by
GitHub
parent
7ba2659f73
commit
ee703c5db4
@@ -281,8 +281,9 @@ func nimIdentNormalize*(s: string): string =
|
||||
runnableExamples:
|
||||
doAssert nimIdentNormalize("Foo_bar") == "Foobar"
|
||||
result = newString(s.len)
|
||||
if s.len > 0:
|
||||
result[0] = s[0]
|
||||
if s.len == 0:
|
||||
return
|
||||
result[0] = s[0]
|
||||
var j = 1
|
||||
for i in 1..len(s) - 1:
|
||||
if s[i] in {'A'..'Z'}:
|
||||
|
||||
@@ -841,5 +841,12 @@ bar
|
||||
doAssert s.endsWith('a') == false
|
||||
doAssert s.endsWith('\0') == false
|
||||
|
||||
block: # nimIdentNormalize
|
||||
doAssert nimIdentNormalize("") == ""
|
||||
doAssert nimIdentNormalize("foo") == "foo"
|
||||
doAssert nimIdentNormalize("foo_bar") == "foobar"
|
||||
doAssert nimIdentNormalize("Foo_bar") == "Foobar"
|
||||
doAssert nimIdentNormalize("_Foo_bar") == "_foobar"
|
||||
|
||||
static: main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user