(self)
| 1245 | |
| 1246 | @with_all_eh_sjlj |
| 1247 | def test_exceptions_3(self): |
| 1248 | src = r''' |
| 1249 | #include <iostream> |
| 1250 | #include <stdexcept> |
| 1251 | |
| 1252 | int main(int argc, char **argv) { |
| 1253 | if (argc != 2) { |
| 1254 | std::cout << "need an arg" << std::endl; |
| 1255 | return 1; |
| 1256 | } |
| 1257 | |
| 1258 | int arg = argv[1][0] - '0'; |
| 1259 | try { |
| 1260 | if (arg == 0) throw "a c string"; |
| 1261 | if (arg == 1) throw std::exception(); |
| 1262 | if (arg == 2) throw std::runtime_error("Hello"); |
| 1263 | } catch(const char * ex) { |
| 1264 | std::cout << "Caught C string: " << ex << std::endl; |
| 1265 | } catch(const std::exception &ex) { |
| 1266 | std::cout << "Caught exception: " << ex.what() << std::endl; |
| 1267 | } catch(...) { |
| 1268 | std::cout << "Caught something else" << std::endl; |
| 1269 | } |
| 1270 | |
| 1271 | std::cout << "Done.\n"; |
| 1272 | } |
| 1273 | ''' |
| 1274 | |
| 1275 | js_out = self.output_name('src') |
| 1276 | print('0') |
| 1277 | self.do_run(src, 'Caught C string: a c string\nDone.', args=['0']) |
| 1278 | print('1') |
| 1279 | self.do_run(js_out, 'Caught exception: std::exception\nDone.', args=['1'], no_build=True) |
| 1280 | print('2') |
| 1281 | self.do_run(js_out, 'Caught exception: Hello\nDone.', args=['2'], no_build=True) |
| 1282 | |
| 1283 | def test_exceptions_allowed(self): |
| 1284 | self.set_setting('EXCEPTION_CATCHING_ALLOWED', ["_Z12somefunctionv"]) |
nothing calls this directly
no test coverage detected