xo-interpreter2: report_memory_use() unit test
This commit is contained in:
parent
a41ff13f09
commit
a1e85d65bc
3 changed files with 44 additions and 1 deletions
|
|
@ -25,6 +25,12 @@ namespace xo {
|
|||
return retval;
|
||||
}
|
||||
|
||||
VsmConfig with_parser_debug_flag(bool x) const {
|
||||
VsmConfig retval = *this;
|
||||
retval.rdr_config_.parser_debug_flag_ = x;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/** true for interactive parser session; false for batch session **/
|
||||
bool interactive_flag_ = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ namespace xo {
|
|||
// outer loop: fetch one line of interactive input
|
||||
while (replxx_getline(interactive_, vsm_.is_at_toplevel(), rx_, &input)) {
|
||||
|
||||
// inner lo9op: consume up to one expression at a time.
|
||||
// inner loop: consume up to one expression at a time.
|
||||
while (!input.empty() && this->_read_eval_print(&input, false /*eof*/))
|
||||
{
|
||||
;
|
||||
|
|
|
|||
|
|
@ -584,6 +584,43 @@ namespace xo {
|
|||
log && vsm_fixture.log_memory_layout(&log);
|
||||
}
|
||||
|
||||
TEST_CASE("VirtualSchematikaMachine-report_memory_use", "[interpreter2][VSM]")
|
||||
{
|
||||
const auto & testname = Catch::getResultCapture().getCurrentTestName();
|
||||
|
||||
bool c_debug_flag = false;
|
||||
scope log(XO_DEBUG(c_debug_flag), xtag("test", testname));
|
||||
|
||||
VsmFixture vsm_fixture(testname, c_debug_flag,
|
||||
VsmConfig().with_parser_debug_flag(c_debug_flag));
|
||||
auto & vsm = vsm_fixture.vsm_;
|
||||
|
||||
bool eof_flag = true;
|
||||
|
||||
vsm.begin_interactive_session();
|
||||
|
||||
span_type input = span_type::from_cstr("report_memory_use();");
|
||||
|
||||
log && log(xtag("input", input));
|
||||
|
||||
VsmResultExt res
|
||||
= vsm.read_eval_print(input, eof_flag);
|
||||
|
||||
REQUIRE(res.is_value());
|
||||
REQUIRE(res.value());
|
||||
|
||||
log && log(xtag("res.tseq", res.value()->_typeseq()),
|
||||
xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq())));
|
||||
|
||||
auto x = obj<AGCObject,DBoolean>::from(*res.value());
|
||||
REQUIRE(x);
|
||||
REQUIRE(x->value() == true);
|
||||
|
||||
REQUIRE(res.remaining_.size() == 1);
|
||||
REQUIRE(*res.remaining_.lo() == '\n');
|
||||
|
||||
//log && vsm_fixture.log_memory_layout(&log);
|
||||
}
|
||||
} /*namespace ut*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue