Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6.x - string.expandWildcards implementation #1889

Open
wants to merge 1 commit into
base: 6.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/modules/string/string.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ end
---
-- Returns a new string with any Premake pattern tokens (i.e. `*`) expanded to Lua patterns.
--
-- TODO: Just a placeholder at the moment; needs implementation.
-- TODO: Move this to C; gets called a lot.
--
-- @param value
Expand All @@ -26,7 +25,8 @@ end
---

function string.expandWildcards(value)
return value, true
local expanded = string.patternFromWildcards(value)
return expanded, value ~= expanded
end


Expand Down
12 changes: 12 additions & 0 deletions core/modules/string/tests/string_pattern_tests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,15 @@ end
function StringPatternTests.patternFromWildcards_replacesStarWithLuaPattern()
test.isEqual('ab.*', string.patternFromWildcards('ab*'))
end

function StringPatternTests.expandWildcards_leavesUnchanged_onNoWildcards()
local value, hasTokens = string.expandWildcards('abcd')
test.isEqual('abcd', value)
test.isEqual(false, hasTokens)
end

function StringPatternTests.expandWildcards_replacesStarWithLuaPattern()
local value, hasTokens = string.expandWildcards('ab*')
test.isEqual('ab.*', value)
test.isEqual(true, hasTokens)
end