tusages.nim 590 B

1234567891011121314151617181920212223
  1. discard """
  2. action: reject
  3. nimout: '''tusages.nim(20, 5) Error: 'BAD_STYLE' should be: 'BADSTYLE' [proc declared in tusages.nim(9, 6)]'''
  4. matrix: "--styleCheck:error --styleCheck:usages --hint:all:off --hint:Name:on"
  5. """
  6. import strutils
  7. proc BADSTYLE(c: char) = discard
  8. proc toSnakeCase(s: string): string =
  9. result = newStringOfCap(s.len + 3)
  10. for i in 0..<s.len:
  11. if s[i] in {'A'..'Z'}:
  12. if i > 0 and s[i-1] in {'a'..'z'}:
  13. result.add '_'
  14. result.add toLowerAscii(s[i])
  15. else:
  16. result.add s[i]
  17. BAD_STYLE(s[i])
  18. echo toSnakeCase("fooBarBaz Yes")