tusages.nim 563 B

12345678910111213141516171819202122232425
  1. discard """
  2. action: reject
  3. nimout: '''tusages.nim(22, 5) Error: 'BAD_STYLE' should be: 'BADSTYLE' [proc declared in tusages.nim(11, 6)]'''
  4. matrix: "--styleCheck:error --styleCheck:usages"
  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")