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 1f00d0c commit 9c25ce7
Show file tree
Hide file tree
Showing 18 changed files with 107 additions and 174 deletions.
3 changes: 3 additions & 0 deletions module/core/former/examples/former_custom_subformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,6 @@ fn main()
// > },
// > }
}

// xxx2 : finish example former_custom_subformer

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

#[ test ]
fn container()
{

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
@@ -0,0 +1,23 @@

#[ test ]
fn scalar()
{

let children = vec!
[
Child { name : "a".to_string(), is_mandatory : false },
Child { name : "b".to_string(), is_mandatory : false },
];
let got = Parent::former()
.children( children )
.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
@@ -0,0 +1,19 @@

#[ test ]
fn subform()
{

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,4 @@ where

}

#[ test ]
fn container()
{

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

}
include!( "./only_test/subformer_container_children2.rs" );
Original file line number Diff line number Diff line change
Expand Up @@ -41,46 +41,5 @@ where

}

#[ test ]
fn scalar()
{

let children = vec!
[
Child { name : "a".to_string(), is_mandatory : false },
Child { name : "b".to_string(), is_mandatory : false },
];
let got = Parent::former()
.children( children )
.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 );

}

#[ test ]
fn container()
{

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

}
include!( "./only_test/subformer_scalar_children.rs" );
include!( "./only_test/subformer_container_children2.rs" );
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ where

// == end of generated

include!( "./only_test/subformer_subform.rs" );
include!( "./only_test/subformer_subform_child.rs" );
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct Parent
{
// #[ subform ]
#[ subform( name = _child ) ]
#[ container( former::VectorDefinition ) ]
#[ container( definition = former::VectorDefinition ) ]
// #[ scalar_setter( false ) ]
children : Vec< Child >,
}
Expand All @@ -44,5 +44,5 @@ where

// == end of generated

include!( "./only_test/subformer_subform.rs" );
include!( "./only_test/subformer_subform_child.rs" );
include!( "./only_test/subformer_container.rs" );
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ pub struct Child< 'child, T >

// == end of generated

// include!( "./only_test/subformer_subform.rs" );
// include!( "./only_test/subformer_subform_child.rs" );
// include!( "./only_test/subformer_container.rs" );
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ fn basic()
a_id!( got.command.len(), 2 );

}

// xxx2 : finish example former_custom_subformer
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,4 @@ where

// == end of generated for Parent in context of attribute subform

include!( "./only_test/subformer_subform.rs" );
include!( "./only_test/subformer_subform_child.rs" );
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ where

// == end of generated

include!( "./only_test/subformer_subform.rs" );
include!( "./only_test/subformer_subform_child.rs" );
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ where

// == end of generated for Parent in context of attribute subform

include!( "./only_test/subformer_subform.rs" );
include!( "./only_test/subformer_subform_child.rs" );
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,4 @@ where

}

#[ test ]
fn subform()
{

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

}
include!( "./only_test/subformer_subform_children2.rs" );
Original file line number Diff line number Diff line change
Expand Up @@ -40,44 +40,5 @@ where

}

#[ test ]
fn scalar()
{

let children = vec!
[
Child { name : "a".to_string(), is_mandatory : false },
Child { name : "b".to_string(), is_mandatory : false },
];
let got = Parent::former()
.children( children )
.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 );

}

#[ test ]
fn subform()
{

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

}
include!( "./only_test/subformer_scalar_children.rs" );
include!( "./only_test/subformer_subform_children2.rs" );
12 changes: 6 additions & 6 deletions module/core/former/tests/inc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ mod former_tests
#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_subform_setter_on;

// #[ 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_subform_and_container;
#[ 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_subform_and_container;
// #[ cfg( any( not( feature = "no_std" ) ) ) ]
// mod subformer_subform_and_container_parametrized;

Expand Down
Loading

0 comments on commit 9c25ce7

Please sign in to comment.