mstch/test/specs_lambdas.hpp

26 lines
1.1 KiB
C++
Raw Normal View History

2015-10-01 18:40:51 +08:00
std::map<std::string,mstch::node> specs_lambdas {
{"Interpolation", mstch::lambda{[](const std::string&) -> mstch::node {
2015-05-05 20:15:47 +08:00
return std::string{"world"};
2015-10-01 18:40:51 +08:00
}}},
{"Interpolation - Expansion", mstch::lambda{[](const std::string&) -> mstch::node {
2015-05-05 20:15:47 +08:00
return std::string{"{{planet}}"};
2015-10-01 18:40:51 +08:00
}}},
{"Interpolation - Multiple Calls", mstch::lambda{[](const std::string&) -> mstch::node {
2015-05-05 20:15:47 +08:00
static int calls = 0; return ++calls;
2015-10-01 18:40:51 +08:00
}}},
{"Escaping", mstch::lambda{[](const std::string&) -> mstch::node {
2015-05-05 20:15:47 +08:00
return std::string{">"};
2015-10-01 18:40:51 +08:00
}}},
{"Section", mstch::lambda{[](const std::string& txt) -> mstch::node {
2015-05-05 20:15:47 +08:00
return std::string{(txt == "{{x}}") ? "yes" : "no"};
2015-10-01 18:40:51 +08:00
}}},
{"Section - Expansion", mstch::lambda{[](const std::string& txt) -> mstch::node {
2015-05-05 20:15:47 +08:00
return txt + std::string{"{{planet}}"} + txt;
2015-10-01 18:40:51 +08:00
}}},
{"Section - Multiple Calls", mstch::lambda{[](const std::string& txt) -> mstch::node {
2015-05-04 22:14:32 +08:00
return "__" + txt + "__";
2015-10-01 18:40:51 +08:00
}}},
2015-10-10 20:00:45 +08:00
{"Inverted Section", mstch::lambda{[](const std::string&) -> mstch::node {
2015-05-05 20:15:47 +08:00
return false;
2015-10-01 18:40:51 +08:00
}}}
2015-05-04 22:14:32 +08:00
};