-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support fine grained python error comparison (#64)
- Loading branch information
1 parent
f5981fd
commit a32c9b1
Showing
12 changed files
with
973 additions
and
844 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,22 +1,36 @@ | ||
import gleam/string | ||
|
||
pub fn to_printable_text(text: String) -> String { | ||
do_to_printable_text(text |> string.to_graphemes, "") | ||
pub fn to_printable_text(text: String, python_output: Bool) -> String { | ||
do_to_printable_text( | ||
characters: text |> string.to_graphemes, | ||
python_output: python_output, | ||
acc: "", | ||
) | ||
} | ||
|
||
fn do_to_printable_text(characters: List(String), acc: String) -> String { | ||
fn do_to_printable_text( | ||
characters characters: List(String), | ||
python_output python_output: Bool, | ||
acc acc: String, | ||
) -> String { | ||
case characters { | ||
[] -> acc | ||
[first, ..rest] -> { | ||
let printable = case first { | ||
"\t" -> "\\t" | ||
"\n" -> "\\n" | ||
"\r" -> "\\r" | ||
// Python weirdly converts "\f" to "\x0c" | ||
"\f" if python_output -> "\\x0c" | ||
"\f" -> "\\f" | ||
"\r\n" -> "\\r\\n" | ||
_ -> first | ||
} | ||
do_to_printable_text(rest, acc <> printable) | ||
do_to_printable_text( | ||
characters: rest, | ||
python_output: python_output, | ||
acc: acc <> printable, | ||
) | ||
} | ||
} | ||
} |
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,3 @@ | ||
pub type PythonError { | ||
ValueError(message: String) | ||
} |
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
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