diff options
| author | William Boman <william@redwill.se> | 2022-12-26 16:50:40 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-26 16:50:40 +0100 |
| commit | 05ea35e25dcb03fc019be9ec0ede7e4782bae6b4 (patch) | |
| tree | 2458ad78bddd6f69a348d8381119bc7bc6667142 /tests/mason-core | |
| parent | refactor(installer): introduce PackageInstallOpts class (#802) (diff) | |
| download | mason-05ea35e25dcb03fc019be9ec0ede7e4782bae6b4.tar mason-05ea35e25dcb03fc019be9ec0ede7e4782bae6b4.tar.gz mason-05ea35e25dcb03fc019be9ec0ede7e4782bae6b4.tar.bz2 mason-05ea35e25dcb03fc019be9ec0ede7e4782bae6b4.tar.lz mason-05ea35e25dcb03fc019be9ec0ede7e4782bae6b4.tar.xz mason-05ea35e25dcb03fc019be9ec0ede7e4782bae6b4.tar.zst mason-05ea35e25dcb03fc019be9ec0ede7e4782bae6b4.zip | |
feat(functional): add strip_{prefix,suffix} (#803)
Diffstat (limited to 'tests/mason-core')
| -rw-r--r-- | tests/mason-core/functional/string_spec.lua | 19 | ||||
| -rw-r--r-- | tests/mason-core/installer/registry/expr_spec.lua | 2 |
2 files changed, 18 insertions, 3 deletions
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) diff --git a/tests/mason-core/installer/registry/expr_spec.lua b/tests/mason-core/installer/registry/expr_spec.lua index ec92f7a7..be9de0d7 100644 --- a/tests/mason-core/installer/registry/expr_spec.lua +++ b/tests/mason-core/installer/registry/expr_spec.lua @@ -37,7 +37,7 @@ describe("registry expressions", function() assert.same( Result.success "Gloves", - expr.eval("G{{ 'Cloves' | trim_start(trim) }}", { + expr.eval("G{{ 'Cloves' | strip_prefix(trim) }}", { trim = "C", }) ) |
