Skip to content

Commit

Permalink
remove macro test_suite
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandalen committed Jun 18, 2022
1 parent ad3e0d9 commit e1fcc76
Show file tree
Hide file tree
Showing 12 changed files with 259 additions and 231 deletions.
116 changes: 58 additions & 58 deletions rust/impl/test/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,61 @@ pub( crate ) mod private

// xxx : move here test tools

///
/// Mechanism to define test suite.
/// This macro encourages refactoring the code of the test in the most readable way, gathering a list of all test routines at the end of the test file.
///
/// Name of test routine should have postfix `*_test`. In the index of test routine the postfix should be ommited.
///
/// ### Sample
/// use wtest_basic::*;
///
/// //
///
/// fn pass1_test()
/// {
/// assert_eq!( true, true );
/// }
///
/// //
///
/// fn pass2_test()
/// {
/// assert_eq!( 1, 1 );
/// }
///
/// //
///
/// test_suite!
/// {
/// pass1,
/// pass2,
/// }
///
#[ macro_export ]
macro_rules! test_suite
{

() => { };

(
$( #[ $Meta : meta ] )*
$Name : ident ,
$( $Rest : tt )*
)
=>
{
$( #[ $Meta ] )*
#[test]
fn $Name()
{
$crate::paste::paste!([< $Name _test >])()
}
$crate::test_suite!( $( $Rest )* );
};

}
// ///
// /// Mechanism to define test suite.
// /// This macro encourages refactoring the code of the test in the most readable way, gathering a list of all test routines at the end of the test file.
// ///
// /// Name of test routine should have postfix `*_test`. In the index of test routine the postfix should be ommited.
// ///
// /// ### Sample
// /// use wtest_basic::*;
// ///
// /// //
// ///
// /// fn pass1_test()
// /// {
// /// assert_eq!( true, true );
// /// }
// ///
// /// //
// ///
// /// fn pass2_test()
// /// {
// /// assert_eq!( 1, 1 );
// /// }
// ///
// /// //
// ///
// /// test_suite!
// /// {
// /// pass1,
// /// pass2,
// /// }
// ///
//
// #[ macro_export ]
// macro_rules! test_suite
// {
//
// () => { };
//
// (
// $( #[ $Meta : meta ] )*
// $Name : ident ,
// $( $Rest : tt )*
// )
// =>
// {
// $( #[ $Meta ] )*
// #[test]
// fn $Name()
// {
// $crate::paste::paste!([< $Name _test >])()
// }
// $crate::test_suite!( $( $Rest )* );
// };
//
// }

// /// Pass only if callback fails either returning error or panicing.
//
Expand All @@ -76,7 +76,7 @@ pub( crate ) mod private
// loop {}
// }

pub use test_suite;
// pub use test_suite;
// pub use test_suite_internals;
// pub use index;
}
Expand All @@ -86,7 +86,7 @@ pub mod exposed
{
// use super::private as i;
pub use super::prelude::*;
pub use super::private::test_suite;
// pub use super::private::test_suite;
}

pub use exposed::*;
Expand All @@ -95,6 +95,6 @@ pub use exposed::*;
pub mod prelude
{
// use super::private as i;
pub use super::private::test_suite;
// pub use super::private::test_suite;
pub use core::fmt; // zzz : add to prelude of wtools under feature fair_context
}
2 changes: 0 additions & 2 deletions rust/test/_integration_test/smoke_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// #[ allow( unused_imports ) ]
// use test_tools::test_suite;

//

Expand Down
15 changes: 10 additions & 5 deletions rust/test/dt/either_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ use super::*;

//

fn basic_test()
tests_impls!
{
let left : TheModule::Either< _, () > = TheModule::Either::Left( 13 );
a_id!( left.flip(), TheModule::Either::Right( 13 ) );

fn basic_test()
{
let left : TheModule::Either< _, () > = TheModule::Either::Left( 13 );
a_id!( left.flip(), TheModule::Either::Right( 13 ) );
}

}

//

test_suite!
tests_index!
{
basic,
basic_test,
}
162 changes: 81 additions & 81 deletions rust/test/dt/interval_test.rs
Original file line number Diff line number Diff line change
@@ -1,121 +1,121 @@
#[ allow( unused_imports ) ]
use super::*;
// use test_tools::*;

//

#[ cfg( feature = "use_std" ) ]
fn adapter_basic_test()
tests_impls!
{
use TheModule::*;

// test.case( "basic" );
//

let src = TheModule::Interval::new( 2, 4 );
#[ cfg( feature = "use_std" ) ]
fn adapter_basic()
{
use TheModule::*;

a_id!( TheModule::IntervalAdapter::first( &src ), 2 );
a_id!( TheModule::IntervalAdapter::last( &src ), 4 );
a_id!( TheModule::IntervalAdapter::len( &src ), 3 );
a_id!( TheModule::IntervalAdapter::closed( &src ), ( 2, 4 ) );
a_id!( TheModule::IntervalAdapter::closed_open( &src ), ( 2, 5 ) );
a_id!( TheModule::IntervalAdapter::first_len( &src ), ( 2, 3 ) );
// test.case( "basic" );

a_id!( src.first(), 2 );
a_id!( src.last(), 4 );
a_id!( src.len(), 3 );
a_id!( src.closed(), ( 2, 4 ) );
a_id!( src.closed_open(), ( 2, 5 ) );
a_id!( src.first_len(), ( 2, 3 ) );
let src = TheModule::Interval::new( 2, 4 );

}
a_id!( TheModule::IntervalAdapter::first( &src ), 2 );
a_id!( TheModule::IntervalAdapter::last( &src ), 4 );
a_id!( TheModule::IntervalAdapter::len( &src ), 3 );
a_id!( TheModule::IntervalAdapter::closed( &src ), ( 2, 4 ) );
a_id!( TheModule::IntervalAdapter::closed_open( &src ), ( 2, 5 ) );
a_id!( TheModule::IntervalAdapter::first_len( &src ), ( 2, 3 ) );

//
a_id!( src.first(), 2 );
a_id!( src.last(), 4 );
a_id!( src.len(), 3 );
a_id!( src.closed(), ( 2, 4 ) );
a_id!( src.closed_open(), ( 2, 5 ) );
a_id!( src.first_len(), ( 2, 3 ) );

#[ cfg( feature = "use_std" ) ]
fn adapter_std_closed_open_test()
{
use TheModule::*;
}

// test.case( "basic" );
//

let src = 2..5;
#[ cfg( feature = "use_std" ) ]
fn adapter_std_closed_open()
{
use TheModule::*;

a_id!( TheModule::IntervalAdapter::first( &src ), 2 );
a_id!( TheModule::IntervalAdapter::last( &src ), 4 );
a_id!( TheModule::IntervalAdapter::len( &src ), 3 );
a_id!( TheModule::IntervalAdapter::closed( &src ), ( 2, 4 ) );
a_id!( TheModule::IntervalAdapter::closed_open( &src ), ( 2, 5 ) );
a_id!( TheModule::IntervalAdapter::first_len( &src ), ( 2, 3 ) );
// test.case( "basic" );

a_id!( src.first(), 2 );
// a_id!( src.last(), 4 );
// a_id!( src.len(), 3 );
a_id!( src.closed(), ( 2, 4 ) );
a_id!( src.closed_open(), ( 2, 5 ) );
a_id!( src.first_len(), ( 2, 3 ) );
let src = 2..5;

}
a_id!( TheModule::IntervalAdapter::first( &src ), 2 );
a_id!( TheModule::IntervalAdapter::last( &src ), 4 );
a_id!( TheModule::IntervalAdapter::len( &src ), 3 );
a_id!( TheModule::IntervalAdapter::closed( &src ), ( 2, 4 ) );
a_id!( TheModule::IntervalAdapter::closed_open( &src ), ( 2, 5 ) );
a_id!( TheModule::IntervalAdapter::first_len( &src ), ( 2, 3 ) );

//
a_id!( src.first(), 2 );
// a_id!( src.last(), 4 );
// a_id!( src.len(), 3 );
a_id!( src.closed(), ( 2, 4 ) );
a_id!( src.closed_open(), ( 2, 5 ) );
a_id!( src.first_len(), ( 2, 3 ) );

#[ cfg( feature = "use_std" ) ]
fn adapter_std_closed_test()
{
use TheModule::*;
}

//

// test.case( "basic" );
#[ cfg( feature = "use_std" ) ]
fn adapter_std_closed()
{
use TheModule::*;

let src = 2..=4;
// test.case( "basic" );

a_id!( TheModule::IntervalAdapter::first( &src ), 2 );
a_id!( TheModule::IntervalAdapter::last( &src ), 4 );
a_id!( TheModule::IntervalAdapter::len( &src ), 3 );
a_id!( TheModule::IntervalAdapter::closed( &src ), ( 2, 4 ) );
a_id!( TheModule::IntervalAdapter::closed_open( &src ), ( 2, 5 ) );
a_id!( TheModule::IntervalAdapter::first_len( &src ), ( 2, 3 ) );
let src = 2..=4;

a_id!( src.first(), 2 );
// a_id!( src.last(), 4 );
// a_id!( src.len(), 3 );
a_id!( src.closed(), ( 2, 4 ) );
a_id!( src.closed_open(), ( 2, 5 ) );
a_id!( src.first_len(), ( 2, 3 ) );
a_id!( TheModule::IntervalAdapter::first( &src ), 2 );
a_id!( TheModule::IntervalAdapter::last( &src ), 4 );
a_id!( TheModule::IntervalAdapter::len( &src ), 3 );
a_id!( TheModule::IntervalAdapter::closed( &src ), ( 2, 4 ) );
a_id!( TheModule::IntervalAdapter::closed_open( &src ), ( 2, 5 ) );
a_id!( TheModule::IntervalAdapter::first_len( &src ), ( 2, 3 ) );

}
a_id!( src.first(), 2 );
// a_id!( src.last(), 4 );
// a_id!( src.len(), 3 );
a_id!( src.closed(), ( 2, 4 ) );
a_id!( src.closed_open(), ( 2, 5 ) );
a_id!( src.first_len(), ( 2, 3 ) );

//
}

#[ cfg( feature = "use_std" ) ]
fn into_interval_test()
{
use TheModule::*;
//

#[ cfg( feature = "use_std" ) ]
fn into_interval()
{
use TheModule::*;

// test.case( "from closed open std interval" );
// test.case( "from closed open std interval" );

let src : Interval = ( 2..5 ).into();
a_id!( src.closed(), ( 2, 4 ) );
let src = Interval::from( 2..5 );
a_id!( src.closed(), ( 2, 4 ) );
let src : Interval = ( 2..5 ).into();
a_id!( src.closed(), ( 2, 4 ) );
let src = Interval::from( 2..5 );
a_id!( src.closed(), ( 2, 4 ) );

// test.case( "from closed std interval" );
// test.case( "from closed std interval" );

let src : Interval = ( 2..=4 ).into();
a_id!( src.closed(), ( 2, 4 ) );
let src = Interval::from( 2..=4 );
a_id!( src.closed(), ( 2, 4 ) );
let src : Interval = ( 2..=4 ).into();
a_id!( src.closed(), ( 2, 4 ) );
let src = Interval::from( 2..=4 );
a_id!( src.closed(), ( 2, 4 ) );

}

}

//

test_suite!
tests_index!
{
#[ cfg( feature = "use_std" ) ]
adapter_basic,
#[ cfg( feature = "use_std" ) ]
adapter_std_closed,
#[ cfg( feature = "use_std" ) ]
adapter_std_closed_open,
#[ cfg( feature = "use_std" ) ]
into_interval,
}
11 changes: 8 additions & 3 deletions rust/test/fs/basic_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ use super::*;

//

fn basic_test()
tests_impls!
{

fn basic_test()
{
}

}

//

test_suite!
tests_index!
{
basic,
basic_test,
}
Loading

0 comments on commit e1fcc76

Please sign in to comment.