From fde0644a85caaa105893b54c06d26f46e24e49ed Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Thu, 21 Dec 2023 16:47:42 +0100 Subject: [PATCH] Nim regression test for canBeImplicit --- .github/workflows/action.yml | 14 +++----------- config.nims | 2 +- test/tnimregress.nim | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 test/tnimregress.nim diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index 72b26c16..0e78fdf6 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -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 @@ -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 diff --git a/config.nims b/config.nims index 5ddb0b3f..5db7d417 100644 --- a/config.nims +++ b/config.nims @@ -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 diff --git a/test/tnimregress.nim b/test/tnimregress.nim new file mode 100644 index 00000000..21546ec1 --- /dev/null +++ b/test/tnimregress.nim @@ -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 + \ No newline at end of file