diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2021-04-09 06:59:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-09 06:59:25 +0200 |
commit | 13b958eb45a3569acaa18f9381d28b8f37d42057 (patch) | |
tree | 846e4636e86ca13657646b8bdc9e92513e22fdc5 /tests/ic | |
parent | e4b64eee894ddbf41935d3b8aeed1448cd2b5e46 (diff) | |
download | Nim-13b958eb45a3569acaa18f9381d28b8f37d42057.tar.gz |
IC: added basic test case for methods (#17679)
* IC: added basic test case for methods * IC: better methods test
Diffstat (limited to 'tests/ic')
-rw-r--r-- | tests/ic/mbaseobj.nim | 7 | ||||
-rw-r--r-- | tests/ic/tmethods.nim | 28 |
2 files changed, 35 insertions, 0 deletions
diff --git a/tests/ic/mbaseobj.nim b/tests/ic/mbaseobj.nim new file mode 100644 index 000000000..0f4e4a90d --- /dev/null +++ b/tests/ic/mbaseobj.nim @@ -0,0 +1,7 @@ + +type + Base* = ref object of RootObj + s*: string + +method m*(b: Base) {.base.} = + echo "Base ", b.s diff --git a/tests/ic/tmethods.nim b/tests/ic/tmethods.nim new file mode 100644 index 000000000..251f26889 --- /dev/null +++ b/tests/ic/tmethods.nim @@ -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 + |