forked from nim-lang/Nim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IC: added basic test case for methods (nim-lang#17679)
* IC: added basic test case for methods * IC: better methods test
- Loading branch information
Showing
4 changed files
with
62 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
type | ||
Base* = ref object of RootObj | ||
s*: string | ||
|
||
method m*(b: Base) {.base.} = | ||
echo "Base ", b.s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|