MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / test_exceptions_uncaught

Method test_exceptions_uncaught

test/test_core.py:1373–1406  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1371
1372 @with_all_eh_sjlj
1373 def test_exceptions_uncaught(self):
1374 src = r'''
1375 #include <stdio.h>
1376 #include <exception>
1377 struct X {
1378 ~X() {
1379 printf("exception? %s\n", std::uncaught_exceptions() ? "yes" : "no");
1380 }
1381 };
1382 int main() {
1383 printf("exception? %s\n", std::uncaught_exceptions() ? "yes" : "no");
1384 try {
1385 X x;
1386 throw 1;
1387 } catch(...) {
1388 printf("exception? %s\n", std::uncaught_exceptions() ? "yes" : "no");
1389 }
1390 printf("exception? %s\n", std::uncaught_exceptions() ? "yes" : "no");
1391 return 0;
1392 }
1393 ''&#x27;
1394 self.do_run(src, 'exception? no\nexception? yes\nexception? no\nexception? no\n')
1395
1396 src = r''&#x27;
1397 #include <fstream>
1398 #include <iostream>
1399 int main() {
1400 std::ofstream os("test");
1401 os << std::unitbuf << "foo"; // trigger a call to std::uncaught_exceptions from
1402 // std::basic_ostream::sentry::~sentry
1403 std::cout << "done\n";
1404 }
1405 ''&#x27;
1406 self.do_run(src, 'done\n')
1407
1408 @with_all_eh_sjlj
1409 def test_exceptions_uncaught_2(self):

Callers

nothing calls this directly

Calls 1

do_runMethod · 0.95

Tested by

no test coverage detected