diff options
Diffstat (limited to 'tests/stylecheck')
-rw-r--r-- | tests/stylecheck/foreign_package/foreign_package.nim | 1 | ||||
-rw-r--r-- | tests/stylecheck/foreign_package/foreign_package.nimble | 2 | ||||
-rw-r--r-- | tests/stylecheck/t20397_1.nim | 4 | ||||
-rw-r--r-- | tests/stylecheck/tforeign_package.nim | 16 | ||||
-rw-r--r-- | tests/stylecheck/thint.nim | 43 | ||||
-rw-r--r-- | tests/stylecheck/treject.nim | 4 | ||||
-rw-r--r-- | tests/stylecheck/tusages.nim | 6 |
7 files changed, 68 insertions, 8 deletions
diff --git a/tests/stylecheck/foreign_package/foreign_package.nim b/tests/stylecheck/foreign_package/foreign_package.nim new file mode 100644 index 000000000..f95be006c --- /dev/null +++ b/tests/stylecheck/foreign_package/foreign_package.nim @@ -0,0 +1 @@ +include ../thint \ No newline at end of file diff --git a/tests/stylecheck/foreign_package/foreign_package.nimble b/tests/stylecheck/foreign_package/foreign_package.nimble new file mode 100644 index 000000000..a2c49e389 --- /dev/null +++ b/tests/stylecheck/foreign_package/foreign_package.nimble @@ -0,0 +1,2 @@ +# See `tstyleCheck` +# Needed to mark `mstyleCheck` as a foreign package. diff --git a/tests/stylecheck/t20397_1.nim b/tests/stylecheck/t20397_1.nim index 24f5791f8..76c03dca1 100644 --- a/tests/stylecheck/t20397_1.nim +++ b/tests/stylecheck/t20397_1.nim @@ -1,8 +1,8 @@ discard """ - matrix: "--styleCheck:off" + matrix: "--styleCheck:off --hint:Name:on" """ {.hintAsError[Name]:on.} var a_b = 1 discard a_b -{.hintAsError[Name]:off.} \ No newline at end of file +{.hintAsError[Name]:off.} diff --git a/tests/stylecheck/tforeign_package.nim b/tests/stylecheck/tforeign_package.nim new file mode 100644 index 000000000..8594ad802 --- /dev/null +++ b/tests/stylecheck/tforeign_package.nim @@ -0,0 +1,16 @@ +discard """ + matrix: "--errorMax:0 --styleCheck:error" + action: compile +""" + +import foreign_package/foreign_package + +# This call tests that: +# - an instantiation of a generic in a foreign package doesn't raise errors +# when the generic body contains: +# - definition and usage violations +# - builtin pragma usage violations +# - user pragma usage violations +# - definition violations in foreign packages are ignored +# - usage violations in foreign packages are ignored +genericProc[int]() diff --git a/tests/stylecheck/thint.nim b/tests/stylecheck/thint.nim new file mode 100644 index 000000000..c19aac1b8 --- /dev/null +++ b/tests/stylecheck/thint.nim @@ -0,0 +1,43 @@ +discard """ + matrix: "--styleCheck:hint" + action: compile +""" + +# Test violating ident definition: +{.pragma: user_pragma.} #[tt.Hint + ^ 'user_pragma' should be: 'userPragma' [Name] ]# + +# Test violating ident usage style matches definition style: +{.userPragma.} #[tt.Hint + ^ 'userPragma' should be: 'user_pragma' [template declared in thint.nim(7, 9)] [Name] ]# + +# Test violating builtin pragma usage style: +{.no_side_effect.}: #[tt.Hint + ^ 'no_side_effect' should be: 'noSideEffect' [Name] ]# + discard 0 + +# Test: +# - definition style violation +# - user pragma usage style violation +# - builtin pragma usage style violation +proc generic_proc*[T] {.no_destroy, userPragma.} = #[tt.Hint + ^ 'generic_proc' should be: 'genericProc' [Name]; tt.Hint + ^ 'no_destroy' should be: 'nodestroy' [Name]; tt.Hint + ^ 'userPragma' should be: 'user_pragma' [template declared in thint.nim(7, 9)] [Name] ]# + # Test definition style violation: + let snake_case = 0 #[tt.Hint + ^ 'snake_case' should be: 'snakeCase' [Name] ]# + # Test user pragma definition style violation: + {.pragma: another_user_pragma.} #[tt.Hint + ^ 'another_user_pragma' should be: 'anotherUserPragma' [Name] ]# + # Test user pragma usage style violation: + {.anotherUserPragma.} #[tt.Hint + ^ 'anotherUserPragma' should be: 'another_user_pragma' [template declared in thint.nim(31, 11)] [Name] ]# + # Test violating builtin pragma usage style: + {.no_side_effect.}: #[tt.Hint + ^ 'no_side_effect' should be: 'noSideEffect' [Name] ]# + # Test usage style violation: + discard snakeCase #[tt.Hint + ^ 'snakeCase' should be: 'snake_case' [let declared in thint.nim(28, 7)] [Name] ]# + +generic_proc[int]() diff --git a/tests/stylecheck/treject.nim b/tests/stylecheck/treject.nim index b9d97a58d..458a2d039 100644 --- a/tests/stylecheck/treject.nim +++ b/tests/stylecheck/treject.nim @@ -1,7 +1,7 @@ discard """ action: reject nimout: '''treject.nim(14, 13) Error: 'iD' should be: 'id' [field declared in treject.nim(9, 5)]''' - matrix: "--styleCheck:error --styleCheck:usages" + matrix: "--styleCheck:error --styleCheck:usages --hint:Name:on" """ type @@ -14,4 +14,4 @@ template hello = echo name.iD echo iD -hello() \ No newline at end of file +hello() diff --git a/tests/stylecheck/tusages.nim b/tests/stylecheck/tusages.nim index 2f99c70c5..b689dabb3 100644 --- a/tests/stylecheck/tusages.nim +++ b/tests/stylecheck/tusages.nim @@ -1,11 +1,9 @@ discard """ action: reject - nimout: '''tusages.nim(22, 5) Error: 'BAD_STYLE' should be: 'BADSTYLE' [proc declared in tusages.nim(11, 6)]''' - matrix: "--styleCheck:error --styleCheck:usages" + 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 |