diff --git a/corelib/src/test/testing_test.cairo b/corelib/src/test/testing_test.cairo index 6e5e56444e5..917f2106c7a 100644 --- a/corelib/src/test/testing_test.cairo +++ b/corelib/src/test/testing_test.cairo @@ -39,6 +39,50 @@ fn test_assert_ne_no_description() { assert_ne!(1, 2); } +#[test] +fn test_assert_lt_with_description() { + assert_lt!(1_u8, 2_u8, "Description"); +} + +#[test] +fn test_assert_lt_no_description() { + assert_lt!(1_u8, 2_u8); +} + +#[test] +fn test_assert_le_with_description() { + assert_le!(1_u8, 2_u8, "Description"); + assert_le!(1_u8, 1_u8, "Description"); +} + +#[test] +fn test_assert_le_no_description() { + assert_le!(1_u8, 2_u8); + assert_le!(1_u8, 1_u8); +} + +#[test] +fn test_assert_gt_with_description() { + assert_gt!(2_u8, 1_u8, "Description"); +} + +#[test] +fn test_assert_gt_no_description() { + assert_gt!(2_u8, 1_u8); +} + +#[test] +fn test_assert_ge_with_description() { + assert_ge!(2_u8, 1_u8, "Description"); + assert_ge!(2_u8, 2_u8, "Description"); +} + +#[test] +fn test_assert_ge_no_description() { + assert_ge!(2_u8, 1_u8); + assert_ge!(2_u8, 2_u8); +} + #[test] #[should_panic(expected: "assertion failed: `false`.")] fn test_assert_macro_no_input() { diff --git a/crates/cairo-lang-starknet/cairo_level_tests/interoperability.cairo b/crates/cairo-lang-starknet/cairo_level_tests/interoperability.cairo index 3714c2c5038..ace95ddac64 100644 --- a/crates/cairo-lang-starknet/cairo_level_tests/interoperability.cairo +++ b/crates/cairo-lang-starknet/cairo_level_tests/interoperability.cairo @@ -91,7 +91,7 @@ fn test_flow_safe_dispatcher() { // If the test is failing do to gas usage changes, update the gas limit by taking `test_flow` test // gas usage and remove 10000. #[test] -#[available_gas(1170970)] +#[available_gas(1160970)] #[should_panic(expected: ('Syscall out of gas', 'ENTRYPOINT_FAILED',))] fn test_flow_out_of_gas() { // Calling the `test_flow` test but a low gas limit. diff --git a/crates/cairo-lang-test-plugin/src/inline_macros/assert.rs b/crates/cairo-lang-test-plugin/src/inline_macros/assert.rs index baa1af53d03..a842008c4cc 100644 --- a/crates/cairo-lang-test-plugin/src/inline_macros/assert.rs +++ b/crates/cairo-lang-test-plugin/src/inline_macros/assert.rs @@ -85,7 +85,7 @@ trait CompareAssertionPlugin: NamedPlugin { {{ {maybe_assign_lhs} {maybe_assign_rhs} - if !(@$lhs_value$ {operator} @$rhs_value$) {{ + if !($lhs_value$ {operator} $rhs_value$) {{ let mut {f}: core::fmt::Formatter = core::traits::Default::default(); core::result::ResultTrait::<(), core::fmt::Error>::unwrap( write!({f}, "assertion `{lhs_escaped} {operator} {rhs_escaped}` failed") @@ -207,3 +207,31 @@ define_compare_assert_macro!( "assert_ne", "!=" ); + +define_compare_assert_macro!( + /// Macro for less-than assertion. + AssertLtMacro, + "assert_lt", + "<" +); + +define_compare_assert_macro!( + /// Macro for less-than-or-equal assertion. + AssertLeMacro, + "assert_le", + "<=" +); + +define_compare_assert_macro!( + /// Macro for greater-than assertion. + AssertGtMacro, + "assert_gt", + ">" +); + +define_compare_assert_macro!( + /// Macro for greater-than-or-equal assertion. + AssertGeMacro, + "assert_ge", + ">=" +); diff --git a/crates/cairo-lang-test-plugin/src/lib.rs b/crates/cairo-lang-test-plugin/src/lib.rs index 5086a39cc26..b9003ff92c9 100644 --- a/crates/cairo-lang-test-plugin/src/lib.rs +++ b/crates/cairo-lang-test-plugin/src/lib.rs @@ -186,6 +186,10 @@ pub fn test_plugin_suite() -> PluginSuite { suite .add_plugin::() .add_inline_macro_plugin::() - .add_inline_macro_plugin::(); + .add_inline_macro_plugin::() + .add_inline_macro_plugin::() + .add_inline_macro_plugin::() + .add_inline_macro_plugin::() + .add_inline_macro_plugin::(); suite } diff --git a/vscode-cairo/snippets/cairo.json b/vscode-cairo/snippets/cairo.json index 78ec9caa786..a9c2fd1cbaf 100644 --- a/vscode-cairo/snippets/cairo.json +++ b/vscode-cairo/snippets/cairo.json @@ -218,13 +218,33 @@ "Creates an equality assertion with macro": { "prefix": "assert_eq!", "body": ["assert_eq!($1, $2);"], - "description": "Creates an inline macro for asserting equality." + "description": "Creates an inline macro for asserting equality" }, - "Creates an not equality assertion with macro": { + "Creates an not-equality assertion with macro": { "prefix": "assert_ne!", "body": ["assert_ne!($1, $2);"], "description": "Creates an inline macro for asserting non-equality" }, + "Creates a less-than comparison assertion with macro": { + "prefix": "assert_lt!", + "body": ["assert_lt!($1, $2);"], + "description": "Creates an inline macro for asserting less-than" + }, + "Creates a less-than-or-equal comparison assertion with macro": { + "prefix": "assert_le!", + "body": ["assert_le!($1, $2);"], + "description": "Creates an inline macro for asserting less-than-or-equal" + }, + "Creates a greater-than comparison assertion with macro": { + "prefix": "assert_gt!", + "body": ["assert_gt!($1, $2);"], + "description": "Creates an inline macro for asserting greater-than" + }, + "Creates a greater-than-or-equal comparison assertion with macro": { + "prefix": "assert_ge!", + "body": ["assert_ge!($1, $2);"], + "description": "Creates an inline macro for asserting greater-than-or-equal" + }, "Creates panic": { "prefix": "panic!", "body": ["panic!(\"$1\");"],