From 4dc1042c1d1e84da025e3f69d647815249ab8b18 Mon Sep 17 00:00:00 2001 From: Ade Attwood Date: Sat, 11 May 2024 10:39:22 +0100 Subject: [PATCH] test: add regex feature tests --- tests/features.rs | 2 +- tests/features/regex.feature | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/features/regex.feature diff --git a/tests/features.rs b/tests/features.rs index 4b8c7bf..fb4ad95 100644 --- a/tests/features.rs +++ b/tests/features.rs @@ -24,5 +24,5 @@ fn assert_output(world: &mut TestWorld, expected: String) { } fn main() { - futures::executor::block_on(TestWorld::run("tests/features/basic.feature")); + futures::executor::block_on(TestWorld::run("tests/features")); } diff --git a/tests/features/regex.feature b/tests/features/regex.feature new file mode 100644 index 0000000..cc77786 --- /dev/null +++ b/tests/features/regex.feature @@ -0,0 +1,19 @@ +Feature: Regex search and replace + + Scenario: You can search and replace with with a regular expression + Given Search is '(\w+)' + And Replace is 'new' + And Input is 'This is a' + Then Output is 'new new new' + + Scenario: You can use a '$' to replace a match group + Given Search is 'function (\w+)\(\)' + And Replace is 'fun $1()' + And Input is 'function foo()' + Then Output is 'fun foo()' + + Scenario: You can will need to wrap the match group when the match is against another word + Given Search is 'Hello (\w+)' + And Replace is 'Hello ${1}s' + And Input is 'Hello world' + Then Output is 'Hello worlds'