Skip to content

Commit 03d96e6

Browse files
committed
add test
1 parent 0e2b298 commit 03d96e6

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
discard """
2+
output: '''
3+
hello some integer
4+
hello range
5+
hello tuple
6+
hello seq
7+
hello object
8+
hello distinct
9+
hello enum
10+
'''
11+
"""
12+
13+
# SomeInteger (OK)
14+
15+
proc foo[T : SomeInteger](arg: T)
16+
proc foo[T : SomeInteger](arg: T) =
17+
echo "hello some integer"
18+
foo(123)
19+
20+
# range (OK)
21+
22+
proc foo2[T : range[0..100]](arg: T)
23+
proc foo2[T : range[0..100]](arg: T) =
24+
echo "hello range"
25+
foo2(7)
26+
27+
# tuple (OK)
28+
29+
proc foo3[T : tuple](arg: T)
30+
proc foo3[T : tuple](arg: T) =
31+
echo "hello tuple"
32+
33+
foo3((a:123,b:321))
34+
35+
# seq (OK)
36+
37+
proc foo4[T: seq](arg: T)
38+
proc foo4[T: seq](arg: T) =
39+
echo "hello seq"
40+
41+
foo4(@[1,2,3])
42+
43+
# object (broken)
44+
45+
proc foo5[T : object](arg: T)
46+
proc foo5[T : object](arg: T) =
47+
echo "hello object"
48+
49+
type MyType = object
50+
var mt: MyType
51+
foo5(mt)
52+
53+
# distinct (broken)
54+
55+
proc foo6[T : distinct](arg: T)
56+
proc foo6[T : distinct](arg: T) =
57+
echo "hello distinct"
58+
59+
type MyDistinct = distinct string
60+
var md: MyDistinct
61+
foo6(md)
62+
63+
# enum (broken)
64+
65+
proc foo7[T : enum](arg: T)
66+
proc foo7[T : enum](arg: T) =
67+
echo "hello enum"
68+
69+
type MyEnum = enum
70+
ValueA
71+
foo7(ValueA)

0 commit comments

Comments
 (0)