Skip to content

Commit

Permalink
former : experimenting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandalen committed May 2, 2024
1 parent 754823f commit 02fd5d1
Show file tree
Hide file tree
Showing 5 changed files with 331 additions and 186 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ pub struct Parent
impl< Definition, > ParentFormer< Definition, >
where
Definition : former::FormerDefinition< Storage = ParentFormerStorage< > >,
// Definition::Types : former::FormerDefinitionTypes< Storage = ParentFormerStorage< > >,
{

#[ inline( always ) ]
Expand All @@ -37,10 +36,13 @@ where
{
Former2::former_begin( None, Some( self ), ParentFormerAssignChildrenEnd::< Definition >::default() )
}
#[ doc =
"Subformer setter for the 'children' field. Method _children_assign unlike method children accept custom container subformer." ]

#[ inline( always ) ]
pub fn children( self ) -> former::ContainerSubformer::< Child, former::VectorDefinition< Child, Self, Self, ParentFormerAssignChildrenEnd< Definition >, > >
pub fn children( self ) -> former::ContainerSubformer::
<
Child,
former::VectorDefinition< Child, Self, Self, ParentFormerAssignChildrenEnd< Definition >, >
>
{
self._children_assign::< former::ContainerSubformer::< Child, former::VectorDefinition< Child, Self, Self, ParentFormerAssignChildrenEnd< Definition >, > > >()
}
Expand Down Expand Up @@ -71,14 +73,14 @@ impl< Definition > Default for ParentFormerAssignChildrenEnd< Definition >

#[ automatically_derived ]
impl< Definition, > former::FormingEnd
// < former::VectorDefinition< Child, ParentFormer< Definition, >, ParentFormer< Definition, >, former::NoEnd >, >
<
< Vec< Child > as former::EntityToDefinition< ParentFormer< Definition, >, ParentFormer< Definition, >, former::NoEnd > >::Definition
<
Vec< Child > as former::EntityToDefinition< ParentFormer< Definition, >, ParentFormer< Definition, >, former::NoEnd >
>::Definition
>
for ParentFormerAssignChildrenEnd< Definition >
where
Definition : former::FormerDefinition< Storage = ParentFormerStorage< > >,
// Definition::Types : former::FormerDefinitionTypes< Storage = ParentFormerStorage< > >,
{
#[ inline( always ) ]
fn call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,35 @@ where
"#
}

#[ inline( always ) ]
pub fn children2( self ) -> former::ContainerSubformer::
<
Child,
former::VectorDefinition< Child, Self, Self, ParentFormerAssignChildrenEnd< Definition >, >
>
{
self._children_assign::< _ >()
}

}

#[ test ]
fn basic()
{

let got = Parent::former()
.children2()
.add( Child::former().name( "a" ).form() )
.add( Child::former().name( "b" ).form() )
.end()
.form();

let children = vec!
[
Child { name : "a".to_string(), is_mandatory : false },
Child { name : "b".to_string(), is_mandatory : false },
];
let exp = Parent { children };
a_id!( got, exp );

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![ allow( dead_code ) ]
// xxx : rename

use super::*;

Expand Down Expand Up @@ -38,4 +39,32 @@ where
"#
}

#[ inline( always ) ]
pub fn children2( self, name : &str ) ->
ChildAsSubformer< Self, impl ChildAsSubformerEnd< Self > >
{
self._children_add
::< ChildFormer< _ >, _, >()
.name( name )
}

}

#[ test ]
fn children()
{

let got = Parent::former()
.children2( "a" ).end()
.children2( "b" ).end()
.form();

let children = vec!
[
Child { name : "a".to_string(), is_mandatory : false },
Child { name : "b".to_string(), is_mandatory : false },
];
let exp = Parent { children };
a_id!( got, exp );

}
232 changes: 116 additions & 116 deletions module/core/former/tests/inc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,91 +7,90 @@ mod former_tests
#[ allow( unused_imports ) ]
use super::*;

#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
mod container_former_common;
#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
mod container_former_vec;
#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
mod container_former_hashset;
#[ 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;

mod a_containers_without_subformer;
#[ cfg( not( feature = "no_std" ) ) ]
mod a_containers_with_subformer_manual;
#[ cfg( not( feature = "no_std" ) ) ]
mod a_containers_with_subformer;

mod attribute_default_container;
mod attribute_default_primitive;
mod attribute_perform;
mod attribute_setter;
mod attribute_alias;
mod attribute_feature;

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 visibility;

mod name_collision_former_hashmap_without_parameter;
mod name_collision_former_vector_without_parameter;
mod name_collisions;
mod name_collision_context;
mod name_collision_end;
mod name_collision_on_end;

#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
mod parametrized_struct_manual;
#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
mod parametrized_struct_imm;
#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
mod parametrized_struct_where;
mod parametrized_field;
mod parametrized_field_where;

#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
mod subformer_basic;

#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_container;
#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_container_manual;
#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_container_implicit;

#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_subform;
#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_subform_manual;
#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_subform_named;
#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_subform_named_manual;

// #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
// mod container_former_common;
// #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
// mod container_former_vec;
// #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
// mod container_former_hashset;
// #[ 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;
//
// mod a_containers_without_subformer;
// #[ cfg( not( feature = "no_std" ) ) ]
// mod a_containers_with_subformer_manual;
// #[ cfg( not( feature = "no_std" ) ) ]
// mod a_containers_with_subformer;
//
// mod attribute_default_container;
// mod attribute_default_primitive;
// mod attribute_perform;
// mod attribute_setter;
// mod attribute_alias;
// mod attribute_feature;
//
// 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 visibility;
//
// mod name_collision_former_hashmap_without_parameter;
// mod name_collision_former_vector_without_parameter;
// mod name_collisions;
// mod name_collision_context;
// mod name_collision_end;
// mod name_collision_on_end;
//
// #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
// mod parametrized_struct_manual;
// #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
// mod parametrized_struct_imm;
// #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
// mod parametrized_struct_where;
// mod parametrized_field;
// mod parametrized_field_where;
//
// #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
// mod subformer_basic;
//
// #[ cfg( any( not( feature = "no_std" ) ) ) ]
// mod subformer_container;
// #[ cfg( any( not( feature = "no_std" ) ) ) ]
// mod subformer_container_manual;
// #[ cfg( any( not( feature = "no_std" ) ) ) ]
// mod subformer_container_implicit;
#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_subform_hashmap;
mod subformer_container_setter_off;

// #[ cfg( any( not( feature = "no_std" ) ) ) ]
// mod subformer_subform;
// #[ cfg( any( not( feature = "no_std" ) ) ) ]
// mod subformer_subform_manual;
// #[ cfg( any( not( feature = "no_std" ) ) ) ]
// mod subformer_subform_named;
// #[ cfg( any( not( feature = "no_std" ) ) ) ]
// mod subformer_subform_named_manual;
#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_subform_hashmap_explicit;
mod subformer_subform_setter_off;

#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_setter_off_subform;
// #[ cfg( any( not( feature = "no_std" ) ) ) ]
// mod subformer_subform_hashmap;
// #[ cfg( any( not( feature = "no_std" ) ) ) ]
// mod subformer_subform_hashmap_explicit;
// #[ cfg( any( not( feature = "no_std" ) ) ) ]
// mod subformer_setter_off_container;

#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_subform_and_container;
#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_subform_and_container_parametrized;
// mod subformer_subform_and_container;
// #[ cfg( any( not( feature = "no_std" ) ) ) ]
// mod subformer_subform_and_container_parametrized;

// xxx
}

#[ cfg( feature = "derive_components" ) ]
Expand Down Expand Up @@ -126,39 +125,40 @@ mod components_tests

}

only_for_terminal_module!
{

// stable have different information about error
// that's why these tests are active only for nightly
#[ test_tools::nightly ]
#[ test ]
fn former_trybuild()
{

println!( "current_dir : {:?}", std::env::current_dir().unwrap() );
let t = test_tools::compiletime::TestCases::new();

// zzz : uncomment
t.compile_fail( "tests/inc/compiletime/former_bad_attr.rs" );
t.pass( "tests/inc/compiletime/former_hashmap_without_parameter.rs" );
t.pass( "tests/inc/compiletime/former_vector_without_parameter.rs" );

}

// stable have different information about error
// that's why these tests are active only for nightly
#[ test_tools::nightly ]
#[ test ]
fn components_trybuild()
{

println!( "current_dir : {:?}", std::env::current_dir().unwrap() );
let _t = test_tools::compiletime::TestCases::new();

// zzz : make it working test
//t.run( "tests/inc/compiletime/components_component_from_debug.rs" );

}

}
// only_for_terminal_module!
// {
//
// // stable have different information about error
// // that's why these tests are active only for nightly
// #[ test_tools::nightly ]
// #[ test ]
// fn former_trybuild()
// {
//
// println!( "current_dir : {:?}", std::env::current_dir().unwrap() );
// let t = test_tools::compiletime::TestCases::new();
//
// // zzz : uncomment
// t.compile_fail( "tests/inc/compiletime/former_bad_attr.rs" );
// t.pass( "tests/inc/compiletime/former_hashmap_without_parameter.rs" );
// t.pass( "tests/inc/compiletime/former_vector_without_parameter.rs" );
//
// }
//
// // stable have different information about error
// // that's why these tests are active only for nightly
// #[ test_tools::nightly ]
// #[ test ]
// fn components_trybuild()
// {
//
// println!( "current_dir : {:?}", std::env::current_dir().unwrap() );
// let _t = test_tools::compiletime::TestCases::new();
//
// // zzz : make it working test
// //t.run( "tests/inc/compiletime/components_component_from_debug.rs" );
//
// }
//
// }
// xxx
Loading

0 comments on commit 02fd5d1

Please sign in to comment.