From b522b3c62043b9cc0ae5af8b2cee43f9c1354191 Mon Sep 17 00:00:00 2001 From: wandalen Date: Sat, 13 Apr 2024 13:56:07 +0300 Subject: [PATCH] former : experimenting --- .../former/tests/inc/former_tests/a_basic.rs | 16 + .../tests/inc/former_tests/a_basic_manual.rs | 14 + .../tests/inc/former_tests/a_primitives.rs | 8 +- .../inc/former_tests/a_primitives_expanded.rs | 18 - .../tests/inc/former_tests/only_test/basic.rs | 435 ++++++++++++++++++ .../inc/former_tests/only_test/primitives.rs | 305 +----------- module/core/former/tests/inc/mod.rs | 17 +- 7 files changed, 481 insertions(+), 332 deletions(-) create mode 100644 module/core/former/tests/inc/former_tests/a_basic.rs create mode 100644 module/core/former/tests/inc/former_tests/a_basic_manual.rs delete mode 100644 module/core/former/tests/inc/former_tests/a_primitives_expanded.rs create mode 100644 module/core/former/tests/inc/former_tests/only_test/basic.rs diff --git a/module/core/former/tests/inc/former_tests/a_basic.rs b/module/core/former/tests/inc/former_tests/a_basic.rs new file mode 100644 index 0000000000..50d1bc7e0d --- /dev/null +++ b/module/core/former/tests/inc/former_tests/a_basic.rs @@ -0,0 +1,16 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ derive( Debug, PartialEq, former::Former ) ] +// #[ derive( Debug, PartialEq, former::Former ) ] #[ debug ] +// #[ derive( Debug, PartialEq ) ] #[ debug ] +pub struct Struct1 +{ + pub int_1 : i32, +} + +// = begin of generated + +// = end of generated + +include!( "./only_test/basic.rs" ); diff --git a/module/core/former/tests/inc/former_tests/a_basic_manual.rs b/module/core/former/tests/inc/former_tests/a_basic_manual.rs new file mode 100644 index 0000000000..af40c456a4 --- /dev/null +++ b/module/core/former/tests/inc/former_tests/a_basic_manual.rs @@ -0,0 +1,14 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ derive( Debug, PartialEq ) ] +pub struct Struct1 +{ + pub int_1 : i32, +} + +// = formed + +// + +include!( "./only_test/basic.rs" ); diff --git a/module/core/former/tests/inc/former_tests/a_primitives.rs b/module/core/former/tests/inc/former_tests/a_primitives.rs index c39429b63a..dc4963c069 100644 --- a/module/core/former/tests/inc/former_tests/a_primitives.rs +++ b/module/core/former/tests/inc/former_tests/a_primitives.rs @@ -1,7 +1,9 @@ #[ allow( unused_imports ) ] use super::*; -#[ derive( Debug, PartialEq, the_module::Former ) ] +#[ derive( Debug, PartialEq, former::Former ) ] +// #[ derive( Debug, PartialEq, former::Former ) ] #[ debug ] +// #[ derive( Debug, PartialEq ) ] #[ debug ] pub struct Struct1 { pub int_1 : i32, @@ -10,6 +12,8 @@ pub struct Struct1 string_optional_1 : Option< String >, } -// +// = begin of generated + +// = end of generated include!( "./only_test/primitives.rs" ); diff --git a/module/core/former/tests/inc/former_tests/a_primitives_expanded.rs b/module/core/former/tests/inc/former_tests/a_primitives_expanded.rs deleted file mode 100644 index 1fb79bc568..0000000000 --- a/module/core/former/tests/inc/former_tests/a_primitives_expanded.rs +++ /dev/null @@ -1,18 +0,0 @@ -#[ allow( unused_imports ) ] -use super::*; - -// #[ derive( Debug, PartialEq ) ] -#[ derive( Debug, PartialEq, the_module::Former ) ] #[ debug ] -pub struct Struct1 -{ - pub int_1 : i32, - string_1 : String, - int_optional_1 : core::option::Option< i32 >, - string_optional_1 : Option< String >, -} - -// = generated - -// = end of generated - -include!( "./only_test/primitives.rs" ); diff --git a/module/core/former/tests/inc/former_tests/only_test/basic.rs b/module/core/former/tests/inc/former_tests/only_test/basic.rs new file mode 100644 index 0000000000..0808110ac3 --- /dev/null +++ b/module/core/former/tests/inc/former_tests/only_test/basic.rs @@ -0,0 +1,435 @@ +#[ allow( unused_imports ) ] +use super::*; + +// + +tests_impls! +{ + + // + + fn internals() + { + + let former = Struct1::former(); + a_id!( former.storage.int_1, None ); + a_id!( former.context, None ); + a_id!( print!( "{:?}", former.on_end ), print!( "{:?}", Some( the_module::ReturnPreformed ) ) ); + let former2 = Struct1Former::< Struct1FormerDefinition >::new( former::ReturnPreformed ); + a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) ); + + let command = Struct1::former().form(); + a_id!( command.int_1, 0 ); + + let command = Struct1::former().perform(); + a_id!( command.int_1, 0 ); + + let command = Struct1::former().end(); + a_id!( command.int_1, 0 ); + + } + + // + + fn custom_definition_params() + { + // zzz : make example of that + + // custom params + let got = Struct1Former + ::< Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > > > + ::begin + ( + None, + Some( 3 ), + | storage : Struct1FormerStorage, context : Option< i32 > | { 2 * ( storage.int_1.unwrap() + context.unwrap() ) }, + ) + .int_1( 13 ) + .form(); + a_id!( got, 32 ); + + // custom params with into + let got = Struct1Former + ::< Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > > > + ::begin + ( + None, + Some( 3 ), + | storage : Struct1FormerStorage, context : Option< i32 > | { 2 * ( storage.int_1.unwrap() + context.unwrap() ) }, + ) + .int_1( 13 ) + .form(); + a_id!( got, 32 ); + + // custom params begin + let got = Struct1Former + ::< Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > > > + ::begin + ( + None, + Some( 3 ), + | storage : Struct1FormerStorage, context : Option< i32 > | { 2 * ( storage.int_1.unwrap() + context.unwrap() ) } + ) + .int_1( 13 ) + .form(); + a_id!( got, 32 ); + + // custom params begin with Struct1FormerWithClosure + let got = Struct1Former + ::< Struct1FormerWithClosure< i32, i32 > > + ::begin + ( + None, + Some( 3 ), + | storage : Struct1FormerStorage, context : Option< i32 > | { 2 * ( storage.int_1.unwrap() + context.unwrap() ) } + ) + .int_1( 13 ) + .form(); + a_id!( got, 32 ); + + } + + // + + fn begin() + { + + // begin with none + let got = Struct1Former::< Struct1FormerDefinition >::begin( None, None, the_module::ReturnPreformed ).int_1( 13 ).form(); + let exp = Struct1::former().int_1( 13 ).form(); + a_id!( got, exp ); + + // begin with storage + let mut storage = Struct1FormerStorage::default(); + storage.int_1 = Some( 13 ); + let exp = Struct1Former::< Struct1FormerDefinition >::begin( Some( storage ), None, the_module::ReturnPreformed ).form(); + a_id!( got, exp ); + + // begin with context + let mut storage = Struct1FormerStorage::default(); + storage.int_1 = Some( 13 ); + let exp = Struct1Former::< Struct1FormerDefinition > + ::begin( Some( storage ), Some( () ), the_module::ReturnPreformed ) + .form(); + a_id!( got, exp ); + + } + + // + + fn _begin_precise() + { + + // custom params + let got = Struct1Former + ::< Struct1FormerDefinition< i32, i32, _ > > + ::_begin_precise + ( + None, + Some( 3 ), + former::FormingEndClosure::new + ( + | storage : Struct1FormerStorage, context | { 2 * ( storage.int_1.unwrap() + context.unwrap() ) } + ), + ) + .int_1( 13 ) + .form(); + a_id!( got, 32 ); + + // custom params with into + let got = Struct1Former + ::< Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > > > + ::_begin_precise + ( + None, + Some( 3 ), + ( + | storage : Struct1FormerStorage, context : Option< i32 > | { 2 * ( storage.int_1.unwrap() + context.unwrap() ) } + ).into(), + ) + .int_1( 13 ) + .form(); + a_id!( got, 32 ); + + } + + // + + fn new() + { + + // basic case + let former = Struct1::former(); + let former2 = Struct1Former::< Struct1FormerDefinition >::_new_precise( former::ReturnPreformed ); + a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) ); + let exp = former.form(); + let got = former2.form(); + a_id!( got, exp ); + + // default explicit params + let got = Struct1Former + ::< Struct1FormerDefinition< (), Struct1, former::ReturnPreformed > > + ::new( former::ReturnPreformed ) + .int_1( 13 ) + .form(); + let exp = Struct1::former().int_1( 13 ).form(); + a_id!( got, exp ); + + // default explicit params with wrapper + fn f1( storage : Struct1FormerStorage, _context : Option< () > ) -> Struct1 + { + former::StoragePreform::preform( storage ) + } + let end_wrapper : former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > = former::FormingEndClosure::new( f1 ); + let got = Struct1Former + ::< Struct1FormerDefinition< (), Struct1, former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > > > + ::new( end_wrapper ) + .int_1( 13 ) + .form(); + let exp = Struct1::former().int_1( 13 ).form(); + a_id!( got, exp ); + + // default explicit params with wrapper and closure + let got = Struct1Former + ::< Struct1FormerDefinition< (), Struct1, former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > > > + ::new( former::FormingEndClosure::new( | storage, _context | { former::StoragePreform::preform( storage ) } ) ) + .int_1( 13 ) + .form(); + let exp = Struct1::former().int_1( 13 ).form(); + a_id!( got, exp ); + + // default explicit params with wrapper and closure, auto types + let got = Struct1Former + ::< Struct1FormerDefinition< _, _, former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > > > + ::new( former::FormingEndClosure::new( | storage, _context : Option< () > | { former::StoragePreform::preform( storage ) } ) ) + .int_1( 13 ) + .form(); + let exp = Struct1::former().int_1( 13 ).form(); + a_id!( got, exp ); + + // default explicit params with wrapper and closure + let got = Struct1Former + ::< Struct1FormerWithClosure< (), Struct1 > > + ::new( former::FormingEndClosure::new( | storage, _context | { former::StoragePreform::preform( storage ) } ) ) + .int_1( 13 ) + .form(); + let exp = Struct1::former().int_1( 13 ).form(); + a_id!( got, exp ); + + // default explicit params with wrapper and closure + let got = Struct1Former + ::< Struct1FormerWithClosure< (), Struct1 > > + ::new( | storage, _context | { former::StoragePreform::preform( storage ) } ) + .int_1( 13 ) + .form(); + let exp = Struct1::former().int_1( 13 ).form(); + a_id!( got, exp ); + + } + + // + + fn _new_precise() + { + + // basic case + let former = Struct1::former(); + let former2 = Struct1Former::< Struct1FormerDefinition >::_new_precise( former::ReturnPreformed ); + a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) ); + let exp = former.form(); + let got = former2.form(); + a_id!( got, exp ); + + // default explicit params + let got = Struct1Former + ::< Struct1FormerDefinition< (), Struct1, _ > > + ::_new_precise( former::ReturnPreformed ) + .int_1( 13 ) + .form(); + let exp = Struct1::former().int_1( 13 ).form(); + a_id!( got, exp ); + + // default explicit params with wrapper + fn f1( storage : Struct1FormerStorage, _context : Option< () > ) -> Struct1 + { + former::StoragePreform::preform( storage ) + } + let end_wrapper : former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > = former::FormingEndClosure::new( f1 ); + let got = Struct1Former + ::< Struct1FormerDefinition< (), Struct1, _ > > + ::_new_precise( end_wrapper ) + .int_1( 13 ) + .form(); + let exp = Struct1::former().int_1( 13 ).form(); + a_id!( got, exp ); + + // default explicit params with wrapper and closure + let got = Struct1Former + ::< Struct1FormerDefinition< (), Struct1, _ > > + ::_new_precise( former::FormingEndClosure::new( | storage, _context | { former::StoragePreform::preform( storage ) } ) ) + .int_1( 13 ) + .form(); + let exp = Struct1::former().int_1( 13 ).form(); + a_id!( got, exp ); + + // default explicit params with wrapper and closure, auto types + let got = Struct1Former + ::< Struct1FormerDefinition< _, _, _ > > + ::_new_precise( former::FormingEndClosure::new( | storage, _context : Option< () > | { former::StoragePreform::preform( storage ) } ) ) + .int_1( 13 ) + .form(); + let exp = Struct1::former().int_1( 13 ).form(); + a_id!( got, exp ); + + } + + // + + fn preform() + { + + // formation should have method preform + let got = Struct1::former().preform(); + let exp = Struct1::former().form(); + a_id!( got, exp ); + + // storage should have method preform + let got = the_module::StoragePreform::preform( Struct1::former().storage ); + let exp = Struct1::former().form(); + a_id!( got, exp ); + + // storage should have method preform + use the_module::StoragePreform; + let got = Struct1::former().storage.preform(); + let exp = Struct1::former().form(); + a_id!( got, exp ); + + } + + // + + fn definition() + { + + // default is implemented for definition + let _default = Struct1FormerDefinition::< () >::default(); + // let _default = Struct1FormerDefinition::default(); // why does not work? + + // definition types exists and has Formed + let got = < Struct1FormerDefinitionTypes< (), Struct1 > as the_module::FormerDefinitionTypes >::Formed::former().form(); + let exp = Struct1::former().form(); + a_id!( got, exp ); + + // definition types exists and has Formed + let got = < Struct1FormerDefinitionTypes as the_module::FormerDefinitionTypes >::Formed::former().form(); + let exp = Struct1::former().form(); + a_id!( got, exp ); + + // definition types exists and has Storage + use former::StoragePreform; + let got = < Struct1FormerDefinitionTypes as the_module::FormerDefinitionTypes >::Storage::preform( Struct1::former().storage ); + let exp = Struct1::former().form(); + a_id!( got, exp ); + + // definition exists and has Storage + let got = < < Struct1FormerDefinition as the_module::FormerDefinition >::Types as the_module::FormerDefinitionTypes >::Formed::former().form(); + let exp = Struct1::former().form(); + a_id!( got, exp ); + + } + + // + + fn storage() + { + + // definition exists and has Storage + let got = < Struct1FormerStorage as the_module::StoragePreform >::preform( Struct1::former().storage ); + let exp = Struct1::former().form(); + a_id!( got, exp ); + + // default is implemented for Storage + let got = Struct1FormerStorage::default().preform(); + let exp = Struct1::former().storage.preform(); + a_id!( got, exp ); + + // definition exists and has Storage + use former::StoragePreform; + let got = Struct1::former().storage.preform(); + let exp = Struct1::former().form(); + a_id!( got, exp ); + + // storage exists + let got = < Struct1FormerStorage as the_module::Storage >::Formed::former().form(); + let exp = Struct1::former().form(); + a_id!( got, exp ); + + } + + // + + fn test_int() + { + + // test.case( "basic" ); + + let command = Struct1::former() + .int_1( 13 ) + .form(); + // dbg!( &command ); + + let expected = Struct1 + { + int_1 : 13, + }; + a_id!( command, expected ); + + // test.case( "rewriting" ); + + // should_throw( || + // { + // let _command = Struct1::former() + // .int_1( 1 ) + // .int_1( 3 ) + // .form(); + // Ok( () ) + // })?; + } + + // + + fn test_underscored_form() + { + // test.case( "basic" ); + let command = Struct1::former() + .int_1( 13 ) + .form(); + + let expected = Struct1 + { + int_1 : 13, + }; + a_id!( command, expected ); + } + + // + + +} + +// + +tests_index! +{ + internals, + custom_definition_params, + begin, + _begin_precise, + new, + _new_precise, + preform, + definition, + storage, + test_int, + test_underscored_form, +} diff --git a/module/core/former/tests/inc/former_tests/only_test/primitives.rs b/module/core/former/tests/inc/former_tests/only_test/primitives.rs index 4d0aede6cf..3e536af161 100644 --- a/module/core/former/tests/inc/former_tests/only_test/primitives.rs +++ b/module/core/former/tests/inc/former_tests/only_test/primitives.rs @@ -43,191 +43,9 @@ tests_impls! // - fn custom_definition_params() - { - // zzz : make example of that - - // custom params - let got = Struct1Former - ::< Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > > > - ::begin - ( - None, - Some( 3 ), - | storage : Struct1FormerStorage, context : Option< i32 > | { 2 * ( storage.int_1.unwrap() + context.unwrap() ) }, - ) - .int_1( 13 ) - .form(); - a_id!( got, 32 ); - - // custom params with into - let got = Struct1Former - ::< Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > > > - ::begin - ( - None, - Some( 3 ), - | storage : Struct1FormerStorage, context : Option< i32 > | { 2 * ( storage.int_1.unwrap() + context.unwrap() ) }, - ) - .int_1( 13 ) - .form(); - a_id!( got, 32 ); - - // custom params begin - let got = Struct1Former - ::< Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > > > - ::begin - ( - None, - Some( 3 ), - | storage : Struct1FormerStorage, context : Option< i32 > | { 2 * ( storage.int_1.unwrap() + context.unwrap() ) } - ) - .int_1( 13 ) - .form(); - a_id!( got, 32 ); - - // custom params begin with Struct1FormerWithClosure - let got = Struct1Former - ::< Struct1FormerWithClosure< i32, i32 > > - ::begin - ( - None, - Some( 3 ), - | storage : Struct1FormerStorage, context : Option< i32 > | { 2 * ( storage.int_1.unwrap() + context.unwrap() ) } - ) - .int_1( 13 ) - .form(); - a_id!( got, 32 ); - - } - - // - - fn begin() - { - - // begin with none - let got = Struct1Former::< Struct1FormerDefinition >::begin( None, None, the_module::ReturnPreformed ).int_1( 13 ).form(); - let exp = Struct1::former().int_1( 13 ).form(); - a_id!( got, exp ); - - // begin with storage - let mut storage = Struct1FormerStorage::default(); - storage.int_1 = Some( 13 ); - let exp = Struct1Former::< Struct1FormerDefinition >::begin( Some( storage ), None, the_module::ReturnPreformed ).form(); - a_id!( got, exp ); - - // begin with context - let mut storage = Struct1FormerStorage::default(); - storage.int_1 = Some( 13 ); - let exp = Struct1Former::< Struct1FormerDefinition > - ::begin( Some( storage ), Some( () ), the_module::ReturnPreformed ) - .form(); - a_id!( got, exp ); - - } - - // - - fn _begin_precise() - { - - // custom params - let got = Struct1Former - ::< Struct1FormerDefinition< i32, i32, _ > > - ::_begin_precise - ( - None, - Some( 3 ), - former::FormingEndClosure::new - ( - | storage : Struct1FormerStorage, context | { 2 * ( storage.int_1.unwrap() + context.unwrap() ) } - ), - ) - .int_1( 13 ) - .form(); - a_id!( got, 32 ); - - // custom params with into - let got = Struct1Former - ::< Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > > > - ::_begin_precise - ( - None, - Some( 3 ), - ( - | storage : Struct1FormerStorage, context : Option< i32 > | { 2 * ( storage.int_1.unwrap() + context.unwrap() ) } - ).into(), - ) - .int_1( 13 ) - .form(); - a_id!( got, 32 ); - - } - - // - fn new() { - // basic case - let former = Struct1::former(); - let former2 = Struct1Former::< Struct1FormerDefinition >::_new_precise( former::ReturnPreformed ); - a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) ); - let exp = former.form(); - let got = former2.form(); - a_id!( got, exp ); - - // default explicit params - let got = Struct1Former - ::< Struct1FormerDefinition< (), Struct1, former::ReturnPreformed > > - ::new( former::ReturnPreformed ) - .int_1( 13 ) - .form(); - let exp = Struct1::former().int_1( 13 ).form(); - a_id!( got, exp ); - - // default explicit params with wrapper - fn f1( storage : Struct1FormerStorage, _context : Option< () > ) -> Struct1 - { - former::StoragePreform::preform( storage ) - } - let end_wrapper : former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > = former::FormingEndClosure::new( f1 ); - let got = Struct1Former - ::< Struct1FormerDefinition< (), Struct1, former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > > > - ::new( end_wrapper ) - .int_1( 13 ) - .form(); - let exp = Struct1::former().int_1( 13 ).form(); - a_id!( got, exp ); - - // default explicit params with wrapper and closure - let got = Struct1Former - ::< Struct1FormerDefinition< (), Struct1, former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > > > - ::new( former::FormingEndClosure::new( | storage, _context | { former::StoragePreform::preform( storage ) } ) ) - .int_1( 13 ) - .form(); - let exp = Struct1::former().int_1( 13 ).form(); - a_id!( got, exp ); - - // default explicit params with wrapper and closure, auto types - let got = Struct1Former - ::< Struct1FormerDefinition< _, _, former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > > > - ::new( former::FormingEndClosure::new( | storage, _context : Option< () > | { former::StoragePreform::preform( storage ) } ) ) - .int_1( 13 ) - .form(); - let exp = Struct1::former().int_1( 13 ).form(); - a_id!( got, exp ); - - // default explicit params with wrapper and closure - let got = Struct1Former - ::< Struct1FormerWithClosure< (), Struct1 > > - ::new( former::FormingEndClosure::new( | storage, _context | { former::StoragePreform::preform( storage ) } ) ) - .int_1( 13 ) - .form(); - let exp = Struct1::former().int_1( 13 ).form(); - a_id!( got, exp ); - // default explicit params with wrapper and closure let got = Struct1Former ::< Struct1FormerWithClosure< (), Struct1 > > @@ -241,62 +59,6 @@ tests_impls! // - fn _new_precise() - { - - // basic case - let former = Struct1::former(); - let former2 = Struct1Former::< Struct1FormerDefinition >::_new_precise( former::ReturnPreformed ); - a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) ); - let exp = former.form(); - let got = former2.form(); - a_id!( got, exp ); - - // default explicit params - let got = Struct1Former - ::< Struct1FormerDefinition< (), Struct1, _ > > - ::_new_precise( former::ReturnPreformed ) - .int_1( 13 ) - .form(); - let exp = Struct1::former().int_1( 13 ).form(); - a_id!( got, exp ); - - // default explicit params with wrapper - fn f1( storage : Struct1FormerStorage, _context : Option< () > ) -> Struct1 - { - former::StoragePreform::preform( storage ) - } - let end_wrapper : former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > = former::FormingEndClosure::new( f1 ); - let got = Struct1Former - ::< Struct1FormerDefinition< (), Struct1, _ > > - ::_new_precise( end_wrapper ) - .int_1( 13 ) - .form(); - let exp = Struct1::former().int_1( 13 ).form(); - a_id!( got, exp ); - - // default explicit params with wrapper and closure - let got = Struct1Former - ::< Struct1FormerDefinition< (), Struct1, _ > > - ::_new_precise( former::FormingEndClosure::new( | storage, _context | { former::StoragePreform::preform( storage ) } ) ) - .int_1( 13 ) - .form(); - let exp = Struct1::former().int_1( 13 ).form(); - a_id!( got, exp ); - - // default explicit params with wrapper and closure, auto types - let got = Struct1Former - ::< Struct1FormerDefinition< _, _, _ > > - ::_new_precise( former::FormingEndClosure::new( | storage, _context : Option< () > | { former::StoragePreform::preform( storage ) } ) ) - .int_1( 13 ) - .form(); - let exp = Struct1::former().int_1( 13 ).form(); - a_id!( got, exp ); - - } - - // - fn preform() { @@ -320,66 +82,6 @@ tests_impls! // - fn definition() - { - - // default is implemented for definition - let _default = Struct1FormerDefinition::< () >::default(); - // let _default = Struct1FormerDefinition::default(); // why does not work? - - // definition types exists and has Formed - let got = < Struct1FormerDefinitionTypes< (), Struct1 > as the_module::FormerDefinitionTypes >::Formed::former().form(); - let exp = Struct1::former().form(); - a_id!( got, exp ); - - // definition types exists and has Formed - let got = < Struct1FormerDefinitionTypes as the_module::FormerDefinitionTypes >::Formed::former().form(); - let exp = Struct1::former().form(); - a_id!( got, exp ); - - // definition types exists and has Storage - use former::StoragePreform; - let got = < Struct1FormerDefinitionTypes as the_module::FormerDefinitionTypes >::Storage::preform( Struct1::former().storage ); - let exp = Struct1::former().form(); - a_id!( got, exp ); - - // definition exists and has Storage - let got = < < Struct1FormerDefinition as the_module::FormerDefinition >::Types as the_module::FormerDefinitionTypes >::Formed::former().form(); - let exp = Struct1::former().form(); - a_id!( got, exp ); - - } - - // - - fn storage() - { - - // definition exists and has Storage - let got = < Struct1FormerStorage as the_module::StoragePreform >::preform( Struct1::former().storage ); - let exp = Struct1::former().form(); - a_id!( got, exp ); - - // default is implemented for Storage - let got = Struct1FormerStorage::default().preform(); - let exp = Struct1::former().storage.preform(); - a_id!( got, exp ); - - // definition exists and has Storage - use former::StoragePreform; - let got = Struct1::former().storage.preform(); - let exp = Struct1::former().form(); - a_id!( got, exp ); - - // storage exists - let got = < Struct1FormerStorage as the_module::Storage >::Formed::former().form(); - let exp = Struct1::former().form(); - a_id!( got, exp ); - - } - - // - fn test_int() { @@ -562,14 +264,9 @@ tests_impls! tests_index! { internals, - begin, - _begin_precise, new, - _new_precise, - custom_definition_params, preform, - definition, - storage, + test_int, test_string, test_optional_string, diff --git a/module/core/former/tests/inc/mod.rs b/module/core/former/tests/inc/mod.rs index 9f7c70070e..9180e0351a 100644 --- a/module/core/former/tests/inc/mod.rs +++ b/module/core/former/tests/inc/mod.rs @@ -16,8 +16,9 @@ mod former_tests #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] mod container_former_hashmap; + // mod a_basic_manual; + mod a_basic; mod a_primitives_manual; - // mod a_primitives_expanded; mod a_primitives; mod a_containers_without_subformer; #[ cfg( not( feature = "no_std" ) ) ] @@ -27,17 +28,17 @@ mod former_tests mod attribute_default_container; mod attribute_default_primitive; - // mod attribute_perform; + // mod attribute_perform; // xxx mod attribute_setter; mod attribute_alias; mod string_slice_manual; -// mod string_slice; -// mod unsigned_primitive_types; -// mod default_user_type; -// mod user_type_no_default; -// mod user_type_no_debug; -// + // mod string_slice; + mod unsigned_primitive_types; + mod default_user_type; + mod user_type_no_default; + mod user_type_no_debug; + // mod name_collision_former_hashmap_without_parameter; // mod name_collision_former_vector_without_parameter; // mod name_collisions;