String utils updates and tests#3434
Merged
demonnic merged 5 commits intoMudlet:developmentfrom Mar 13, 2020
Merged
Conversation
|
Hey there! Thanks for helping Mudlet improve. 🌟 Test versionsYou can directly test the changes here:
No need to install anything - just unzip and run. |
vadi2
approved these changes
Mar 13, 2020
src/mudlet-lua/lua/StringUtils.lua
Outdated
| function string:title() | ||
| assert(type(self) == "string", "string.title(): no word given to capitalize") | ||
| local strType = type(self) | ||
| assert(strType == "string", "string.title(str): str as string expected, got " .. strType) |
Member
There was a problem hiding this comment.
Could you use the C++ variant of the error msg for consistency?
Member
Author
There was a problem hiding this comment.
Ok. Because consistency is good. But I still don't like it. =)
Member
There was a problem hiding this comment.
I had no idea you don't like it! Feel free to raise it for discussion.
vadi2
reviewed
Mar 13, 2020
src/mudlet-lua/lua/StringUtils.lua
Outdated
| function string:title() | ||
| local strType = type(self) | ||
| assert(strType == "string", "string.title(str): str as string expected, got " .. strType) | ||
| assert(strType == "string", string.format("string.title: bad argument #1 type. (String to title as string expected, got %s!)", strType)) |
Member
There was a problem hiding this comment.
Suggested change
| assert(strType == "string", string.format("string.title: bad argument #1 type. (String to title as string expected, got %s!)", strType)) | |
| assert(strType == "string", string.format("string.title: bad argument #1 type (string to title as string expected, got %s!)", strType)) |
vadi2
reviewed
Mar 13, 2020
| local str = {} | ||
| local errfn = function() string.title(str) end | ||
| assert.has_error(errfn, "string.title(str): str as string expected, got table") | ||
| assert.has_error(errfn, "string.title: bad argument #1 type. (String to title as string expected, got table!)") |
Member
There was a problem hiding this comment.
Suggested change
| assert.has_error(errfn, "string.title: bad argument #1 type. (String to title as string expected, got table!)") | |
| assert.has_error(errfn, "string.title: bad argument #1 type (string to title as string expected, got table!)") |
vadi2
approved these changes
Mar 13, 2020
Chris7
pushed a commit
to Chris7/Mudlet
that referenced
this pull request
Jan 2, 2022
* Adjusting items in StringUtils to support the : function notation * Adding StringUtils spec, to make sure that the changes I made didn't break anything * Adjusting one test and adding one last one
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brief overview of PR changes/additions
While writing the tests for StringUtils I realized it would only take a bit of adjustment to support the : notation for the functions we add.
Motivation for adding to Mudlet
TEST ALL THE THINGS
Other info (issues closed, discussion etc)