We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 440b73e commit 34594f3Copy full SHA for 34594f3
tests/lang_objects/objects/tgeneric_base_runtime_of.nim
@@ -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