@@ -467,42 +467,7 @@ private static void VerifyGenericWithStructRestrictionIsObject<Ts>(Ts value) whe
467
467
Expression . TypeIs ( Expression . Constant ( value , typeof ( Ts ) ) , typeof ( object ) ) ,
468
468
Enumerable . Empty < ParameterExpression > ( ) ) ;
469
469
Func < bool > f = e . Compile ( ) ;
470
-
471
- // compute the value with the expression tree
472
- bool etResult = default ( bool ) ;
473
- Exception etException = null ;
474
- try
475
- {
476
- etResult = f ( ) ;
477
- }
478
- catch ( Exception ex )
479
- {
480
- etException = ex ;
481
- }
482
-
483
- // compute the value with regular IL
484
- bool csResult = default ( bool ) ;
485
- Exception csException = null ;
486
- try
487
- {
488
- csResult = value is object ;
489
- }
490
- catch ( Exception ex )
491
- {
492
- csException = ex ;
493
- }
494
-
495
- // either both should have failed the same way or they should both produce the same result
496
- if ( etException != null || csException != null )
497
- {
498
- Assert . NotNull ( etException ) ;
499
- Assert . NotNull ( csException ) ;
500
- Assert . Equal ( csException . GetType ( ) , etException . GetType ( ) ) ;
501
- }
502
- else
503
- {
504
- Assert . Equal ( csResult , etResult ) ;
505
- }
470
+ Assert . True ( f ( ) ) ;
506
471
}
507
472
508
473
private static void VerifyGenericWithStructRestrictionIsValueType < Ts > ( Ts value ) where Ts : struct
@@ -512,42 +477,7 @@ private static void VerifyGenericWithStructRestrictionIsValueType<Ts>(Ts value)
512
477
Expression . TypeIs ( Expression . Constant ( value , typeof ( Ts ) ) , typeof ( ValueType ) ) ,
513
478
Enumerable . Empty < ParameterExpression > ( ) ) ;
514
479
Func < bool > f = e . Compile ( ) ;
515
-
516
- // compute the value with the expression tree
517
- bool etResult = default ( bool ) ;
518
- Exception etException = null ;
519
- try
520
- {
521
- etResult = f ( ) ;
522
- }
523
- catch ( Exception ex )
524
- {
525
- etException = ex ;
526
- }
527
-
528
- // compute the value with regular IL
529
- bool csResult = default ( bool ) ;
530
- Exception csException = null ;
531
- try
532
- {
533
- csResult = value is ValueType ;
534
- }
535
- catch ( Exception ex )
536
- {
537
- csException = ex ;
538
- }
539
-
540
- // either both should have failed the same way or they should both produce the same result
541
- if ( etException != null || csException != null )
542
- {
543
- Assert . NotNull ( etException ) ;
544
- Assert . NotNull ( csException ) ;
545
- Assert . Equal ( csException . GetType ( ) , etException . GetType ( ) ) ;
546
- }
547
- else
548
- {
549
- Assert . Equal ( csResult , etResult ) ;
550
- }
480
+ Assert . True ( f ( ) ) ;
551
481
}
552
482
553
483
#endregion
0 commit comments