Skip to content

Commit 5614fe1

Browse files
committed
test: use primaries and specializations in test cases
1 parent e63e15e commit 5614fe1

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1-
t: @struct <T: type> type = { }
2-
t: @struct <T: type> type < T> type requires true = { }
3-
main: () = { }
1+
t: @struct <T: type> type = {
2+
a: i32 = 1;
3+
}
4+
t: @struct <T: type> type < T> type requires std::is_void_v < T> = {
5+
b: i32 = 2;
6+
}
7+
v: <T> i32 = 1; // clang-format off
8+
v: <> type<void> i32 = 2; // clang-format on
9+
main: () = {
10+
[[assert Testing: t<i32>().a == 1]]
11+
[[assert Testing: t<void>().b == 2]]
12+
[[assert Testing: (v<i32>) == 1]]
13+
[[assert Testing: (v<void>) == 2]]
14+
}

regression-tests/test-results/pure2-template-specialization.cpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,33 @@
77
#include "cpp2util.h"
88

99
#line 1 "pure2-template-specialization.cpp2"
10-
template <typename T> class t;
11-
10+
template<typename T> class t;
11+
1212

1313
//=== Cpp2 type definitions and function declarations ===========================
1414

1515
#line 1 "pure2-template-specialization.cpp2"
16-
template <typename T> class t { };
17-
template<typename T> requires( true )
18-
class t<T> {};auto main() -> int;
19-
16+
template<typename T> class t {
17+
public: cpp2::i32 a {1};
18+
};
19+
template<typename T> requires( std::is_void_v<T> )
20+
class t<T> {public: cpp2::i32 b {2};
21+
};
22+
template<typename T> extern cpp2::i32 v;// clang-format off
23+
template<> extern cpp2::i32 v<void>;// clang-format on
24+
auto main() -> int;
25+
2026

2127
//=== Cpp2 function definitions =================================================
2228

2329

24-
#line 3 "pure2-template-specialization.cpp2"
25-
auto main() -> int {}
30+
#line 7 "pure2-template-specialization.cpp2"
31+
template<typename T> cpp2::i32 v {1};
32+
template<> cpp2::i32 v<void> {2};
33+
auto main() -> int{
34+
cpp2::Testing.expects(t<cpp2::i32>().a==1, "");
35+
cpp2::Testing.expects(t<void>().b==2, "");
36+
cpp2::Testing.expects((v<cpp2::i32>)==1, "");
37+
cpp2::Testing.expects((v<void>)==2, "");
38+
}
2639

0 commit comments

Comments
 (0)