diff options
| author | Mistivia <i@mistivia.com> | 2025-01-16 15:43:04 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-01-16 15:53:58 +0800 |
| commit | 8689a7c78c50676ea739f52fbcee9f091709f5c0 (patch) | |
| tree | bbb72c68e5e1753f751133941a402caa43e29a16 /lib/mstch/test/specs_lambdas.hpp | |
| parent | 00afb767ae37488d99f78363d031b898b1932354 (diff) | |
add mstch
Diffstat (limited to 'lib/mstch/test/specs_lambdas.hpp')
| -rw-r--r-- | lib/mstch/test/specs_lambdas.hpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/mstch/test/specs_lambdas.hpp b/lib/mstch/test/specs_lambdas.hpp new file mode 100644 index 0000000..603c9b6 --- /dev/null +++ b/lib/mstch/test/specs_lambdas.hpp @@ -0,0 +1,32 @@ +std::map<std::string,mstch::node> specs_lambdas { + {"Interpolation", mstch::lambda{[](const std::string&) -> mstch::node { + return std::string{"world"}; + }}}, + {"Interpolation - Expansion", mstch::lambda{[](const std::string&) -> mstch::node { + return std::string{"{{planet}}"}; + }}}, + {"Interpolation - Alternate Delimiters", mstch::lambda{[](const std::string&) -> mstch::node { + return std::string{"|planet| => {{planet}}"}; + }}}, + {"Interpolation - Multiple Calls", mstch::lambda{[](const std::string&) -> mstch::node { + static int calls = 0; return ++calls; + }}}, + {"Escaping", mstch::lambda{[](const std::string&) -> mstch::node { + return std::string{">"}; + }}}, + {"Section", mstch::lambda{[](const std::string& txt) -> mstch::node { + return std::string{(txt == "{{x}}") ? "yes" : "no"}; + }}}, + {"Section - Expansion", mstch::lambda{[](const std::string& txt) -> mstch::node { + return txt + std::string{"{{planet}}"} + txt; + }}}, + {"Section - Alternate Delimiters", mstch::lambda{[](const std::string& txt) -> mstch::node { + return txt + std::string{"{{planet}} => |planet|"} + txt; + }}}, + {"Section - Multiple Calls", mstch::lambda{[](const std::string& txt) -> mstch::node { + return "__" + txt + "__"; + }}}, + {"Inverted Section", mstch::lambda{[](const std::string&) -> mstch::node { + return false; + }}} +};
\ No newline at end of file |
