mirror of https://github.com/catchorg/Catch2.git
switch from ->* to <= in expression decomposer
<= chosen arbitrarily from comparison operators, but any of <=, >=, <, > have the same precedence. This now allows expressions containing any of *, /, %, +, -, << and >> to be used on the LHS. No tests broke, and the corresponding originally failing test in [tricky] was expanded and added to the main suite.
This commit is contained in:
parent
08dc8458c0
commit
6a6b41411c
|
@ -33,7 +33,7 @@
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
|
||||||
try { \
|
try { \
|
||||||
( __catchResult->*expr ).endExpression(); \
|
( __catchResult <= expr ).endExpression(); \
|
||||||
} \
|
} \
|
||||||
catch( ... ) { \
|
catch( ... ) { \
|
||||||
__catchResult.useActiveException( Catch::ResultDisposition::Normal ); \
|
__catchResult.useActiveException( Catch::ResultDisposition::Normal ); \
|
||||||
|
|
|
@ -41,8 +41,8 @@ namespace Catch {
|
||||||
ResultDisposition::Flags resultDisposition );
|
ResultDisposition::Flags resultDisposition );
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ExpressionLhs<T const&> operator->* ( T const& operand );
|
ExpressionLhs<T const&> operator<= ( T const& operand );
|
||||||
ExpressionLhs<bool> operator->* ( bool value );
|
ExpressionLhs<bool> operator<= ( bool value );
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ResultBuilder& operator << ( T const& value ) {
|
ResultBuilder& operator << ( T const& value ) {
|
||||||
|
@ -93,11 +93,11 @@ namespace Catch {
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline ExpressionLhs<T const&> ResultBuilder::operator->* ( T const& operand ) {
|
inline ExpressionLhs<T const&> ResultBuilder::operator<= ( T const& operand ) {
|
||||||
return ExpressionLhs<T const&>( *this, operand );
|
return ExpressionLhs<T const&>( *this, operand );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ExpressionLhs<bool> ResultBuilder::operator->* ( bool value ) {
|
inline ExpressionLhs<bool> ResultBuilder::operator<= ( bool value ) {
|
||||||
return ExpressionLhs<bool>( *this, value );
|
return ExpressionLhs<bool>( *this, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,18 +55,18 @@ TEST_CASE
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
TEST_CASE
|
TEST_CASE
|
||||||
(
|
(
|
||||||
"Where the LHS is not a simple value[failing]",
|
"Where the LHS is not a simple value",
|
||||||
"[Tricky][failing][.]"
|
"[Tricky]"
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
int a = 1;
|
int a = 1;
|
||||||
int b = 2;
|
int b = 2;
|
||||||
|
|
||||||
// This only captures part of the expression, but issues a warning about the rest
|
REQUIRE( a+1 == b );
|
||||||
REQUIRE( a+1 == b-1 );
|
REQUIRE( a < b );
|
||||||
*/
|
|
||||||
WARN( "Uncomment the code in this test to check that it gives a sensible compiler error" );
|
REQUIRE( a%2 == 1 );
|
||||||
|
REQUIRE( b%2 == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Opaque
|
struct Opaque
|
||||||
|
|
Loading…
Reference in New Issue