Skip to content

Commit 18d6c21

Browse files
Misc fixes for v0.2.6
1 parent 691c2e7 commit 18d6c21

File tree

6 files changed

+21
-20
lines changed

6 files changed

+21
-20
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "antithesis_sdk"
3-
version = "0.2.5"
3+
version = "0.2.6"
44
edition = "2021"
55
rust-version = "1.62.1"
66
license = "MIT"

lib/src/assert/macros.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ Example usage:
426426
#[macro_export]
427427
macro_rules! assert_always_greater_than_or_equal_to {
428428
($left:expr, $right:expr, $message:literal$(, $details:expr)?) => {
429-
$crate::numeric_guidance_helper!($crate::assert_always, >=, false, $left, $right, $message, $details)
429+
$crate::numeric_guidance_helper!($crate::assert_always, >=, false, $left, $right, $message$(, $details)?)
430430
};
431431
($($rest:tt)*) => {
432432
::std::compile_error!(
@@ -442,7 +442,7 @@ Example usage:
442442
#[macro_export]
443443
macro_rules! assert_always_less_than {
444444
($left:expr, $right:expr, $message:literal$(, $details:expr)?) => {
445-
$crate::numeric_guidance_helper!($crate::assert_always, <, true, $left, $right, $message, $details)
445+
$crate::numeric_guidance_helper!($crate::assert_always, <, true, $left, $right, $message$(, $details)?)
446446
};
447447
($($rest:tt)*) => {
448448
::std::compile_error!(
@@ -458,7 +458,7 @@ Example usage:
458458
#[macro_export]
459459
macro_rules! assert_always_less_than_or_equal_to {
460460
($left:expr, $right:expr, $message:literal$(, $details:expr)?) => {
461-
$crate::numeric_guidance_helper!($crate::assert_always, <=, true, $left, $right, $message, $details)
461+
$crate::numeric_guidance_helper!($crate::assert_always, <=, true, $left, $right, $message$(, $details)?)
462462
};
463463
($($rest:tt)*) => {
464464
::std::compile_error!(
@@ -474,7 +474,7 @@ Example usage:
474474
#[macro_export]
475475
macro_rules! assert_sometimes_greater_than {
476476
($left:expr, $right:expr, $message:literal$(, $details:expr)?) => {
477-
$crate::numeric_guidance_helper!($crate::assert_sometimes, >, true, $left, $right, $message, $details)
477+
$crate::numeric_guidance_helper!($crate::assert_sometimes, >, true, $left, $right, $message$(, $details)?)
478478
};
479479
($($rest:tt)*) => {
480480
::std::compile_error!(
@@ -490,7 +490,7 @@ Example usage:
490490
#[macro_export]
491491
macro_rules! assert_sometimes_greater_than_or_equal_to {
492492
($left:expr, $right:expr, $message:literal$(, $details:expr)?) => {
493-
$crate::numeric_guidance_helper!($crate::assert_sometimes, >=, true, $left, $right, $message, $details)
493+
$crate::numeric_guidance_helper!($crate::assert_sometimes, >=, true, $left, $right, $message$(, $details)?)
494494
};
495495
($($rest:tt)*) => {
496496
::std::compile_error!(
@@ -506,7 +506,7 @@ Example usage:
506506
#[macro_export]
507507
macro_rules! assert_sometimes_less_than {
508508
($left:expr, $right:expr, $message:literal$(, $details:expr)?) => {
509-
$crate::numeric_guidance_helper!($crate::assert_sometimes, <, false, $left, $right, $message, $details)
509+
$crate::numeric_guidance_helper!($crate::assert_sometimes, <, false, $left, $right, $message$(, $details)?)
510510
};
511511
($($rest:tt)*) => {
512512
::std::compile_error!(
@@ -522,7 +522,7 @@ Example usage:
522522
#[macro_export]
523523
macro_rules! assert_sometimes_less_than_or_equal_to {
524524
($left:expr, $right:expr, $message:literal$(, $details:expr)?) => {
525-
$crate::numeric_guidance_helper!($crate::assert_sometimes, <=, false, $left, $right, $message, $details)
525+
$crate::numeric_guidance_helper!($crate::assert_sometimes, <=, false, $left, $right, $message$(, $details)?)
526526
};
527527
($($rest:tt)*) => {
528528
::std::compile_error!(

lib/src/assert/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub struct AssertionCatalogInfo {
137137
}
138138

139139
#[derive(Serialize, Debug)]
140-
struct AssertionInfo {
140+
struct AssertionInfo<'a> {
141141
assert_type: AssertType,
142142
display_type: String,
143143
condition: bool,
@@ -146,10 +146,10 @@ struct AssertionInfo {
146146
hit: bool,
147147
must_hit: bool,
148148
id: String,
149-
details: Value,
149+
details: &'a Value,
150150
}
151151

152-
impl AssertionInfo {
152+
impl<'a> AssertionInfo<'a> {
153153
#[allow(clippy::too_many_arguments)]
154154
pub fn new(
155155
assert_type: AssertType,
@@ -164,7 +164,7 @@ impl AssertionInfo {
164164
hit: bool,
165165
must_hit: bool,
166166
id: String,
167-
details: &Value,
167+
details: &'a Value,
168168
) -> Self {
169169
let location = AntithesisLocationInfo {
170170
class,
@@ -183,13 +183,13 @@ impl AssertionInfo {
183183
hit,
184184
must_hit,
185185
id,
186-
details: details.clone(),
186+
details
187187
}
188188
}
189189
}
190190

191191
#[cfg(feature = "full")]
192-
impl AssertionInfo {
192+
impl AssertionInfo<'_> {
193193
// AssertionInfo::track_entry() determines if the assertion should
194194
// actually be emitted:
195195
//
@@ -496,7 +496,7 @@ mod tests {
496496
assert_eq!(ai.hit, this_hit);
497497
assert_eq!(ai.must_hit, this_must_hit);
498498
assert_eq!(ai.id.as_str(), this_id);
499-
assert_eq!(ai.details, this_details);
499+
assert_eq!(ai.details, &this_details);
500500
}
501501

502502
#[test]
@@ -544,7 +544,7 @@ mod tests {
544544
assert_eq!(ai.hit, this_hit);
545545
assert_eq!(ai.must_hit, this_must_hit);
546546
assert_eq!(ai.id.as_str(), this_id);
547-
assert_eq!(ai.details, this_details);
547+
assert_eq!(ai.details, &this_details);
548548
}
549549

550550
#[test]
@@ -592,7 +592,7 @@ mod tests {
592592
assert_eq!(ai.hit, this_hit);
593593
assert_eq!(ai.must_hit, this_must_hit);
594594
assert_eq!(ai.id.as_str(), this_id);
595-
assert_eq!(ai.details, this_details);
595+
assert_eq!(ai.details, &this_details);
596596
}
597597

598598
#[test]

lib/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
///
66
/// Each macro/function in this module takes a parameter called ``message``, which is
77
/// a string literal identifier used to aggregate assertions.
8-
/// Antithesis generates one test property per unique ``message`` This test property will be named ``message`` in the [triage report](https://antithesis.com/docs/reports/triage/).
8+
/// Antithesis generates one test property per unique ``message`` This test property will be named ``message`` in the [triage report](https://antithesis.com/reports/example-triage-report).
99
///
1010
/// Each macro/function also takes a parameter called ``details``, which is a key-value map of optional additional information provided by the user to add context for assertion failures.
11-
/// The information that is logged will appear in the ``logs`` section of a [triage report](https://antithesis.com/docs/reports/triage/).
11+
/// The information that is logged will appear in the ``logs`` section of a [triage report](https://antithesis.com/reports/example-triage-report).
1212
/// Normally the values in ``details`` are evaluated at runtime.
1313
pub mod assert;
1414

simple/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ fn assert_demo() {
8181
assert_unreachable!("Impossible to get here", &details);
8282

8383
assert_always_greater_than!(3, 100, "not right");
84+
assert_sometimes_greater_than_or_equal_to!(3, 100, "not right");
8485

8586
assert_sometimes_all!({a: true, b: false}, "not all right");
8687
}

0 commit comments

Comments
 (0)