Skip to content

Commit 11c9d47

Browse files
committed
Adjust regression-tests to new code generation of internal_as
1 parent 85dd05d commit 11c9d47

5 files changed

+9
-9
lines changed

regression-tests/test-results/pure2-inspect-expression-in-generic-function-multiple-types.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ auto test_generic(auto const& x) -> void{
3535
<< std::setw(30) << typeid(x).name()
3636
<< " value is "
3737
<< [&] () -> std::string { auto&& __expr = x;
38-
if (cpp2::is<int>(__expr)) { if constexpr( requires{"integer " + std::to_string(cpp2::as<int>(x));} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF("integer " + std::to_string(cpp2::as<int>(x))),std::string> ) return "integer " + std::to_string(cpp2::as<int>(x)); else return std::string{}; else return std::string{}; }
39-
else if (cpp2::is<std::string>(__expr)) { if constexpr( requires{'"' + cpp2::as<std::string>(x) + '"';} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF('"' + cpp2::as<std::string>(x) + '"'),std::string> ) return '"' + cpp2::as<std::string>(x) + '"'; else return std::string{}; else return std::string{}; }
38+
if (cpp2::is<int>(__expr)) { if constexpr( requires{"integer " + std::to_string(cpp2::internal_as<cpp2::cast_failure_policy::throws, int>(x));} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF(("integer " + std::to_string(cpp2::internal_as<cpp2::cast_failure_policy::throws, int>(x)))),std::string> ) return "integer " + std::to_string(cpp2::as<int>(x)); else return std::string{}; else return std::string{}; }
39+
else if (cpp2::is<std::string>(__expr)) { if constexpr( requires{'"' + cpp2::internal_as<cpp2::cast_failure_policy::throws, std::string>(x) + '"';} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF(('"' + cpp2::internal_as<cpp2::cast_failure_policy::throws, std::string>(x) + '"')),std::string> ) return '"' + cpp2::as<std::string>(x) + '"'; else return std::string{}; else return std::string{}; }
4040
else return "not an int or string"; }
4141
()
4242
<< "\n";

regression-tests/test-results/pure2-inspect-expression-with-as-in-generic-function.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ auto print_an_int(auto const& x) -> void{
2222
<< std::setw(30) << typeid(x).name()
2323
<< " value is "
2424
<< [&] () -> std::string { auto&& __expr = x;
25-
if (cpp2::is<int>(__expr)) { if constexpr( requires{std::to_string(cpp2::as<int>(x));} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF(std::to_string(cpp2::as<int>(x))),std::string> ) return std::to_string(cpp2::as<int>(x)); else return std::string{}; else return std::string{}; }
25+
if (cpp2::is<int>(__expr)) { if constexpr( requires{std::to_string(cpp2::internal_as<cpp2::cast_failure_policy::throws, int>(x));} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF((std::to_string(cpp2::internal_as<cpp2::cast_failure_policy::throws, int>(x)))),std::string> ) return std::to_string(cpp2::as<int>(x)); else return std::string{}; else return std::string{}; }
2626
else return "not an int"; }
2727
()
2828
<< "\n";

regression-tests/test-results/pure2-inspect-fallback-with-variant-any-optional.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ auto test_generic(auto const& x) -> void{
2828
std::cout
2929
<< "\n" << typeid(x).name() << "\n ..."
3030
<< [&] () -> std::string { auto&& __expr = x;
31-
if (cpp2::is<std::string>(__expr)) { if constexpr( requires{" matches std::string";} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF(" matches std::string"),std::string> ) return " matches std::string"; else return std::string{}; else return std::string{}; }
32-
else if (cpp2::is<std::variant<int,std::string>>(__expr)) { if constexpr( requires{" matches std::variant<int, std::string>";} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF(" matches std::variant<int, std::string>"),std::string> ) return " matches std::variant<int, std::string>"; else return std::string{}; else return std::string{}; }
33-
else if (cpp2::is<std::any>(__expr)) { if constexpr( requires{" matches std::any";} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF(" matches std::any"),std::string> ) return " matches std::any"; else return std::string{}; else return std::string{}; }
34-
else if (cpp2::is<std::optional<std::string>>(__expr)) { if constexpr( requires{" matches std::optional<std::string>";} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF(" matches std::optional<std::string>"),std::string> ) return " matches std::optional<std::string>"; else return std::string{}; else return std::string{}; }
31+
if (cpp2::is<std::string>(__expr)) { if constexpr( requires{" matches std::string";} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF((" matches std::string")),std::string> ) return " matches std::string"; else return std::string{}; else return std::string{}; }
32+
else if (cpp2::is<std::variant<int,std::string>>(__expr)) { if constexpr( requires{" matches std::variant<int, std::string>";} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF((" matches std::variant<int, std::string>")),std::string> ) return " matches std::variant<int, std::string>"; else return std::string{}; else return std::string{}; }
33+
else if (cpp2::is<std::any>(__expr)) { if constexpr( requires{" matches std::any";} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF((" matches std::any")),std::string> ) return " matches std::any"; else return std::string{}; else return std::string{}; }
34+
else if (cpp2::is<std::optional<std::string>>(__expr)) { if constexpr( requires{" matches std::optional<std::string>";} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF((" matches std::optional<std::string>")),std::string> ) return " matches std::optional<std::string>"; else return std::string{}; else return std::string{}; }
3535
else return " no match"; }
3636
()
3737
<< "\n";

regression-tests/test-results/pure2-inspect-generic-void-empty-with-variant-any-optional.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ auto test_generic(auto const& x) -> void{
3232
std::cout
3333
<< "\n" << typeid(x).name() << "\n ..."
3434
<< [&] () -> std::string { auto&& __expr = x;
35-
if (cpp2::is<void>(__expr)) { if constexpr( requires{" VOYDE AND EMPTIE";} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF(" VOYDE AND EMPTIE"),std::string> ) return " VOYDE AND EMPTIE"; else return std::string{}; else return std::string{}; }
35+
if (cpp2::is<void>(__expr)) { if constexpr( requires{" VOYDE AND EMPTIE";} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF((" VOYDE AND EMPTIE")),std::string> ) return " VOYDE AND EMPTIE"; else return std::string{}; else return std::string{}; }
3636
else return " no match"; }
3737
()
3838
<< "\n";

regression-tests/test-results/pure2-type-safety-2-with-inspect-expression.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ auto test_generic(auto const& x) -> void{
3535
<< std::setw(30) << typeid(x).name()
3636
<< " value is "
3737
<< [&] () -> std::string { auto&& __expr = x;
38-
if (cpp2::is<int>(__expr)) { if constexpr( requires{std::to_string(cpp2::as<int>(x));} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF(std::to_string(cpp2::as<int>(x))),std::string> ) return std::to_string(cpp2::as<int>(x)); else return std::string{}; else return std::string{}; }
38+
if (cpp2::is<int>(__expr)) { if constexpr( requires{std::to_string(cpp2::internal_as<cpp2::cast_failure_policy::throws, int>(x));} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF((std::to_string(cpp2::internal_as<cpp2::cast_failure_policy::throws, int>(x)))),std::string> ) return std::to_string(cpp2::as<int>(x)); else return std::string{}; else return std::string{}; }
3939
else return "not an int"; }
4040
()
4141
<< "\n";

0 commit comments

Comments
 (0)