Skip to content

Commit

Permalink
Merge pull request #1357 from input-output-hk/broken-regex
Browse files Browse the repository at this point in the history
fix regex that failed for multiline mkFunctions and add a test
  • Loading branch information
shmish111 committed Aug 13, 2019
2 parents 68a5529 + 61a08e1 commit 53ba606
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion plutus-playground-server/src/Playground/Interpreter.hs
Expand Up @@ -44,7 +44,11 @@ replaceModuleName script =
ensureMkFunctionExists :: Text -> Text
ensureMkFunctionExists script =
let scriptString = Text.unpack script
regex = Regex.mkRegex "^\\$\\(mkFunctions \\[.*])"
-- I don't really like this regex as it doesn't require properly formed mkFunctions
-- however I couldn't find a better regex that worked for all current usecases
-- additionally I think this check is strong enough to decide whether to add the
-- empty $(mkFunctions [])
regex = Regex.mkRegex "^\\$\\(mkFunctions[ \n\t].*"
mMatches = Regex.matchRegexAll regex scriptString
in case mMatches of
Nothing -> script <> "\n$(mkFunctions [])"
Expand Down
6 changes: 5 additions & 1 deletion plutus-playground-server/usecases/Game.hs
Expand Up @@ -103,7 +103,11 @@ startGame =
-- Player 2's wallet is aware of the game address.
startWatching gameAddress

$(mkFunctions ['lock, 'guess, 'startGame])
$(mkFunctions
['lock
, 'guess
, 'startGame
])

{- Note [Contract endpoints]
Expand Down

0 comments on commit 53ba606

Please sign in to comment.