This is another followup of D24562
These tests are of the form
try { action-that-may-throw assert(!exceptional-condition) assert(some-other-facts) } catch (relevant-exception) { assert(exceptional-condition) }
Under libcpp-no-exceptions there is still value in verifying
some-other-facts while avoiding the exceptional case. So for these tests
just conditionally check some-other-facts if exceptional-condition is
false. When exception are supported make sure that a true
exceptional-condition throws an exception
For the cases where an exception should've been thrown, are we not entering the undefined domain at this point?
What if instead, we define two versions of the test() function? one containing the current code as-is, and the other only handles the cases where exceptions are not expected, and we modify the main() function below so that the correct test() case is invoked depending on the presence / absence of exceptions? It's a bit more cumbersome than the current setup, but I'm not totally happy about treading into the undefined domain (if my understanding above is correct).