From 535055eff8b67dc8ca7fb0283872cb91bd6dd07a Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 1 Aug 2015 12:44:22 -0600 Subject: [PATCH] Add test to see how many exceptions are during simple use --- samples/test_num_exceptions.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 samples/test_num_exceptions.cpp diff --git a/samples/test_num_exceptions.cpp b/samples/test_num_exceptions.cpp new file mode 100644 index 0000000..371d7f1 --- /dev/null +++ b/samples/test_num_exceptions.cpp @@ -0,0 +1,32 @@ +#include +#include +#include +#include + +int main( int argc , char * argv[] ) +{ + chaiscript::ChaiScript ch( chaiscript::Std_Lib::library( ) ); + + static const char script[ ] = + R""( + + class Rectangle + { + def Rectangle() { } + } + + var rect = Rectangle( ); + + )""; + + try + { + ch.eval( script ); + } + catch ( std::exception e ) + { + printf( " >>> Exception thrown: %s \n" , e.what( ) ); + } + + return 1; +}