mirror of
https://github.com/status-im/nim-stew.git
synced 2025-01-10 04:05:44 +00:00
37 lines
717 B
Nim
37 lines
717 B
Nim
import unittest,
|
|
../stew/objects
|
|
|
|
when defined(nimHasUsed):
|
|
{.used.}
|
|
|
|
suite "Objects":
|
|
test "baseType":
|
|
type
|
|
Foo = ref object of RootObj
|
|
Bar = ref object of Foo
|
|
Baz = object of RootObj
|
|
Bob = object of Baz
|
|
Bill = ref object of Bob
|
|
|
|
var
|
|
foo = Foo()
|
|
bar = Bar()
|
|
baz = Baz()
|
|
bob = Bob()
|
|
bill = Bill()
|
|
|
|
when defined(nimTypeNames):
|
|
check:
|
|
foo.baseType == "Foo:ObjectType"
|
|
bar.baseType == "Bar:ObjectType"
|
|
baz.baseType == "Baz"
|
|
bob.baseType == "Bob"
|
|
bill.baseType == "Bill:ObjectType"
|
|
|
|
proc f(o: Foo) =
|
|
check $o.type == "Foo"
|
|
check o.baseType == "Bar:ObjectType"
|
|
|
|
f(bar)
|
|
|