Skip to content
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