summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2021-05-07 16:50:11 +0200
committerGitHub <noreply@github.com>2021-05-07 16:50:11 +0200
commit51f3ef6cb8ac9fbbc9533c1de2af219dc4ecabe7 (patch)
treed631917998fd8725b98cc7e2331061dff7db2c74 /tests
parent56068101f6aee4635c22ca10b3f3062f27bcc946 (diff)
downloadNim-51f3ef6cb8ac9fbbc9533c1de2af219dc4ecabe7.tar.gz
fixes #15848 [backport:1.2] (#17959)
Diffstat (limited to 'tests')
-rw-r--r--tests/stylecheck/tusages.nim23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/stylecheck/tusages.nim b/tests/stylecheck/tusages.nim
new file mode 100644
index 000000000..f3b0d27cc
--- /dev/null
+++ b/tests/stylecheck/tusages.nim
@@ -0,0 +1,23 @@
+discard """
+  cmd: "nim c --styleCheck:error --styleCheck:usages $file"
+  errormsg: "'BAD_STYLE' should be: 'BADSTYLE'"
+  line: 20
+"""
+
+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")
+