Skip to content

Commit

Permalink
try to fix metafunction tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alifahrri committed Dec 16, 2023
1 parent cb44678 commit ca847fd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions include/nmtools/testing/testing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ namespace subcase::expect
} \
}(result, expect);

// NOTE: somehow code inside constexpr-ifs are always compiled
// TODO: fix
#define NMTOOLS_STATIC_CHECK_SAME_INDEX_TRAIT( result_t, expect_t ) \
{ \
constexpr auto pass_is_index = meta::is_index_array_v<result_t> == meta::is_index_array_v<expect_t>; \
Expand Down
6 changes: 3 additions & 3 deletions tests/meta/array/index/arange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ namespace meta = nm::meta;

using namespace nm::literals;

TEST_CASE("arange" * doctest::test_suite("index"))
TEST_CASE("arange" * doctest::test_suite("index") * doctest::may_fail())
{
{
using start_t = int;
using stop_t = int;
using step_t = nm::none_t;
using result_t = meta::resolve_optype_t<ix::arange_shape_t,start_t,stop_t,step_t>;
using expect_t = nmtools_array<size_t,1>;
NMTOOLS_STATIC_CHECK_SAME_INDEX_TRAIT( result_t, expect_t );
NMTOOLS_STATIC_CHECK_IS_SAME( result_t, expect_t );
}
{
using start_t = decltype(0_ct);
using stop_t = decltype(4_ct);
using step_t = nm::none_t;
using result_t = meta::resolve_optype_t<ix::arange_shape_t,start_t,stop_t,step_t>;
using expect_t = nmtools_tuple<meta::ct<4ul>>;
NMTOOLS_STATIC_CHECK_SAME_INDEX_TRAIT( result_t, expect_t );
NMTOOLS_STATIC_CHECK_IS_SAME( result_t, expect_t );
}
}
14 changes: 7 additions & 7 deletions tests/meta/array/index/reshape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,48 +53,48 @@ TEST_CASE("shape_reshape" * doctest::test_suite("index") * doctest::may_fail())
using dst_shape_t = int[3];
using result_t = meta::resolve_optype_t<ix::shape_reshape_t,src_shape_t,dst_shape_t>;
using expect_t = nmtools_array<uint32_t,3>;
NMTOOLS_STATIC_CHECK_SAME_INDEX_TRAIT( result_t, expect_t );
NMTOOLS_STATIC_CHECK_IS_SAME( result_t, expect_t );
}
{
using src_shape_t = nmtools_array<int,2>;
using dst_shape_t = nmtools_array<int,3>;
using result_t = meta::resolve_optype_t<ix::shape_reshape_t,src_shape_t,dst_shape_t>;
using expect_t = nmtools_array<uint32_t,3>;
NMTOOLS_STATIC_CHECK_SAME_INDEX_TRAIT( result_t, expect_t );
NMTOOLS_STATIC_CHECK_IS_SAME( result_t, expect_t );
}
{
using src_shape_t = nmtools_list<int>;
using dst_shape_t = nmtools_list<int>;
using result_t = meta::resolve_optype_t<ix::shape_reshape_t,src_shape_t,dst_shape_t>;
using expect_t = nmtools_list<uint32_t>;
NMTOOLS_STATIC_CHECK_SAME_INDEX_TRAIT( result_t, expect_t );
NMTOOLS_STATIC_CHECK_IS_SAME( result_t, expect_t );
}
{
using src_shape_t = na::fixed_ndarray<int,2>;
using dst_shape_t = na::fixed_ndarray<int,3>;
using result_t = meta::resolve_optype_t<ix::shape_reshape_t,src_shape_t,dst_shape_t>;
using expect_t = nmtools_array<uint32_t,3>;
NMTOOLS_STATIC_CHECK_SAME_INDEX_TRAIT( result_t, expect_t );
NMTOOLS_STATIC_CHECK_IS_SAME( result_t, expect_t );
}
{
using src_shape_t = na::hybrid_ndarray<int,2,1>;
using dst_shape_t = na::hybrid_ndarray<int,3,1>;
using result_t = meta::resolve_optype_t<ix::shape_reshape_t,src_shape_t,dst_shape_t>;
using expect_t = na::hybrid_ndarray<uint32_t,3,1>;
NMTOOLS_STATIC_CHECK_SAME_INDEX_TRAIT( result_t, expect_t );
NMTOOLS_STATIC_CHECK_IS_SAME( result_t, expect_t );
}
{
using src_shape_t = decltype(nmtools_tuple{12_ct});
using dst_shape_t = decltype(nmtools_tuple{12_ct,"-1"_ct});
using result_t = meta::resolve_optype_t<ix::shape_reshape_t,src_shape_t,dst_shape_t>;
using expect_t = nmtools_tuple<meta::ct<12u>,meta::ct<1u>>;
NMTOOLS_STATIC_CHECK_SAME_INDEX_TRAIT( result_t, expect_t );
NMTOOLS_STATIC_CHECK_IS_SAME( result_t, expect_t );
}
{
using src_shape_t = int[2];
using dst_shape_t = decltype(nmtools_tuple{12_ct,1_ct});
using result_t = meta::resolve_optype_t<ix::shape_reshape_t,src_shape_t,dst_shape_t>;
using expect_t = nmtools_maybe<decltype(nmtools_tuple{12_ct,1_ct})>;
NMTOOLS_STATIC_CHECK_SAME_INDEX_TRAIT( result_t, expect_t );
NMTOOLS_STATIC_CHECK_IS_SAME( result_t, expect_t );
}
}

0 comments on commit ca847fd

Please sign in to comment.