Skip to content

Commit 1ad98fc

Browse files
test: Add test for fields/globals + templates (#290)
1 parent 4e750c3 commit 1ad98fc

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed

test/index/vars/templates.cc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
template <typename T>
2+
T zero = 0;
3+
4+
template <typename T>
5+
struct C {
6+
int mono = 0;
7+
8+
T from_param = 0;
9+
10+
static int static_mono;
11+
static const int static_const_mono = 0;
12+
13+
static T static_from_param;
14+
static const T static_const_from_param = T();
15+
16+
template <typename U>
17+
static const U static_templated = 0;
18+
};
19+
20+
template <typename T>
21+
int C<T>::static_mono = 0;
22+
23+
template <typename T>
24+
T C<T>::static_from_param = 0;
25+
26+
void test() {
27+
(void)zero<int>;
28+
29+
(void)C<int>().mono;
30+
(void)C<int>().from_param;
31+
32+
(void)C<int>::static_mono;
33+
(void)C<int>::static_const_mono;
34+
(void)C<int>::static_from_param;
35+
(void)C<int>::static_const_from_param;
36+
(void)C<int>::static_templated<int>;
37+
}

test/index/vars/templates.snapshot.cc

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
template <typename T>
2+
//^^^^^^^^ definition [..] `<file>/templates.cc`/
3+
// ^ definition local 0
4+
T zero = 0;
5+
//^ reference local 0
6+
// ^^^^ definition [..] zero.
7+
// ^^^^ definition [..] zero.
8+
9+
template <typename T>
10+
// ^ definition local 1
11+
struct C {
12+
// ^ definition [..] C#
13+
int mono = 0;
14+
// ^^^^ definition [..] C#mono.
15+
16+
T from_param = 0;
17+
// ^ reference local 1
18+
// ^^^^^^^^^^ definition [..] C#from_param.
19+
20+
static int static_mono;
21+
// ^^^^^^^^^^^ definition [..] C#static_mono.
22+
static const int static_const_mono = 0;
23+
// ^^^^^^^^^^^^^^^^^ definition [..] C#static_const_mono.
24+
25+
static T static_from_param;
26+
// ^ reference local 1
27+
// ^^^^^^^^^^^^^^^^^ definition [..] C#static_from_param.
28+
static const T static_const_from_param = T();
29+
// ^ reference local 1
30+
// ^^^^^^^^^^^^^^^^^^^^^^^ definition [..] C#static_const_from_param.
31+
// ^ reference local 1
32+
33+
template <typename U>
34+
// ^ definition local 2
35+
static const U static_templated = 0;
36+
// ^ reference local 2
37+
// ^^^^^^^^^^^^^^^^ definition [..] C#static_templated.
38+
};
39+
40+
template <typename T>
41+
// ^ definition local 3
42+
int C<T>::static_mono = 0;
43+
// ^ reference [..] C#
44+
// ^ reference [..] C#
45+
// ^^^^^^^^^^^ definition [..] C#static_mono.
46+
// ^^^^^^^^^^^ definition [..] C#static_mono.
47+
48+
template <typename T>
49+
// ^ definition local 4
50+
T C<T>::static_from_param = 0;
51+
//^ reference local 4
52+
// ^ reference [..] C#
53+
// ^ reference [..] C#
54+
// ^^^^^^^^^^^^^^^^^ definition [..] C#static_from_param.
55+
// ^^^^^^^^^^^^^^^^^ definition [..] C#static_from_param.
56+
57+
void test() {
58+
// ^^^^ definition [..] test(49f6e7a06ebc5aa8).
59+
(void)zero<int>;
60+
// ^^^^ reference [..] zero.
61+
62+
(void)C<int>().mono;
63+
// ^ reference [..] C#
64+
// ^^^^ reference [..] C#mono.
65+
(void)C<int>().from_param;
66+
// ^ reference [..] C#
67+
// ^^^^^^^^^^ reference [..] C#from_param.
68+
69+
(void)C<int>::static_mono;
70+
// ^ reference [..] C#
71+
// ^^^^^^^^^^^ reference [..] C#static_mono.
72+
(void)C<int>::static_const_mono;
73+
// ^ reference [..] C#
74+
// ^^^^^^^^^^^^^^^^^ reference [..] C#static_const_mono.
75+
(void)C<int>::static_from_param;
76+
// ^ reference [..] C#
77+
// ^^^^^^^^^^^^^^^^^ reference [..] C#static_from_param.
78+
(void)C<int>::static_const_from_param;
79+
// ^ reference [..] C#
80+
// ^^^^^^^^^^^^^^^^^^^^^^^ reference [..] C#static_const_from_param.
81+
(void)C<int>::static_templated<int>;
82+
// ^ reference [..] C#
83+
// ^^^^^^^^^^^^^^^^ reference [..] C#static_templated.
84+
}

0 commit comments

Comments
 (0)