mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-13 17:11:21 +00:00
Isolated emscripten in new lib
This commit is contained in:
48
lib/emscripten/emtests/test_exceptions_destroy_virtual.cpp
Normal file
48
lib/emscripten/emtests/test_exceptions_destroy_virtual.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
// Copyright 2014 The Emscripten Authors. All rights reserved.
|
||||
// Emscripten is available under two separate licenses, the MIT license and the
|
||||
// University of Illinois/NCSA Open Source License. Both these licenses can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
namespace
|
||||
{
|
||||
// An exception that can be derived virtually or not based on macro
|
||||
// definition.
|
||||
class test_exception
|
||||
: virtual public std::runtime_error
|
||||
{
|
||||
public:
|
||||
test_exception()
|
||||
: std::runtime_error("test_exception")
|
||||
{}
|
||||
};
|
||||
|
||||
// Test class that logs its construction and destruction.
|
||||
class TestClass
|
||||
{
|
||||
public:
|
||||
TestClass()
|
||||
{ std::cout << "TestClass::Construction" << std::endl; }
|
||||
|
||||
~TestClass()
|
||||
{ std::cout << "TestClass::Destruction" << std::endl; }
|
||||
};
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
try {
|
||||
TestClass testClass;
|
||||
throw test_exception();
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
std::cout << "Caught exception: " << ex.what() << std::endl;
|
||||
}
|
||||
|
||||
// Something goes very wrong between handling the exception and resuming
|
||||
// normal execution when the exception is virtually derived.
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user