difftreelog
test fix
in: master
6 files changed
cmds/jrsonnet-fmt/src/snapshots/jrsonnet_fmt__tests__complex_comments_snapshot.snapdiffbeforeafterboth--- a/cmds/jrsonnet-fmt/src/snapshots/jrsonnet_fmt__tests__complex_comments_snapshot.snap
+++ b/cmds/jrsonnet-fmt/src/snapshots/jrsonnet_fmt__tests__complex_comments_snapshot.snap
@@ -3,51 +3,51 @@
expression: "reformat(indoc!(\"{\n\t\t comments: {\n\t\t\t_: '',\n\t\t\t// Plain comment\n\t\t\ta: '',\n\n\t\t\t# Plain comment with empty line before\n\t\t\tb: '',\n\t\t\t/*Single-line multiline comment\n\n\t\t\t*/\n\t\t\tc: '',\n\n\t\t\t/**Single-line multiline doc comment\n\n\t\t\t*/\n\t\t\tc: '',\n\n\t\t\t/**Multiline doc\n\t\t\tComment\n\t\t\t*/\n\t\t\tc: '',\n\n\t\t\t/*\n\n\tMulti-line\n\n\tcomment\n\t\t\t*/\n\t\t\td: '',\n\n\t\t\te: '', // Inline comment\n\n\t\t\tk: '',\n\n\t\t\t// Text after everything\n\t\t },\n\t\t comments2: {\n\t\t\tk: '',\n\t\t\t// Text after everything, but no newline above\n\t\t },\n spacing: {\n a: '',\n\n b: '',\n },\n noSpacing: {\n a: '',\n b: '',\n },\n }\"))"
---
{
- comments: {
- _: '',
- // Plain comment
- a: '',
+ comments: {
+ _: '',
+ // Plain comment
+ a: '',
- # Plain comment with empty line before
- b: '',
- /* Single-line multiline comment */
- c: '',
+ # Plain comment with empty line before
+ b: '',
+ /* Single-line multiline comment */
+ c: '',
- /**
- * Single-line multiline doc comment
- */
- c: '',
+ /**
+ * Single-line multiline doc comment
+ */
+ c: '',
- /**
- * Multiline doc
- * Comment
- */
- c: '',
+ /**
+ * Multiline doc
+ * Comment
+ */
+ c: '',
- /*
- Multi-line
+ /*
+ Multi-line
- comment
- */
- d: '',
+ comment
+ */
+ d: '',
- e: '', // Inline comment
+ e: '', // Inline comment
- k: '',
+ k: '',
- // Text after everything
- },
- comments2: {
- k: '',
- // Text after everything, but no newline above
- },
- spacing: {
- a: '',
+ // Text after everything
+ },
+ comments2: {
+ k: '',
+ // Text after everything, but no newline above
+ },
+ spacing: {
+ a: '',
- b: '',
- },
- noSpacing: {
- a: '',
- b: '',
- },
+ b: '',
+ },
+ noSpacing: {
+ a: '',
+ b: '',
+ },
}
cmds/jrsonnet-fmt/src/tests.rsdiffbeforeafterboth1use dprint_core::formatting::PrintOptions;2use indoc::indoc;34use crate::Printable;56fn reformat(input: &str) -> String {7 let (source, _) = jrsonnet_rowan_parser::parse(input);89 dprint_core::formatting::format(10 || source.print(),11 PrintOptions {12 indent_width: 2,13 max_width: 100,14 use_tabs: false,15 new_line_text: "\n",16 },17 )18}1920macro_rules! assert_formatted {21 ($input:literal, $output:literal) => {22 let formatted = reformat(indoc!($input));23 let mut expected = indoc!($output).to_owned();24 expected.push('\n');25 if formatted != expected {26 panic!(27 "bad formatting, expected\n```\n{formatted}\n```\nto be equal to\n```\n{expected}\n```",28 )29 }30 };31}3233#[test]34fn padding_stripped_for_multiline_comment() {35 assert_formatted!(36 "{37 /*38 Hello39 World40 */41 _: null,42 }",43 "{44 /*45 Hello46 World47 */48 _: null,49 }"50 );51}5253#[test]54fn last_comment_respects_spacing_with_inline_comment_above() {55 assert_formatted!(56 "{57 a: '', // Inline5859 // Comment60 }",61 "{62 a: '', // Inline6364 // Comment65 }"66 );67}6869#[test]70fn complex_comments_snapshot() {71 insta::assert_display_snapshot!(reformat(indoc!(72 "{73 comments: {74 _: '',75 // Plain comment76 a: '',7778 # Plain comment with empty line before79 b: '',80 /*Single-line multiline comment8182 */83 c: '',8485 /**Single-line multiline doc comment8687 */88 c: '',8990 /**Multiline doc91 Comment92 */93 c: '',9495 /*9697 Multi-line9899 comment100 */101 d: '',102103 e: '', // Inline comment104105 k: '',106107 // Text after everything108 },109 comments2: {110 k: '',111 // Text after everything, but no newline above112 },113 spacing: {114 a: '',115116 b: '',117 },118 noSpacing: {119 a: '',120 b: '',121 },122 }"123 )))124}cmds/jrsonnet/src/main.rsdiffbeforeafterboth--- a/cmds/jrsonnet/src/main.rs
+++ b/cmds/jrsonnet/src/main.rs
@@ -87,6 +87,7 @@
debug: DebugOpts,
}
+// TODO: Add unix_sigpipe = "sig_dfl"
fn main() {
let opts: Opts = Opts::parse();
crates/jrsonnet-evaluator/src/stdlib/format.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/stdlib/format.rs
+++ b/crates/jrsonnet-evaluator/src/stdlib/format.rs
@@ -88,13 +88,13 @@
}
#[test]
- #[should_panic]
+ #[should_panic = "TruncatedFormatCode"]
fn parse_key_missing_start() {
try_parse_mapping_key("").unwrap();
}
#[test]
- #[should_panic]
+ #[should_panic = "TruncatedFormatCode"]
fn parse_key_missing_end() {
try_parse_mapping_key("( ").unwrap();
}
crates/jrsonnet-rowan-parser/src/tests.rsdiffbeforeafterboth--- a/crates/jrsonnet-rowan-parser/src/tests.rs
+++ b/crates/jrsonnet-rowan-parser/src/tests.rs
@@ -248,6 +248,7 @@
fn eval_simple() {
let src = "local a = 1, b = 2; a + local c = 1; c";
let (node, errors) = parse(src);
+ assert!(errors.is_empty());
dbg!(node);
}
tests/tests/common.rsdiffbeforeafterboth--- a/tests/tests/common.rs
+++ b/tests/tests/common.rs
@@ -64,12 +64,12 @@
FuncVal::StaticBuiltin(b) => b
.params()
.iter()
- .map(|p| p.name().as_str().unwrap_or(&"<unnamed>").to_string())
+ .map(|p| p.name().as_str().unwrap_or("<unnamed>").to_string())
.collect(),
FuncVal::Builtin(b) => b
.params()
.iter()
- .map(|p| p.name().as_str().unwrap_or(&"<unnamed>").to_string())
+ .map(|p| p.name().as_str().unwrap_or("<unnamed>").to_string())
.collect(),
}
}