mstch/test/specs_lambdas.hpp

26 lines
1.1 KiB
C++
Raw Normal View History

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