-
Notifications
You must be signed in to change notification settings - Fork 52
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
Feature/more string methods #725
Merged
Jason2605
merged 11 commits into
dictu-lang:develop
from
briandowns:feature/more_string_methods
Jan 22, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
aa7b9ce
add collapseSpaces method to string type
briandowns 2e2b6aa
add wrap string method
briandowns e3b29bd
newlines
briandowns b08a365
update code style
briandowns 809b187
add new line
briandowns 76d28e9
redo implementations
briandowns 5181778
update docs
briandowns 818f19c
add addtional test
briandowns c01149d
update docs
briandowns 47fa9a9
Reuse length variable and only resize if we need to
Jason2605 7f997cc
Correct memory tracking
Jason2605 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* collapseSpaces.du | ||
* | ||
* Testing the str.collapseSpaces() method | ||
* | ||
* .collapseSpaces() returns a string with extraneous spaces removed. | ||
*/ | ||
from UnitTest import UnitTest; | ||
|
||
class TestStringCollapseSpaces < UnitTest { | ||
testStringCollapseSpaces() { | ||
const testString = "This is a huge string of a lot of spaces."; | ||
const expected = "This is a huge string of a lot of spaces."; | ||
const res = testString.collapseSpaces(); | ||
this.assertEquals(res, expected); | ||
this.assertNotEquals(testString, expected); | ||
} | ||
} | ||
|
||
TestStringCollapseSpaces().run(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ class TestStringConcat < UnitTest { | |
} | ||
} | ||
|
||
TestStringConcat().run(); | ||
TestStringConcat().run(); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* wrap.du | ||
* | ||
* Testing the str.wrap() method | ||
* | ||
* .wrap() returns a new string with new lines inserted at the given length. | ||
*/ | ||
from UnitTest import UnitTest; | ||
|
||
class TestStringWrap < UnitTest { | ||
const maxLen = 80; | ||
|
||
testStringWrap() { | ||
const testString = "This is a really really long string that will need to be broken up for whatever reason the caller has determined. Not out business as to why, but we can provide the functionality for them to do so."; | ||
const res = testString.wrap(this.maxLen); | ||
const idx = res.find("\n"); | ||
this.assertTruthy(res.find("\n") <= this.maxLen); | ||
} | ||
} | ||
|
||
TestStringWrap().run(); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably worth adding some tests to ensure the original string is also untouched