diff options
author | metagn <metagngn@gmail.com> | 2023-06-16 18:14:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-16 17:14:47 +0200 |
commit | 88388040db4b169d51345bcabedb8bb70729f094 (patch) | |
tree | 1b7bc43672b0f02ba4e5857a6abf82bef7e87b8e | |
parent | 77beb152141f0efe4d5c93b784e42f973ba46551 (diff) | |
download | Nim-88388040db4b169d51345bcabedb8bb70729f094.tar.gz |
add tests to close #7223, close #11733 (#22111)
add test to close #7223, close #11733 closes #7223, closes #11733, were fixed by #22076
-rw-r--r-- | tests/template/mdotcall.nim | 28 | ||||
-rw-r--r-- | tests/template/mdotcall2.nim | 7 | ||||
-rw-r--r-- | tests/template/tdotcall.nim | 26 |
3 files changed, 53 insertions, 8 deletions
diff --git a/tests/template/mdotcall.nim b/tests/template/mdotcall.nim index 38a6ccae0..13dcbd824 100644 --- a/tests/template/mdotcall.nim +++ b/tests/template/mdotcall.nim @@ -20,3 +20,31 @@ proc bar(a: string): string = template baz*(a: string): string = var b = a.bar() b + +# issue #7223 + +import mdotcall2 + +type + Bytes* = seq[byte] + + BytesRange* = object + bytes*: Bytes + ibegin*, iend*: int + +proc privateProc(r: BytesRange): int = r.ibegin + +template rangeBeginAddr*(r: BytesRange): pointer = + r.bytes.baseAddr.shift(r.privateProc) + +# issue #11733 + +type ObjA* = object + +proc foo2(o: var ObjA) = discard +proc bar2(o: var ObjA, arg: Natural) = discard + +template publicTemplateObjSyntax*(o: var ObjA, arg: Natural, doStuff: untyped) = + o.foo2() + doStuff + o.bar2(arg) diff --git a/tests/template/mdotcall2.nim b/tests/template/mdotcall2.nim new file mode 100644 index 000000000..e906ac9d6 --- /dev/null +++ b/tests/template/mdotcall2.nim @@ -0,0 +1,7 @@ +# imported by mdotcall + +proc baseAddr*[T](x: openarray[T]): pointer = + cast[pointer](x) + +proc shift*(p: pointer, delta: int): pointer = + cast[pointer](cast[int](p) + delta) diff --git a/tests/template/tdotcall.nim b/tests/template/tdotcall.nim index abcbc8bd5..5fc991dd2 100644 --- a/tests/template/tdotcall.nim +++ b/tests/template/tdotcall.nim @@ -1,10 +1,20 @@ import mdotcall -# issue #20073 -works() -boom() - -# issue #7085 -doAssert baz("hello") == "hellobar" -doAssert baz"hello" == "hellobar" -doAssert "hello".baz == "hellobar" +block: # issue #20073 + works() + boom() + +block: # issue #7085 + doAssert baz("hello") == "hellobar" + doAssert baz"hello" == "hellobar" + doAssert "hello".baz == "hellobar" + +block: # issue #7223 + var r = BytesRange(bytes: @[1.byte, 2, 3], ibegin: 0, iend: 2) + var a = r.rangeBeginAddr + +block: # issue #11733 + var a: ObjA + var evaluated = false + a.publicTemplateObjSyntax(42): evaluated = true + doAssert evaluated |