本文整理汇总了C++中kaguya::State::dostring方法的典型用法代码示例。如果您正苦于以下问题:C++ State::dostring方法的具体用法?C++ State::dostring怎么用?C++ State::dostring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kaguya::State
的用法示例。
在下文中一共展示了State::dostring方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
KAGUYA_TEST_FUNCTION_DEF(void_defaultarguments)(kaguya::State& state)
{
KAGUYA_VOID_FUNCTION_OVERLOADS(defargfn_wrapper, void_defargfn,0,3)
state["defargfn"] = kaguya::function(defargfn_wrapper);
state.dostring("defargfn()");
state.dostring("defargfn(3)");
state.dostring("defargfn(3,2)");
state.dostring("defargfn(3,2,1)");
}
示例2:
KAGUYA_TEST_FUNCTION_DEF(load_with_other_env)(kaguya::State& state)
{
state.dostring("foo = 'bar'");
state["otherEnv"] = kaguya::NewTable();
state.dostring("foo = 'dar'", state["otherEnv"]);
TEST_CHECK(state("assert(foo == 'bar')"));
TEST_CHECK(state("assert(otherEnv.foo == 'dar')"));
}
示例3:
KAGUYA_TEST_FUNCTION_DEF(defaultarguments)(kaguya::State& state)
{
state.setErrorHandler(error_fun);
state["defargfn"] = kaguya::function(defargfn_wrapper());
state["defargfn2"] = kaguya::function(defargfn_wrapper2());
state.dostring("defargfn('abc')");
last_error_message.find("[OPT]int,[OPT]int,[OPT]int");
state.dostring("defargfn2('abc')");
last_error_message.find("int,int,[OPT]int");
}
示例4:
KAGUYA_TEST_FUNCTION_DEF(defaultarguments)(kaguya::State& state)
{
state.setErrorHandler(error_fun);
state["defargfn"] = kaguya::function(defargfn_wrapper());
state["defargfn2"] = kaguya::function(defargfn_wrapper2());
std::string intname = kaguya::util::pretty_name(typeid(int));
if (intname == "int")
{
state.dostring("defargfn('abc')");
TEST_CHECK_M(last_error_message.find("[OPT]int,[OPT]int,[OPT]int") != std::string::npos, last_error_message);
state.dostring("defargfn2('abc',3)");
TEST_CHECK_M(last_error_message.find("int,int,[OPT]int") != std::string::npos, last_error_message);
}
}