Skip to content

Commit ffacee7

Browse files
committed
test: add more test cases for deducible parameters
1 parent 110aa2f commit ffacee7

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

regression-tests/pure2-bugfix-for-deducible-parameters.cpp2

+7
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,15 @@ main: () = {
1818
_ = :<T> (x: std::vector<std::vector<T>>) = {}(:std::vector<std::vector<i32>> = ());
1919
// Uncomment once `typename` is supported for template arguments.
2020
// _ = :<T, U> (x: std::pair<T, typename U::value_type>, y: U) = {}(:std::pair = (0, 0), z);
21+
_ = :<T, U> (x: std::array<T, U::value>, y: U) = {}(:std::array<i32, 0> = (), z);
2122
init(out z, z);
2223
id(z, z);
24+
25+
// Test that these are emitted unwrapped in case they are deducible.
26+
(copy f := :<T> (x: std::vector<std::type_identity_t<T>>) = {})
27+
static_assert(!std::is_invocable_v<decltype(f), std::vector<i32>>);
28+
(copy f := :<T> (x: std::vector<std::vector<T>>) = {})
29+
static_assert(std::is_invocable_v<decltype(f), std::vector<std::vector<i32>>>);
2330
}
2431

2532
v: <T> type = {

regression-tests/test-results/pure2-bugfix-for-deducible-parameters.cpp

+23-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "cpp2util.h"
88

99

10-
#line 25 "pure2-bugfix-for-deducible-parameters.cpp2"
10+
#line 32 "pure2-bugfix-for-deducible-parameters.cpp2"
1111
template<typename T> class v;
1212

1313

@@ -24,15 +24,15 @@ template<typename T> auto id(cpp2::in<std::integral_constant<cpp2::i32,T::value>
2424
auto main() -> int;
2525

2626

27-
#line 25 "pure2-bugfix-for-deducible-parameters.cpp2"
27+
#line 32 "pure2-bugfix-for-deducible-parameters.cpp2"
2828
template<typename T> class v {
2929
public: explicit v(T const& x);
30-
#line 26 "pure2-bugfix-for-deducible-parameters.cpp2"
30+
#line 33 "pure2-bugfix-for-deducible-parameters.cpp2"
3131
public: auto operator=(T const& x) -> v& ;
3232

3333
public: v(v const&) = delete; /* No 'that' constructor, suppress copy */
3434
public: auto operator=(v const&) -> void = delete;
35-
#line 27 "pure2-bugfix-for-deducible-parameters.cpp2"
35+
#line 34 "pure2-bugfix-for-deducible-parameters.cpp2"
3636
};
3737

3838

@@ -58,15 +58,31 @@ auto main() -> int{
5858
(void) []<typename T>(std::vector<std::vector<T>> const& x) -> void{}(std::vector<std::vector<cpp2::i32>>{});
5959
// Uncomment once `typename` is supported for template arguments.
6060
// _ = :<T, U> (x: std::pair<T, typename U::value_type>, y: U) = {}(:std::pair = (0, 0), z);
61+
(void) []<typename T, typename U>(std::array<T,U::value> const& x, U const& y) -> void{}(std::array<cpp2::i32,0>{}, z.value());
6162
init(cpp2::out(&z.value()), z.value());
6263
id(z.value(), std::move(z.value()));
64+
{
65+
auto f = []<typename T>(std::vector<std::type_identity_t<T>> const& x) -> void{};
66+
67+
// Test that these are emitted unwrapped in case they are deducible.
68+
69+
#line 27 "pure2-bugfix-for-deducible-parameters.cpp2"
70+
static_assert(!(std::is_invocable_v<decltype(f),std::vector<cpp2::i32>>));
71+
}
72+
{
73+
auto f = []<typename T>(std::vector<std::vector<T>> const& x) -> void{};
74+
75+
#line 29 "pure2-bugfix-for-deducible-parameters.cpp2"
76+
static_assert(std::is_invocable_v<decltype(f),std::vector<std::vector<cpp2::i32>>>);
77+
}
78+
#line 30 "pure2-bugfix-for-deducible-parameters.cpp2"
6379
}
6480

65-
#line 26 "pure2-bugfix-for-deducible-parameters.cpp2"
81+
#line 33 "pure2-bugfix-for-deducible-parameters.cpp2"
6682
template <typename T> v<T>::v(T const& x){}
67-
#line 26 "pure2-bugfix-for-deducible-parameters.cpp2"
83+
#line 33 "pure2-bugfix-for-deducible-parameters.cpp2"
6884
template <typename T> auto v<T>::operator=(T const& x) -> v& {
6985
return *this;
70-
#line 26 "pure2-bugfix-for-deducible-parameters.cpp2"
86+
#line 33 "pure2-bugfix-for-deducible-parameters.cpp2"
7187
}
7288

0 commit comments

Comments
 (0)