Fixed unit tests (error messages now have the message class attached)

This commit is contained in:
Matthias Koefferlein 2023-07-29 01:13:25 +02:00
parent e766b12c3e
commit ad114f6137
2 changed files with 5 additions and 5 deletions

View File

@ -45,7 +45,7 @@ TEST (basic)
try { try {
pya::PythonInterpreter::instance ()->eval_string ("raise Exception(\"an error\")"); pya::PythonInterpreter::instance ()->eval_string ("raise Exception(\"an error\")");
} catch (tl::ScriptError &ex) { } catch (tl::ScriptError &ex) {
EXPECT_EQ (ex.basic_msg (), std::string ("an error")); EXPECT_EQ (ex.basic_msg (), std::string ("Exception: an error"));
EXPECT_EQ (ex.cls () == std::string ("exceptions.Exception") || ex.cls () == std::string ("Exception"), true); EXPECT_EQ (ex.cls () == std::string ("exceptions.Exception") || ex.cls () == std::string ("Exception"), true);
err = true; err = true;
} }
@ -56,7 +56,7 @@ TEST (basic)
try { try {
pya::PythonInterpreter::instance ()->eval_string ("Quatsch"); pya::PythonInterpreter::instance ()->eval_string ("Quatsch");
} catch (tl::ScriptError &ex) { } catch (tl::ScriptError &ex) {
EXPECT_EQ (ex.basic_msg (), std::string ("name 'Quatsch' is not defined")); EXPECT_EQ (ex.basic_msg (), std::string ("NameError: name 'Quatsch' is not defined"));
EXPECT_EQ (ex.cls () == std::string ("exceptions.NameError") || ex.cls () == std::string ("NameError"), true); EXPECT_EQ (ex.cls () == std::string ("exceptions.NameError") || ex.cls () == std::string ("NameError"), true);
err = true; err = true;
} }

View File

@ -45,7 +45,7 @@ TEST (basic)
try { try {
rba::RubyInterpreter::instance ()->eval_string ("raise \"an error\""); rba::RubyInterpreter::instance ()->eval_string ("raise \"an error\"");
} catch (tl::Exception &ex) { } catch (tl::Exception &ex) {
EXPECT_EQ (std::string (ex.msg (), 0, 8), std::string ("an error")); EXPECT_EQ (std::string (ex.msg (), 0, 22), std::string ("RuntimeError: an error"));
err = true; err = true;
} }
@ -56,8 +56,8 @@ TEST (basic)
try { try {
rba::RubyInterpreter::instance ()->eval_string ("Quatsch"); rba::RubyInterpreter::instance ()->eval_string ("Quatsch");
} catch (tl::Exception &ex) { } catch (tl::Exception &ex) {
EXPECT_EQ (std::string (ex.msg (), 0, 30) == std::string ("uninitialized constant Quatsch") || EXPECT_EQ (std::string (ex.msg (), 0, 41) == std::string ("NameError: uninitialized constant Quatsch") ||
std::string (ex.msg (), 0, 38) == std::string ("uninitialized constant Object::Quatsch"), std::string (ex.msg (), 0, 49) == std::string ("NameError: uninitialized constant Object::Quatsch"),
true); true);
err = true; err = true;
} }