From 05ea35e25dcb03fc019be9ec0ede7e4782bae6b4 Mon Sep 17 00:00:00 2001 From: William Boman Date: Mon, 26 Dec 2022 16:50:40 +0100 Subject: feat(functional): add strip_{prefix,suffix} (#803) --- tests/mason-core/functional/string_spec.lua | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'tests/mason-core/functional') diff --git a/tests/mason-core/functional/string_spec.lua b/tests/mason-core/functional/string_spec.lua index 02062f4c..30dea069 100644 --- a/tests/mason-core/functional/string_spec.lua +++ b/tests/mason-core/functional/string_spec.lua @@ -55,7 +55,22 @@ Ipsum assert.equals("HELLO!", _.trim " HELLO! ") end) - it("trim_starts strings", function() - assert.equals("HELLO! ", _.trim_start("%s", " HELLO! ")) + it("should trim_start strings", function() + assert.equals("HELLO! ", _.trim_start_matches("%s", " HELLO! ")) + end) + + it("should trim_end strings", function() + assert.equals(" HELLO!", _.trim_end_matches("%s", " HELLO! ")) + end) + + it("should strip_prefix", function() + assert.equals("withthewind", _.strip_prefix("gone", "gonewiththewind")) + assert.equals("1.3.0", _.strip_prefix("v", "v1.3.0")) + end) + + it("should strip_suffix", function() + assert.equals("gone", _.strip_suffix("withtthewind", "gonewithtthewind")) + assert.equals("name", _.strip_suffix("%.tar%.gz", "name.tar.gz")) + assert.equals("name", _.strip_suffix(".tar.*", "name.tar.gz")) end) end) -- cgit v1.2.3-70-g09d2