update tests because AAAAHHHH exceptions

This commit is contained in:
ThePhD 2018-03-22 10:59:37 -04:00
parent 0b4548bed3
commit 8e8dd379ff
2 changed files with 52 additions and 51 deletions

View File

@ -8,7 +8,7 @@ int main () {
};
sol::state lua;
lua.open_libraries();
lua.open_libraries(sol::lib::base);
lua.new_usertype<B>("B",
// bind as variable
"b", &B::bvar,
@ -18,10 +18,11 @@ int main () {
B b;
lua.set("b", &b);
lua.script("x = b:f()");
lua.script("y = b.b");
int x = lua["x"];
int y = lua["y"];
assert(x == 24);
assert(y == 24);
lua.script(R"(x = b:f()
y = b.b
assert(x == 24)
assert(y == 24)
)");
return 0;
}

View File

@ -335,7 +335,7 @@ TEST_CASE("functions/returning functions from C++", "check to see if returning a
}
}
#if defined(SOL_LUAJIT) || (defined(_WIN32) && (defined(_WIN64)))
#if !defined(SOL2_CI)
TEST_CASE("functions/function_result and protected_function_result", "Function result should be the beefy return type for sol::function that allows for error checking and error handlers") {
sol::state lua;
lua.open_libraries(sol::lib::base, sol::lib::debug);
@ -1490,51 +1490,51 @@ TEST_CASE("functions/unique_usertype overloading", "make sure overloading can wo
};
}
TEST_CASE("functions/lua style default arguments", "allow default arguments using sol::reference and sol::object") {
auto def_f1 = [](sol::object defaulted) -> int {
bool inactive = defaulted == sol::lua_nil; // inactive by default
if (inactive) {
return 20;
}
return 10;
TEST_CASE("functions/lua style default arguments", "allow default arguments using sol::reference and sol::object") {
auto def_f1 = [](sol::object defaulted) -> int {
bool inactive = defaulted == sol::lua_nil; // inactive by default
if (inactive) {
return 20;
}
return 10;
};
auto def_f2 = [](sol::reference defaulted) -> int {
bool inactive = defaulted == sol::lua_nil; // inactive by default
if (inactive) {
return 20;
}
return 10;
auto def_f2 = [](sol::reference defaulted) -> int {
bool inactive = defaulted == sol::lua_nil; // inactive by default
if (inactive) {
return 20;
}
return 10;
};
auto def_f3 = [](sol::stack_reference defaulted) -> int {
bool inactive = defaulted == sol::lua_nil; // inactive by default
if (inactive) {
return 20;
}
return 10;
};
sol::state lua;
lua.set_function("f1", def_f1);
lua.set_function("f2", def_f2);
lua.set_function("f3", def_f3);
auto result = lua.safe_script(R"(
v1d, v1nd = f1(), f1(1)
v2d, v2nd = f2(), f2(1)
v3d, v3nd = f3(), f3(1)
)", sol::script_pass_on_error);
REQUIRE(result.valid());
int v1d = lua["v1d"];
int v1nd = lua["v1nd"];
int v2d = lua["v2d"];
int v2nd = lua["v2nd"];
int v3d = lua["v3d"];
int v3nd = lua["v3nd"];
REQUIRE(20 == v1d);
REQUIRE(20 == v2d);
REQUIRE(20 == v3d);
REQUIRE(10 == v1nd);
REQUIRE(10 == v2nd);
auto def_f3 = [](sol::stack_reference defaulted) -> int {
bool inactive = defaulted == sol::lua_nil; // inactive by default
if (inactive) {
return 20;
}
return 10;
};
sol::state lua;
lua.set_function("f1", def_f1);
lua.set_function("f2", def_f2);
lua.set_function("f3", def_f3);
auto result = lua.safe_script(R"(
v1d, v1nd = f1(), f1(1)
v2d, v2nd = f2(), f2(1)
v3d, v3nd = f3(), f3(1)
)", sol::script_pass_on_error);
REQUIRE(result.valid());
int v1d = lua["v1d"];
int v1nd = lua["v1nd"];
int v2d = lua["v2d"];
int v2nd = lua["v2nd"];
int v3d = lua["v3d"];
int v3nd = lua["v3nd"];
REQUIRE(20 == v1d);
REQUIRE(20 == v2d);
REQUIRE(20 == v3d);
REQUIRE(10 == v1nd);
REQUIRE(10 == v2nd);
REQUIRE(10 == v3nd);
}