Skip to content

Commit 34594f3

Browse files
committed
tests: add a dedicated test
1 parent 440b73e commit 34594f3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
discard """
2+
description: '''
3+
Tests to make sure the run-time 'of' works correctly when the base type
4+
is generic.
5+
'''
6+
targets: "c js vm"
7+
"""
8+
9+
type
10+
Base[T] = object of RootObj
11+
x: T
12+
DerivedA = object of Base[int]
13+
DerivedB = object of Base[float]
14+
15+
var a: ref RootObj = new(DerivedA)
16+
var b: ref RootObj = new(DerivedB)
17+
18+
doAssert a of DerivedA
19+
doAssert a of Base[int]
20+
doAssert not(a of DerivedB)
21+
doAssert not(a of Base[float])
22+
23+
doAssert b of DerivedB
24+
doAssert b of Base[float]
25+
doAssert not(b of DerivedA)
26+
doAssert not(b of Base[int])

0 commit comments

Comments
 (0)