From 952c968ed10d19a2097e29a08f42cfd70eaf9d3c Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 14 Feb 2024 15:02:19 -0600 Subject: [PATCH] fix(snap): Help catch swapped parameters --- crates/snapbox/src/assert.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/snapbox/src/assert.rs b/crates/snapbox/src/assert.rs index 2736ed8f..d9c583d9 100644 --- a/crates/snapbox/src/assert.rs +++ b/crates/snapbox/src/assert.rs @@ -62,6 +62,9 @@ impl Assert { #[track_caller] fn eq_inner(&self, expected: crate::Data, actual: crate::Data) { + if expected.source().is_none() && actual.source().is_some() { + panic!("received `(actual, expected)`, expected `(expected, actual)`"); + } match self.action { Action::Skip => { return; @@ -108,6 +111,9 @@ impl Assert { #[track_caller] fn matches_inner(&self, pattern: crate::Data, actual: crate::Data) { + if pattern.source().is_none() && actual.source().is_some() { + panic!("received `(actual, expected)`, expected `(expected, actual)`"); + } match self.action { Action::Skip => { return;