IC: added basic test case for methods (#17679)

* IC: added basic test case for methods

* IC: better methods test
This commit is contained in:
Andreas Rumpf 2021-04-09 06:59:25 +02:00 • committed by GitHub
commit 13b958eb45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 8 deletions

7
tests/ic/mbaseobj.nim Normal file
View file

@ -0,0 +1,7 @@
type
Base* = ref object of RootObj
s*: string
method m*(b: Base) {.base.} =
echo "Base ", b.s

28
tests/ic/tmethods.nim Normal file
View file

@ -0,0 +1,28 @@
discard """
output: '''Base abc'''
"""
import mbaseobj
var c = Base(s: "abc")
m c
#!EDIT!#
discard """
output: '''Base abc
Inherited abc'''
"""
import mbaseobj
type
Inherited = ref object of Base
method m(i: Inherited) =
procCall m(Base i)
echo "Inherited ", i.s
var c = Inherited(s: "abc")
m c