1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/// Internal namespace.
pub( crate ) mod private
{

  ///
  /// Asserts that a boolean expression is true at runtime.
  ///
  /// This will invoke the panic! macro if the provided expression cannot be evaluated to true at runtime.
  ///
  /// ### Basic use-case.
  ///
  /// ``` rust
  /// use diagnostics_tools::prelude::*;
  /// a_true!( 1 == 1, "something wrong" );
  /// ```
  ///

  #[ macro_export ]
  macro_rules! a_true
  {
    () => {};
    (
      $( $Rest : tt )*
    )
    =>
    {
      assert!( $( $Rest )* );
    };
  }

  ///
  /// Asserts that a boolean expression is false at runtime.
  ///
  /// This will invoke the panic! macro if the provided expression cannot be evaluated to false at runtime.
  ///
  /// ### Basic use-case.
  ///
  /// ``` should_panic
  /// use diagnostics_tools::prelude::*;
  /// a_true!( 1 == 2, "something wrong" );
  /// ```
  ///

  #[ macro_export ]
  macro_rules! a_false
  {
    () => {};
    (
      $( $Rest : tt )*
    )
    =>
    {
      assert!( ! $( $Rest )* );
    };
  }

  ///
  /// Asserts that a boolean expression is true at runtime.
  ///
  /// This will invoke the panic! macro if the provided expression cannot be evaluated to true at runtime.
  /// Like [a_true!], this macro also has a second version, where a custom panic message can be provided.
  ///
  /// ### Basic use-case.
  ///
  /// ``` rust
  /// use diagnostics_tools::prelude::*;
  /// a_dbg_true!( 1 == 1, "something wrong" );
  /// ```
  ///

  #[ macro_export ]
  macro_rules! a_dbg_true
  {
    () => {};
    (
      $( $Rest : tt )*
    )
    =>
    {
      debug_assert!( $( $Rest )* );
    };
  }

  ///
  /// Asserts that a boolean expression is false at runtime.
  ///
  /// This will invoke the panic! macro if the provided expression cannot be evaluated to false at runtime.
  /// Like [a_false!], this macro also has a second version, where a custom panic message can be provided.
  ///
  /// ### Basic use-case.
  ///
  /// ``` should_panic
  /// use diagnostics_tools::prelude::*;
  /// a_dbg_true!( 1 == 2, "something wrong" );
  /// ```
  ///

  #[ macro_export ]
  macro_rules! a_dbg_false
  {
    () => {};
    (
      $( $Rest : tt )*
    )
    =>
    {
      debug_assert!( ! $( $Rest )* );
    };
  }

  ///
  /// Asserts that two expressions are identical.
  ///
  /// This macro will invoke the panic! macro if the two expressions have different values at runtime.
  /// Like [a_id!], this macro also has a second version where a custom panic message can be provided.
  ///
  /// ### Basic use-case.
  ///
  /// ``` rust
  /// use diagnostics_tools::prelude::*;
  /// a_dbg_id!( 1, 1, "something wrong" );
  /// ```
  ///

  #[ macro_export ]
  macro_rules! a_dbg_id
  {
    (
      $( $arg:tt )*
    )
    =>
    {
      if cfg!( debug_assertions )
      {
        $crate::a_id!( $( $arg )* );
      }
    };

  }

  ///
  /// Asserts that two expressions are not identical with each other.
  ///
  /// This will invoke the panic! macro if two experessions have the same value at runtime.
  /// Like [a_id!], this macro also has a second version, where a custom panic message can be provided.
  ///
  /// ### Basic use-case.
  ///
  /// ``` rust
  /// use diagnostics_tools::prelude::*;
  /// a_dbg_not_id!( 1, 2, "something wrong" );
  /// ```
  ///

  #[ macro_export ]
  macro_rules! a_dbg_not_id
  {
    (
      $( $arg:tt )*
    )
    =>
    {
      if cfg!( debug_assertions )
      {
        $crate::a_not_id!( $( $arg )* );
      }
    };

  }

  // xxx : qqq : improve a_id and other similar macroses, make sure message is visible int console
  // a_id!( exp, got, "Failed: path_with_trailing_dot_or_dotdot_segments. Expected: '{}', got: '{}'", exp, got );

  ///
  /// Asserts that two expressions are identical to each other (using [`PartialEq`]). Prints nice diff.
  ///

  #[macro_export]
  macro_rules! a_id
  {
    ( $left:expr , $right:expr $(,)? )
    =>
    ({
      $crate::dependency::pretty_assertions::assert_eq!( $left, $right );
    });
    ($left:expr, $right:expr, $($arg:tt)*)
    =>
    ({
      $crate::dependency::pretty_assertions::assert_eq!( $left, $right, $($arg)+ );
    });
  }

  ///
  /// Asserts that two expressions are not identical to each other (using [`PartialEq`]). Prints nice diff.
  ///

  #[macro_export]
  macro_rules! a_not_id
  {
    ( $left:expr , $right:expr $(,)? )
    =>
    ({
      $crate::dependency::pretty_assertions::assert_ne!( $left, $right );
    });
    ($left:expr, $right:expr, $($arg:tt)*)
    =>
    ({
      $crate::dependency::pretty_assertions::assert_ne!( $left, $right, $($arg)+ );
    });
  }

  pub use a_id;
  pub use a_not_id;
  pub use a_true;
  pub use a_false;
  pub use a_dbg_true;
  pub use a_dbg_false;
  pub use a_dbg_id;
  pub use a_dbg_not_id;
}

#[ doc( inline ) ]
#[ allow( unused_imports ) ]
pub use protected::*;

/// Protected namespace of the module.
pub mod protected
{
  #[ doc( inline ) ]
  #[ allow( unused_imports ) ]
  pub use super::orphan::*;
}

/// Orphan namespace of the module.
pub mod orphan
{
  #[ doc( inline ) ]
  #[ allow( unused_imports ) ]
  pub use super::exposed::*;

  #[ doc( inline ) ]
  #[ allow( unused_imports ) ]
  pub use super::private::a_id as assert_eq;
  #[ doc( inline ) ]
  #[ allow( unused_imports ) ]
  pub use super::private::a_not_id as assert_ne;

}

/// Exposed namespace of the module.
pub mod exposed
{
  #[ doc( inline ) ]
  #[ allow( unused_imports ) ]
  pub use super::prelude::*;
}

/// Prelude to use essentials: `use my_module::prelude::*`.
pub mod prelude
{

  // #[ doc( inline ) ]
  // #[ allow( unused_imports ) ]
  // pub use ::pretty_assertions::assert_eq as a_id;
  // #[ doc( inline ) ]
  // #[ allow( unused_imports ) ]
  // pub use ::pretty_assertions::assert_ne as a_not_id;

  #[ doc( inline ) ]
  #[ allow( unused_imports ) ]
  pub use super::private::a_id;
  #[ doc( inline ) ]
  #[ allow( unused_imports ) ]
  pub use super::private::a_not_id;

  #[ doc( inline ) ]
  #[ allow( unused_imports ) ]
  pub use super::private::
  {
    a_true,
    a_false,
    a_dbg_true,
    a_dbg_false,
    a_dbg_id,
    a_dbg_not_id,
  };

}