Skip to content

Commit

Permalink
former : review
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandalen committed Feb 25, 2024
1 parent 94732e2 commit 4f8b8ad
Show file tree
Hide file tree
Showing 28 changed files with 170 additions and 146 deletions.
19 changes: 19 additions & 0 deletions module/core/former/tests/former_runtime_tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@

include!( "../../../../module/step/meta/src/module/terminal.rs" );

// #[ allow( unused_imports ) ]
// use test_tools::exposed::*;
//
// only_for_aggregating_module!
// {
// #[ allow( unused_imports ) ]
// use wtools::meta::*;
// #[ allow( unused_imports ) ]
// use wtools::former::Former;
// }
//
// only_for_terminal_module!
// {
// #[ allow( unused_imports ) ]
// use meta_tools::*;
// #[ allow( unused_imports ) ]
// use former::Former;
// }

#[ allow( unused_imports ) ]
use test_tools::exposed::*;
#[ allow( unused_imports ) ]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[ allow( unused_imports ) ]
use super::*;

#[derive( Debug, PartialEq )]
#[ derive( Debug, PartialEq ) ]
pub struct Struct1
{
pub int_1 : i32,
Expand Down Expand Up @@ -34,7 +34,7 @@ impl Struct1

//

#[derive( Debug )]
#[ derive( Debug ) ]
pub struct Struct1Former
{
pub int_1 : core::option::Option< i32 >,
Expand Down Expand Up @@ -211,4 +211,5 @@ impl Struct1Former

//

include!( "basic_runtime_only_test.rs" );
// include!( "basic_runtine_only_test.rs" );
include!( "only_test/basic.rs" );
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
#[ allow( unused_imports ) ]
use super::*;

// only_for_aggregating_module!
// {
// #[ allow( unused_imports ) ]
// use wtools::meta::*;
// #[ allow( unused_imports ) ]
// use wtools::former::Former;
// }
//
// only_for_terminal_module!
// {
// #[ allow( unused_imports ) ]
// use meta_tools::*;
// #[ allow( unused_imports ) ]
// use former::Former;
// }

use std::collections::HashMap;
use std::collections::HashSet;

Expand All @@ -34,7 +18,10 @@ pub struct Struct1

//

include!( "basic_only_test.rs" );
include!( "only_test/basic.rs" );

// include!( "basic_runtine_only_test.rs" );
// include!( "basic_only_test.rs" );

//
// output :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,6 @@ use super::*;
#[ allow( unused_imports ) ]
use test_tools::exposed::*;

// only_for_aggregating_module!
// {
// #[ allow( unused_imports ) ]
// use wtools::meta::*;
// #[ allow( unused_imports ) ]
// use wtools::former::Former;
// }
//
// only_for_terminal_module!
// {
// #[ allow( unused_imports ) ]
// use meta_tools::*;
// #[ allow( unused_imports ) ]
// use former::Former;
// }

//

tests_impls!
Expand All @@ -29,10 +13,10 @@ tests_impls!
pub struct AliasTestStruct
{
#[ alias( first_field ) ]
string_field: String,
string_field : String,
#[ alias( second_field ) ]
i32_field: i32,
i8_field: i8,
i32_field : i32,
i8_field : i8,
}

let test_struct = AliasTestStruct::former()
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: Unknown attribute #[defaultx(31)]
--> tests/inc/all/former_bad_attr.rs:6:3
--> tests/inc/compiletime/former_bad_attr.rs:6:3
|
6 | #[ defaultx( 31 ) ]
| ^^^^^^^^^^^^^^^^^^^

error: cannot find attribute `defaultx` in this scope
--> tests/inc/all/former_bad_attr.rs:6:6
--> tests/inc/compiletime/former_bad_attr.rs:6:6
|
6 | #[ defaultx( 31 ) ]
| ^^^^^^^^ help: a derive helper attribute with a similar name exists: `default`
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use former::Former;

struct HashMap< T >
{
f1 : T,
}

#[derive( Former )]
pub struct Struct1
{
f2 : HashMap< i32 >,
}

fn main()
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ use former::Former;

struct Vec
{
f1 : i32,
}

#[derive( Former )]
pub struct Struct1
{
pub string_slice_1 : Vec<>,
f2 : Vec<>,
}

fn main()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ pub struct Struct1

//

include!( "basic_only_test.rs" );
include!( "only_test/basic.rs" );
36 changes: 36 additions & 0 deletions module/core/former/tests/inc/former_hashmap_without_parameter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use super::*;
use TheModule::Former;

#[ derive( Debug, PartialEq ) ]
struct HashMap< T >
{
pub f1 : T,
}

#[ derive( Debug, PartialEq, Former ) ]
pub struct Struct1
{
f2 : HashMap< i32 >,
}

tests_impls!
{

// Name conflict is not a problem.
fn basic()
{

let got = Struct1::former().f2( HashMap { f1 : 3 } ).form();
let expected = Struct1 { f2 : HashMap { f1 : 3 } };
a_id!( got, expected );

}

}

//

tests_index!
{
basic,
}
36 changes: 36 additions & 0 deletions module/core/former/tests/inc/former_vector_without_parameter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use super::*;
use TheModule::Former;

#[ derive( Debug, PartialEq ) ]
struct Vec
{
f1 : i32,
}

#[ derive( Debug, PartialEq, Former ) ]
pub struct Struct1
{
f2 : Vec<>,
}

tests_impls!
{

// Name conflict is not a problem.
fn basic()
{

let got = Struct1::former().f2( Vec { f1 : 3 } ).form();
let expected = Struct1 { f2 : Vec { f1 : 3 } };
a_id!( got, expected );

}

}

//

tests_index!
{
basic,
}
43 changes: 16 additions & 27 deletions module/core/former/tests/inc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,25 @@ use super::*;
#[ allow( unused_imports ) ]
use test_tools::meta::*;

#[ cfg( not( feature = "no_std" ) ) ]
#[ path = "./all/basic_runtime_common.rs" ]
mod basic_runtime_common;

#[ path = "./all/alias.rs" ]
mod alias;
#[ path = "./all/basic.rs" ]
mod basic;
#[ path = "./all/conflict.rs" ]
// xxx : qqq : fix the test
// mod abasic_runtime_manual_test;
mod abasic_test;

mod alias_test;
mod conflict;
#[ path = "./all/string_slice_runtime.rs" ]
mod string_slice_runtime;
#[ path = "./all/string_slice.rs" ]
mod string_slice;

#[ path = "./all/default_user_type.rs" ]
mod default_container;
mod default_primitive;
mod former_hashmap_without_parameter;
mod former_vector_without_parameter;

mod string_slice_manual_test;
mod string_slice_test;

mod default_user_type;
#[ path = "./all/user_type_no_default.rs" ]
mod user_type_no_default;
#[ path = "./all/user_type_no_debug.rs" ]
mod user_type_no_debug;
#[ path = "./all/default_primitive.rs" ]
mod default_primitive;
#[ path = "./all/default_primitive.rs" ]
mod unsigned_primitive_types;
#[ path = "./all/unsigned_primitive_types.rs" ]
mod default_container;
#[ path = "./all/perform.rs" ]
mod perform;

//
Expand All @@ -45,14 +36,12 @@ only_for_terminal_module!
fn trybuild_tests()
{

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

t.compile_fail( "tests/inc/all/former_bad_attr.rs" );
t.pass( "tests/inc/all/former_hashmap_without_parameter.rs" );
t.pass( "tests/inc/all/former_vector_without_parameter.rs" );
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" );

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ tests_impls!
{
// test.case( "default" );

let command = Struct1::former()
.form();
let command = Struct1::former().form();
let expected = Struct1
{
string_slice_1 : "",
Expand Down
Loading

0 comments on commit 4f8b8ad

Please sign in to comment.