Skip to content

Commit 95dc230

Browse files
committed
cleaning
1 parent 2c27f80 commit 95dc230

File tree

5 files changed

+48
-19
lines changed

5 files changed

+48
-19
lines changed

module/core/strs_tools_meta/Cargo.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@ full = [
3131
"optimize_split",
3232
"optimize_match",
3333
]
34-
enabled = [ "macro_tools/enabled" ]
34+
enabled = []
3535

36-
optimize_split = []
37-
optimize_match = []
36+
optimize_split = [ "dep:macro_tools" ]
37+
optimize_match = [ "dep:macro_tools" ]
3838

3939
[dependencies]
40-
macro_tools = { workspace = true, features = [ "attr", "ct", "diag", "typ", "derive" ] }
40+
macro_tools = { workspace = true, features = [ "attr", "ct", "diag", "typ", "derive", "enabled" ], optional = true }
4141

42-
[dev-dependencies]
43-
test_tools = { workspace = true, features = [ "full" ] }

module/core/strs_tools_meta/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ]
99
#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ]
1010

11+
#[ cfg( any( feature = "optimize_split", feature = "optimize_match" ) ) ]
1112
use macro_tools::
1213
{
1314
quote::quote,
1415
syn::{ self, Expr, LitStr, Result },
1516
};
17+
18+
#[ cfg( any( feature = "optimize_split", feature = "optimize_match" ) ) ]
1619
use proc_macro::TokenStream;
1720

1821
/// Analyze string patterns at compile time and generate optimized split code.
@@ -286,12 +289,15 @@ impl syn::parse::Parse for OptimizeMatchInput
286289

287290
/// Generate optimized split code based on compile-time analysis
288291
#[ cfg( feature = "optimize_split" ) ]
292+
#[allow(clippy::too_many_lines)]
289293
fn generate_optimized_split( input: &OptimizeSplitInput ) -> macro_tools::proc_macro2::TokenStream
290294
{
291295
let source = &input.source;
292296
let delimiters = &input.delimiters;
297+
#[allow(clippy::no_effect_underscore_binding)]
293298
let _preserve_delimiters = input.preserve_delimiters;
294299
let preserve_empty = input.preserve_empty;
300+
#[allow(clippy::no_effect_underscore_binding)]
295301
let _use_simd = input.use_simd;
296302

297303
// Compile-time optimization decisions
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
//! Integration tests for strs_tools_meta procedural macros
1+
//! Integration tests for `strs_tools_meta` procedural macros
22
//!
33
//! # Test Matrix Summary
44
//!
55
//! This file provides the main entry point for integration tests.
66
//! Detailed Test Matrices are contained in individual test modules:
77
//!
8-
//! - `optimize_split_tests`: Tests for optimize_split macro
9-
//! - `optimize_match_tests`: Tests for optimize_match macro
8+
//! - `optimize_split_tests`: Tests for `optimize_split` macro
9+
//! - `optimize_match_tests`: Tests for `optimize_match` macro
1010
//!
1111
12+
#[ cfg( feature = "optimize_split" ) ]
1213
mod optimize_split_tests;
14+
15+
#[ cfg( feature = "optimize_match" ) ]
1316
mod optimize_match_tests;

module/core/strs_tools_meta/tests/optimize_match_tests.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
//! Integration tests for optimize_match macro
1+
//! Integration tests for `optimize_match` macro
22
//!
3-
//! # Test Matrix for optimize_match
3+
//! # Test Matrix for `optimize_match`
44
//!
55
//! | Test ID | Scenario | Pattern Type | Strategy | Expected Behavior |
66
//! |---------|----------|--------------|----------|-------------------|
77
//! | TC1 | Single pattern | "prefix" | default | Single pattern optimization |
8-
//! | TC2 | Multiple small patterns | ["http://", "https://"] | "first_match" | Trie-based optimization |
8+
//! | TC2 | Multiple small patterns | `["http://", "https://"]` | `"first_match"` | Trie-based optimization |
99
//! | TC3 | Multiple large patterns | Many long patterns | "first_match" | Sequential matching |
10-
//! | TC4 | Strategy: longest_match | ["a", "ab", "abc"] | "longest_match" | Longest match strategy |
11-
//! | TC5 | Strategy: all_matches | ["a", "b"] | "all_matches" | All matches strategy |
10+
//! | TC4 | Strategy: longest_match | `["a", "ab", "abc"]` | `"longest_match"` | Longest match strategy |
11+
//! | TC5 | Strategy: all_matches | `["a", "b"]` | `"all_matches"` | All matches strategy |
1212
//! | TC6 | Debug mode | "test" | default, debug | Debug output generated |
1313
//!
1414
15+
#[ cfg( feature = "optimize_match" ) ]
1516
use strs_tools_meta::optimize_match;
1617

1718
// TC1: Single pattern - should use SinglePattern optimization
19+
#[ cfg( feature = "optimize_match" ) ]
1820
#[ test ]
1921
fn tc1_single_pattern()
2022
{
@@ -25,6 +27,7 @@ fn tc1_single_pattern()
2527
}
2628

2729
// TC2: Multiple small patterns - should use TrieBasedMatch optimization
30+
#[ cfg( feature = "optimize_match" ) ]
2831
#[ test ]
2932
fn tc2_multiple_small_patterns()
3033
{
@@ -35,6 +38,7 @@ fn tc2_multiple_small_patterns()
3538
}
3639

3740
// TC3: First match strategy explicit
41+
#[ cfg( feature = "optimize_match" ) ]
3842
#[ test ]
3943
fn tc3_first_match_strategy()
4044
{
@@ -45,6 +49,7 @@ fn tc3_first_match_strategy()
4549
}
4650

4751
// TC4: Longest match strategy
52+
#[ cfg( feature = "optimize_match" ) ]
4853
#[ test ]
4954
fn tc4_longest_match_strategy()
5055
{
@@ -55,6 +60,7 @@ fn tc4_longest_match_strategy()
5560
}
5661

5762
// TC5: All matches strategy
63+
#[ cfg( feature = "optimize_match" ) ]
5864
#[ test ]
5965
fn tc5_all_matches_strategy()
6066
{
@@ -66,6 +72,7 @@ fn tc5_all_matches_strategy()
6672

6773
// TC6: Debug mode test
6874
// Note: Debug output goes to stderr and can be observed during manual testing
75+
#[ cfg( feature = "optimize_match" ) ]
6976
#[ test ]
7077
fn tc6_debug_mode()
7178
{
@@ -75,6 +82,7 @@ fn tc6_debug_mode()
7582
}
7683

7784
// Test for explicit parameter values to avoid fragile tests
85+
#[ cfg( feature = "optimize_match" ) ]
7886
#[ test ]
7987
fn tc7_explicit_parameters()
8088
{
@@ -84,6 +92,7 @@ fn tc7_explicit_parameters()
8492
}
8593

8694
// Test default value equivalence - dedicated test for parameter defaults
95+
#[ cfg( feature = "optimize_match" ) ]
8796
#[ test ]
8897
fn tc8_default_value_equivalence()
8998
{
@@ -95,6 +104,7 @@ fn tc8_default_value_equivalence()
95104
}
96105

97106
// Test no match case
107+
#[ cfg( feature = "optimize_match" ) ]
98108
#[ test ]
99109
fn tc9_no_match()
100110
{
@@ -104,6 +114,7 @@ fn tc9_no_match()
104114
}
105115

106116
// Test empty input
117+
#[ cfg( feature = "optimize_match" ) ]
107118
#[ test ]
108119
fn tc10_empty_input()
109120
{

module/core/strs_tools_meta/tests/optimize_split_tests.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
//! Integration tests for optimize_split macro
1+
//! Integration tests for `optimize_split` macro
22
//!
3-
//! # Test Matrix for optimize_split
3+
//! # Test Matrix for `optimize_split`
44
//!
55
//! | Test ID | Scenario | Delimiter Type | Options | Expected Behavior |
66
//! |---------|----------|----------------|---------|-------------------|
77
//! | TC1 | Single char delimiter | "," | default | Single char optimization |
88
//! | TC2 | Multiple char single delim | "->" | default | Multi-char delimiter optimization |
9-
//! | TC3 | Multiple delimiters | [",", ";"] | default | Multi-delimiter optimization |
10-
//! | TC4 | Complex delimiters | [",", "->", "::"] | default | Complex pattern fallback |
9+
//! | TC3 | Multiple delimiters | `[",", ";"]` | default | Multi-delimiter optimization |
10+
//! | TC4 | Complex delimiters | `[",", "->", "::"]` | default | Complex pattern fallback |
1111
//! | TC5 | Preserve delimiters | "," | preserve_delimiters=true | Include delimiters in result |
1212
//! | TC6 | Preserve empty | "," | preserve_empty=true | Include empty segments |
13-
//! | TC7 | SIMD disabled | [",", ";"] | use_simd=false | Non-SIMD path |
13+
//! | TC7 | SIMD disabled | `[",", ";"]` | use_simd=false | Non-SIMD path |
1414
//! | TC8 | Debug mode | "," | debug | Debug output generated |
1515
//!
1616
17+
#[ cfg( feature = "optimize_split" ) ]
1718
use strs_tools_meta::optimize_split;
1819

1920
// TC1: Single character delimiter - should use SingleCharDelimiter optimization
21+
#[ cfg( feature = "optimize_split" ) ]
2022
#[ test ]
2123
fn tc1_single_char_delimiter()
2224
{
@@ -30,6 +32,7 @@ fn tc1_single_char_delimiter()
3032
}
3133

3234
// TC2: Multiple character single delimiter - should use MultipleCharDelimiters optimization
35+
#[ cfg( feature = "optimize_split" ) ]
3336
#[ test ]
3437
fn tc2_multi_char_single_delimiter()
3538
{
@@ -43,6 +46,7 @@ fn tc2_multi_char_single_delimiter()
4346
}
4447

4548
// TC3: Multiple delimiters - should use MultipleCharDelimiters optimization
49+
#[ cfg( feature = "optimize_split" ) ]
4650
#[ test ]
4751
fn tc3_multiple_delimiters()
4852
{
@@ -56,6 +60,7 @@ fn tc3_multiple_delimiters()
5660
}
5761

5862
// TC4: Complex delimiters - should use ComplexPattern fallback
63+
#[ cfg( feature = "optimize_split" ) ]
5964
#[ test ]
6065
fn tc4_complex_delimiters()
6166
{
@@ -67,6 +72,7 @@ fn tc4_complex_delimiters()
6772
}
6873

6974
// TC5: Preserve delimiters option
75+
#[ cfg( feature = "optimize_split" ) ]
7076
#[ test ]
7177
fn tc5_preserve_delimiters()
7278
{
@@ -78,6 +84,7 @@ fn tc5_preserve_delimiters()
7884
}
7985

8086
// TC6: Preserve empty segments option
87+
#[ cfg( feature = "optimize_split" ) ]
8188
#[ test ]
8289
fn tc6_preserve_empty()
8390
{
@@ -91,6 +98,7 @@ fn tc6_preserve_empty()
9198
}
9299

93100
// TC7: SIMD disabled
101+
#[ cfg( feature = "optimize_split" ) ]
94102
#[ test ]
95103
fn tc7_simd_disabled()
96104
{
@@ -105,6 +113,7 @@ fn tc7_simd_disabled()
105113

106114
// TC8: Debug mode test
107115
// Note: Debug output goes to stderr and can be observed during manual testing
116+
#[ cfg( feature = "optimize_split" ) ]
108117
#[ test ]
109118
fn tc8_debug_mode()
110119
{
@@ -117,6 +126,7 @@ fn tc8_debug_mode()
117126
}
118127

119128
// Test for explicit parameter values to avoid fragile tests
129+
#[ cfg( feature = "optimize_split" ) ]
120130
#[ test ]
121131
fn tc9_explicit_parameters()
122132
{
@@ -135,6 +145,7 @@ fn tc9_explicit_parameters()
135145
}
136146

137147
// Test default value equivalence - dedicated test for parameter defaults
148+
#[ cfg( feature = "optimize_split" ) ]
138149
#[ test ]
139150
fn tc10_default_value_equivalence()
140151
{

0 commit comments

Comments
 (0)