Skip to content

Commit

Permalink
New test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
vczh committed Feb 11, 2020
1 parent 9ff646d commit 5086aa6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
Expand Up @@ -165,7 +165,6 @@ TEST_FILE
AssertExpr(pa, L"Simple2", L"Simple2", L"<::Simple2::[T]> ::Simple2::[T] __cdecl(::Simple2::[T], ::Simple2::[T]) * $PR", L"void __cdecl(...) * $PR");
AssertExpr(pa, L"Simple2<>", L"Simple2<>", L"<::Simple2::[T]> ::Simple2::[T] __cdecl(::Simple2::[T], ::Simple2::[T]) * $PR");
AssertExpr(pa, L"Simple2<bool>", L"Simple2<bool>", L"bool __cdecl(bool, bool) * $PR");
// test value argument
});

TEST_CATEGORY(L"Partially apply template arguments (variant)")
Expand Down Expand Up @@ -299,7 +298,6 @@ TEST_FILE
ASSERT_OVERLOADING_SIMPLE(Simple2(1, 2.0), void);
ASSERT_OVERLOADING_SIMPLE(Simple2(1.0, 2.f), void);
ASSERT_OVERLOADING_SIMPLE(Simple2(1.f, 2), void);
// test 0, 1 template arguments
});

TEST_CATEGORY(L"Template argument deduction (variant)")
Expand Down Expand Up @@ -330,16 +328,13 @@ TEST_FILE
L"::Types<{__int32 * $PR, double * $PR, float * $PR, bool & $PR, char & $PR, wchar_t & $PR}> $PR",
Types<int*, double*, float*, bool&, char&, wchar_t&>
);
// when the first vta is {}, it could be treated as "to be inferred", if function arguments suggest so
});

TEST_CATEGORY(L"Template argument deduction (kinds)")
{
using namespace Input__TestOverloadingGenericFunction_TypeInferKinds;
COMPILE_PROGRAM(program, pa, input);

// test 0, 1, 2, 3 arguments

ASSERT_OVERLOADING_FORMATTED_VERBOSE(LRef(Value<bool &>()), L"::Types<{bool $PR}> $PR", Types<bool>);
ASSERT_OVERLOADING_FORMATTED_VERBOSE(LRef(Value<bool const &>()), L"::Types<{bool const $PR}> $PR", Types<bool const>);
ASSERT_OVERLOADING_FORMATTED_VERBOSE(LRef(Value<bool volatile &>()), L"::Types<{bool volatile $PR}> $PR", Types<bool volatile>);
Expand Down Expand Up @@ -544,6 +539,7 @@ TEST_FILE
);
});

// when the first vta is {}, it could be treated as "to be inferred", if function arguments suggest so
// test known/unknown variadic arguments/parameters
// test generic methods (TestOverloadingGenericMethodInfer.cpp)
// test generic operators (TestOverloadingGenericMethodInfer.cpp)
Expand Down
25 changes: 25 additions & 0 deletions Tools/CppDoc/UnitTest/TestOverloadingGenericMethodInfer.cpp
@@ -1,5 +1,30 @@
#include "Util.h"

namespace Input__TestOverloadingGenericFunction_Method
{
TEST_DECL
(
template<typename... Ts>
struct MakeTuple
{
template<typename T>
MakeTuple<Ts..., T> operator<<(T);
};
);
}

TEST_FILE
{
TEST_CATEGORY(L"Generic methods (simple)")
{
using namespace Input__TestOverloadingGenericFunction_Method;
COMPILE_PROGRAM(program, pa, input);

ASSERT_OVERLOADING_VERBOSE(
(MakeTuple<>() << 1 << 1. << 1.f << 'x' << L'x' << true),
L"((MakeTuple<>() << (MakeTuple<>() << (MakeTuple<>() << (MakeTuple<>() << (MakeTuple<>() << (MakeTuple<>() << true)))))))",
L"::Tuple<{__int32 $PR, double $PR, float $PR, char $PR, wchar_t $PR, bool $PR}> $PR",
MakeTuple<int, double, float, char, wchar_t, bool>
);
});
}

0 comments on commit 5086aa6

Please sign in to comment.