Skip to content

Commit

Permalink
Nim regression test for canBeImplicit
Browse files Browse the repository at this point in the history
  • Loading branch information
flyx committed Dec 21, 2023
1 parent c7e5a8a commit fde0644
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ jobs:
- windows-latest
- macOS-latest
nim-version:
- '2.0.x'
- stable
- devel
- '2.0.0'
- '2.0.2'
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -47,11 +46,4 @@ jobs:

- name: Test
run: |
nim lexerTests
nim parserTests
nim jsonTests
nim domTests
nim nativeTests
nim quickstartTests
nim hintsTests
nim presenterTests
nim test
2 changes: 1 addition & 1 deletion config.nims
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ task build, "Compile the YAML module into a library":
task test, "Run all tests":
--r
--verbosity:0
setCommand "c", "test/tests"
setCommand "c", "test/tnimregress"

task lexerTests, "Run lexer tests":
--r
Expand Down
33 changes: 33 additions & 0 deletions test/tnimregress.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import unittest, macros

type
Person = object
name: string

ContainerKind = enum
ckString, ckInt, ckBool, ckPerson, ckNone

Container = object
case kind: ContainerKind
of ckString:
strVal: string
of ckInt:
intVal: int
of ckBool:
boolVal: bool
of ckPerson:
personVal: Person
of ckNone:
discard

proc canBeImplicit(t: typedesc): string {.compileTime.} =
## returns empty string if type can be implicit, else the reason why it can't
let tDesc = getType(t)
if tDesc.kind != nnkObjectTy: return "type is not an object"
return ""

suite "Nim Regression Tests":
test "canBeImplicit":
const res = canBeImplicit(Container)
assert len(res) == 0, "unexpected error for canBeImplicit: " & res

0 comments on commit fde0644

Please sign in to comment.