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.rsdiffbeforeafterboth--- a/cmds/jrsonnet-fmt/src/tests.rs
+++ b/cmds/jrsonnet-fmt/src/tests.rs
@@ -1,4 +1,4 @@
-use dprint_core::formatting::PrintOptions;
+use dprint_core::formatting::{PrintOptions, PrintItems};
use indoc::indoc;
use crate::Printable;
@@ -7,11 +7,15 @@
let (source, _) = jrsonnet_rowan_parser::parse(input);
dprint_core::formatting::format(
- || source.print(),
+ || {
+ let mut out = PrintItems::new();
+ source.print(&mut out);
+ out
+ },
PrintOptions {
indent_width: 2,
max_width: 100,
- use_tabs: false,
+ use_tabs: true,
new_line_text: "\n",
},
)
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.rsdiffbeforeafterboth1use jrsonnet_evaluator::{2 bail,3 function::{builtin, FuncVal},4 ObjValueBuilder, Result, State, Thunk, Val,5};67#[macro_export]8macro_rules! ensure_eq {9 ($a:expr, $b:expr $(,)?) => {{10 let a = &$a;11 let b = &$b;12 if a != b {13 ::jrsonnet_evaluator::bail!("assertion failed: a != b\na={a:#?}\nb={b:#?}")14 }15 }};16}1718#[macro_export]19macro_rules! ensure {20 ($v:expr $(,)?) => {21 if !$v {22 ::jrsonnet_evaluator::bail!("assertion failed: {}", stringify!($v))23 }24 };25}2627#[macro_export]28macro_rules! ensure_val_eq {29 ($a:expr, $b:expr) => {{30 if !::jrsonnet_evaluator::val::equals(&$a.clone(), &$b.clone())? {31 use ::jrsonnet_evaluator::manifest::JsonFormat;32 ::jrsonnet_evaluator::bail!(33 "assertion failed: a != b\na={:#?}\nb={:#?}",34 $a.manifest(JsonFormat::default())?,35 $b.manifest(JsonFormat::default())?,36 )37 }38 }};39}4041#[builtin]42fn assert_throw(lazy: Thunk<Val>, message: String) -> Result<bool> {43 match lazy.evaluate() {44 Ok(_) => {45 bail!("expected argument to throw on evaluation, but it returned instead")46 }47 Err(e) => {48 let error = format!("{}", e.error());49 ensure_eq!(message, error);50 }51 }52 Ok(true)53}5455#[builtin]56fn param_names(fun: FuncVal) -> Vec<String> {57 match fun {58 FuncVal::Id => vec!["x".to_string()],59 FuncVal::Normal(func) => func60 .params61 .iter()62 .map(|p| p.0.name().unwrap_or_else(|| "<unnamed>".into()).to_string())63 .collect(),64 FuncVal::StaticBuiltin(b) => b65 .params()66 .iter()67 .map(|p| p.name().as_str().unwrap_or(&"<unnamed>").to_string())68 .collect(),69 FuncVal::Builtin(b) => b70 .params()71 .iter()72 .map(|p| p.name().as_str().unwrap_or(&"<unnamed>").to_string())73 .collect(),74 }75}7677#[allow(dead_code)]78pub fn with_test(s: &State) {79 let mut bobj = ObjValueBuilder::new();80 bobj.method("assertThrow", assert_throw::INST);81 bobj.method("paramNames", param_names::INST);8283 s.add_global("test".into(), Thunk::evaluated(Val::Obj(bobj.build())))84}