Skip to content
Snippets Groups Projects
Commit c0ea7d66 authored by ilor's avatar ilor
Browse files

Allow checking variable state in tests, use it in iterations.ccl, explain in example.ccl

parent 4a616ed2
Branches
No related merge requests found
......@@ -4,6 +4,7 @@ After the --- line comes the first test -- the operator string, followed by an e
If the first operator line is "position=XXX", position is parsed as an int and that is used as the current position in the sentence for this and any following tests. Default position is 0.
Tests are separated from one another by a --- line.
This test loads no sentence, but can change the position anyway. Tagset is kipi by default.
Variable state can be checked by a name=value lines after the expected output.
tagset=ikipi
---
equal(["aaa"], "aaa")
......@@ -13,3 +14,10 @@ True
lower(["A"])
["a"]
---
setvar($b:A, setvar($t:B, subst))
True
A=True
B={subst}
tagset=kipi
sentence=t01.xml
---
rlook(begin, end, $Test, True)
True
---
llook(0, end, $V, False)
False
V=nowhere
......@@ -98,7 +98,24 @@ void test_one_item_actual(const compare_test& c)
expected_output = "";
operator_string = "";
++line_no;
std::getline(ifs_in, line);
while (ifs_in.good() && line != "---" && line != "") {
std::getline(ifs_in, line);
std::vector<std::string> fields;
boost::algorithm::split(fields, line, boost::is_any_of(separators));
if (fields.size() == 2) {
boost::shared_ptr<Wccl::Value> v;
v = fu.variables()->get<Wccl::Value>(fields[0]);
if (!v) {
BOOST_ERROR("Invalid variable name in test: "
<< fields[0] << " on line " << line_no);
} else if (v->to_string(tagset) != fields[1]) {
BOOST_ERROR("Variable " << fields[0]
<< "value mismatch on line "
<< line_no << "\n: expected " << fields[1]
<< " got " << v->to_string(tagset));
}
}
}
BOOST_REQUIRE(line == "---" || line == "");
} else {
if (operator_string.empty() && line.substr(0, 9) == "position=") {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment