-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Format inserted/deleted maps in list assertions #13954
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
Merged
josevalim
merged 9 commits into
elixir-lang:main
from
dkuku:dkuku_pretty_formatting_literals
Nov 17, 2024
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
68ff9b2
escape map
dkuku ce0577d
move tests
dkuku fac9707
rename to build_quoted and move
dkuku a3bf0b8
move to escape function
dkuku 38a8ae9
cleanup
dkuku 21df6c7
cleanup again
dkuku b694c9b
don't wrap structs in tuple
dkuku ae322db
update comment
dkuku ef7fd40
implement for structs
dkuku 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 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -469,6 +469,58 @@ defmodule ExUnit.FormatterTest do | |
| """ | ||
| end | ||
|
|
||
| test "formats nested maps with column limit" do | ||
|
||
| map = | ||
| %{ | ||
| microsecond: {1, 2}, | ||
| second: 3, | ||
| month: 4, | ||
| day: 5, | ||
| year: 2024, | ||
| minute: 6, | ||
| hour: 7 | ||
| } | ||
|
|
||
| failure = [{:error, catch_assertion(assert [map, %{map | hour: 8}] == [map]), []}] | ||
|
|
||
| assert format_test_all_failure(test_module(), failure, 1, 80, &formatter/2) == """ | ||
| 1) Hello: failure on setup_all callback, all tests have been invalidated | ||
| Assertion with == failed | ||
| code: assert [map, %{map | hour: 8}] == [map] | ||
| left: [ | ||
| %{ | ||
| microsecond: {1, 2}, | ||
| second: 3, | ||
| month: 4, | ||
| day: 5, | ||
| year: 2024, | ||
| minute: 6, | ||
| hour: 7 | ||
| }, | ||
| %{ | ||
| microsecond: {1, 2}, | ||
| second: 3, | ||
| month: 4, | ||
| day: 5, | ||
| year: 2024, | ||
| minute: 6, | ||
| hour: 8 | ||
| } | ||
| ] | ||
| right: [ | ||
| %{ | ||
| microsecond: {1, 2}, | ||
| second: 3, | ||
| month: 4, | ||
| day: 5, | ||
| year: 2024, | ||
| minute: 6, | ||
| hour: 7 | ||
| } | ||
| ] | ||
| """ | ||
| end | ||
|
|
||
| test "formats assertions with complex function call arguments" do | ||
| failure = [{:error, catch_assertion(assert is_list(List.to_tuple([1, 2, 3]))), []}] | ||
|
|
||
|
|
||
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.
I am worried this change is happening too deep in the algorithm. We should probably deal with converting to struct/map when building the diff script?
Uh oh!
There was an error while loading. Please reload this page.
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 can try to move it where it is extracted from the diff later, it still may be not the best place.
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'ts enough to convert it in the
escapefunction, it is called in thediff_improperwhen the non matched elem is inserted on the right (line 401) andlist_script_to_diffwhen it's in:delon left side on line 621