diff options
Diffstat (limited to 'tests/stylecheck/tusages.nim')
-rw-r--r-- | tests/stylecheck/tusages.nim | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/stylecheck/tusages.nim b/tests/stylecheck/tusages.nim new file mode 100644 index 000000000..b689dabb3 --- /dev/null +++ b/tests/stylecheck/tusages.nim @@ -0,0 +1,22 @@ +discard """ + action: reject + nimout: '''tusages.nim(20, 5) Error: 'BAD_STYLE' should be: 'BADSTYLE' [proc declared in tusages.nim(9, 6)]''' + matrix: "--styleCheck:error --styleCheck:usages --hint:all:off --hint:Name:on" +""" + +import strutils + +proc BADSTYLE(c: char) = discard + +proc toSnakeCase(s: string): string = + result = newStringOfCap(s.len + 3) + for i in 0..<s.len: + if s[i] in {'A'..'Z'}: + if i > 0 and s[i-1] in {'a'..'z'}: + result.add '_' + result.add toLowerAscii(s[i]) + else: + result.add s[i] + BAD_STYLE(s[i]) + +echo toSnakeCase("fooBarBaz Yes") |