Repository: mitsuhiko/minijinja
Pull request #74 (2022-08-21 20:17:06)

Bump insta and htmlescape, add similar-asserts


Patch:
diff --git a/minijinja/Cargo.toml b/minijinja/Cargo.toml
index 64680ce..4feb731 100644
--- a/minijinja/Cargo.toml
+++ b/minijinja/Cargo.toml
@@ -35,15 +35,16 @@ unstable_machinery = ["internal_debug"]
 
 [dependencies]
 serde = "1.0.130"
-v_htmlescape = { version = "0.14.1", optional = true }
+v_htmlescape = { version = "0.15.8", optional = true }
 self_cell = { version = "0.10.1", optional = true, features = ["old_rust"] }
 serde_json = { version = "1.0.68", optional = true }
 percent-encoding = { version = "2.1.0", optional = true }
 indexmap = { version = "1.7.0", optional = true }
 memo-map = { version = "0.3.1", optional = true }
+similar-asserts = "1.4.2"
 
 [dev-dependencies]
-insta = { version = "1.18.2", features = ["glob"] }
+insta = { version = "1.19.0", features = ["glob"] }
 serde_json = "1.0.68"
 
 [[test]]
diff --git a/minijinja/src/compiler.rs b/minijinja/src/compiler.rs
index 92db05f..cb63cde 100644
--- a/minijinja/src/compiler.rs
+++ b/minijinja/src/compiler.rs
@@ -9,6 +9,9 @@ use crate::tokens::Span;
 use crate::utils::matches;
 use crate::value::Value;
 
+#[cfg(test)]
+use similar_asserts::assert_eq;
+
 /// Represents an open block of code that does not yet have updated
 /// jump targets.
 #[cfg_attr(feature = "internal_debug", derive(Debug))]
diff --git a/minijinja/src/context.rs b/minijinja/src/context.rs
index 78dabca..26ccbf1 100644
--- a/minijinja/src/context.rs
+++ b/minijinja/src/context.rs
@@ -1,3 +1,6 @@
+#[cfg(test)]
+use similar_asserts::assert_eq;
+
 /// Creates a template context with keys and values.
 ///
 /// ```rust
diff --git a/minijinja/src/environment.rs b/minijinja/src/environment.rs
index 946aa48..8192b50 100644
--- a/minijinja/src/environment.rs
+++ b/minijinja/src/environment.rs
@@ -12,6 +12,9 @@ use crate::value::{ArgType, FunctionArgs, RcType, Value};
 use crate::vm::Vm;
 use crate::{filters, functions, tests};
 
+#[cfg(test)]
+use similar_asserts::assert_eq;
+
 /// Represents a handle to a template.
 ///
 /// Templates are stored in the [`Environment`] as bytecode instructions.  With the
diff --git a/minijinja/src/filters.rs b/minijinja/src/filters.rs
index d8d93cc..960f3ed 100644
--- a/minijinja/src/filters.rs
+++ b/minijinja/src/filters.rs
@@ -180,6 +180,9 @@ mod builtins {
     use std::fmt::Write;
     use std::mem;
 
+    #[cfg(test)]
+    use similar_asserts::assert_eq;
+
     /// Converts a value to uppercase.
     ///
     /// ```jinja
diff --git a/minijinja/src/instructions.rs b/minijinja/src/instructions.rs
index fb97f9f..f6fca20 100644
--- a/minijinja/src/instructions.rs
+++ b/minijinja/src/instructions.rs
@@ -1,6 +1,9 @@
 #[cfg(feature = "internal_debug")]
 use std::fmt;
 
+#[cfg(test)]
+use similar_asserts::assert_eq;
+
 use crate::value::Value;
 
 /// This loop has the loop var.
diff --git a/minijinja/src/lexer.rs b/minijinja/src/lexer.rs
index d34d117..7982975 100644
--- a/minijinja/src/lexer.rs
+++ b/minijinja/src/lexer.rs
@@ -4,6 +4,9 @@ use crate::error::{Error, ErrorKind};
 use crate::tokens::{Span, Token};
 use crate::utils::{matches, memchr, memstr, unescape};
 
+#[cfg(test)]
+use similar_asserts::assert_eq;
+
 enum LexerState {
     Template,
     InVariable,
diff --git a/minijinja/src/meta.rs b/minijinja/src/meta.rs
index 648a7af..7a3c57a 100644
--- a/minijinja/src/meta.rs
+++ b/minijinja/src/meta.rs
@@ -12,6 +12,9 @@ use crate::ast;
 use crate::error::Error;
 use crate::parser::parse;
 
+#[cfg(test)]
+use similar_asserts::assert_eq;
+
 /// Given a template source returns a set of undeclared variables.
 ///
 /// Returns a set of all variables in the template that will be looked up from
diff --git a/minijinja/src/source.rs b/minijinja/src/source.rs
index d34dacc..cd1310b 100644
--- a/minijinja/src/source.rs
+++ b/minijinja/src/source.rs
@@ -11,6 +11,9 @@ use crate::environment::CompiledTemplate;
 use crate::error::{Error, ErrorKind};
 use crate::value::RcType;
 
+#[cfg(test)]
+use similar_asserts::assert_eq;
+
 type LoadFunc = dyn for<'a> Fn(&'a str) -> Result<String, Error> + Send + Sync;
 
 /// Utility for dynamic template loading.
diff --git a/minijinja/src/utils.rs b/minijinja/src/utils.rs
index df02b7f..4490da7 100644
--- a/minijinja/src/utils.rs
+++ b/minijinja/src/utils.rs
@@ -6,6 +6,9 @@ use std::str::Chars;
 
 use crate::error::{Error, ErrorKind};
 
+#[cfg(test)]
+use similar_asserts::assert_eq;
+
 // we target Rust 1.41 and that does not have this macro yet
 macro_rules! _matches {
     ($expression:expr, $( $pattern:pat )|+ $( if $guard: expr )? $(,)?) => {
diff --git a/minijinja/src/value.rs b/minijinja/src/value.rs
index 1a6ff82..b078197 100644
--- a/minijinja/src/value.rs
+++ b/minijinja/src/value.rs
@@ -81,6 +81,9 @@ use crate::key::{Key, KeySerializer};
 use crate::utils::{matches, OnDrop};
 use crate::vm::State;
 
+#[cfg(test)]
+use similar_asserts::assert_eq;
+
 #[cfg(feature = "sync")]
 pub(crate) type RcType<T> = std::sync::Arc<T>;
 


Test patch:
diff --git a/minijinja/tests/test_source.rs b/minijinja/tests/test_source.rs
index 0dc64bc..5e40e56 100644
--- a/minijinja/tests/test_source.rs
+++ b/minijinja/tests/test_source.rs
@@ -2,6 +2,8 @@
 
 use minijinja::{Environment, Source};
 
+use similar_asserts::assert_eq;
+
 fn create_env() -> Environment<'static> {
     let mut source = Source::new();
     let template = String::from("Hello World!");
diff --git a/minijinja/tests/test_templates.rs b/minijinja/tests/test_templates.rs
index abaf480..ef2f56a 100644
--- a/minijinja/tests/test_templates.rs
+++ b/minijinja/tests/test_templates.rs
@@ -3,6 +3,8 @@ use std::fs;
 
 use minijinja::{context, Environment, Error, State};
 
+use similar_asserts::assert_eq;
+
 #[test]
 fn test_vm() {
     let mut refs = Vec::new();
diff --git a/minijinja/tests/test_vm.rs b/minijinja/tests/test_vm.rs
index 6d87a25..f948c97 100644
--- a/minijinja/tests/test_vm.rs
+++ b/minijinja/tests/test_vm.rs
@@ -2,6 +2,8 @@
 use minijinja::machinery::{simple_eval, Compiler, Instruction, Instructions};
 use minijinja::value::Value;
 
+use similar_asserts::assert_eq;
+
 #[test]
 fn test_loop() {
     let mut ctx = std::collections::BTreeMap::new();