-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
native string utils cheatcodes #6891
native string utils cheatcodes #6891
Conversation
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.
this looks good, but—could we add some tests for this?
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.
nice!
agree with @Evalir that this should have some tests but besides that lgtm
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.
this is great!
would love a few sanity tests in the testdata/cheats folder
okay working on tests now |
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.
sweet!
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.
nice! ty
updated the spec
crates/cheatcodes/spec/src/vm.rs
Outdated
@@ -1077,6 +1077,22 @@ interface Vm { | |||
#[cheatcode(group = String)] | |||
function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue); | |||
|
|||
/// Converts the given `string` value to Lowercase. | |||
#[cheatcode(group = String)] | |||
function toLowercase(string calldata stringifiedValue) external pure returns (string memory stringifiedValue); |
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.
I tested in forge-std to confirm, and this will error with identifier already declared
in solidity since the stringifiedValue
name is reused. Suggested var names for all sigs:
function toLowercase(string calldata stringifiedValue) external pure returns (string memory stringifiedValue); | |
function toLowercase(string calldata input) external pure returns (string memory output); |
crates/cheatcodes/spec/src/vm.rs
Outdated
function trim(string calldata stringifiedValue) external pure returns (string memory stringifiedValue); | ||
/// Replaces occurrences of `from` in the given `string` with `to`. | ||
#[cheatcode(group = String)] | ||
function replace(string calldata stringifiedValue, string calldata from, string calldata to) external pure returns (string memory stringifiedValue); |
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.
Same as https://github.com/foundry-rs/foundry/pull/6891/files#r1465480622
These are not stringifed values, but just strings, so s
or str
is more suitable
@mds1 ig it's corrected now, can you check |
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.
ty!
@mattsse ig this can be merged now |
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.
ty 🙏
Motivation
closes #6818
Solution
The following string utils cheatcodes have been created: