@@ -846,25 +846,45 @@ pub fn wildcard_match_detailed(
846
846
) ;
847
847
return WildcardMatchResult :: Fail ( output_lines. join ( "\n " ) ) ;
848
848
}
849
- for ( actual, expected) in actual_lines. iter ( ) . zip ( expected_lines. iter ( ) )
849
+
850
+ if let Some ( invalid_expected) =
851
+ expected_lines. iter ( ) . find ( |e| e. contains ( "[WILDCARD]" ) )
850
852
{
851
- if actual != expected {
853
+ panic ! (
854
+ concat!(
855
+ "Cannot use [WILDCARD] inside [UNORDERED_START]. Use [WILDLINE] instead.\n " ,
856
+ " Invalid expected line: {}"
857
+ ) ,
858
+ invalid_expected
859
+ ) ;
860
+ }
861
+
862
+ for actual_line in actual_lines {
863
+ let maybe_found_index =
864
+ expected_lines. iter ( ) . position ( |expected_line| {
865
+ actual_line == * expected_line
866
+ || wildcard_match ( expected_line, actual_line)
867
+ } ) ;
868
+ if let Some ( found_index) = maybe_found_index {
869
+ let expected = expected_lines. remove ( found_index) ;
870
+ output_lines. push ( format ! (
871
+ "<FOUND>{}</FOUND>" ,
872
+ colors:: gray( annotate_whitespace( expected) )
873
+ ) ) ;
874
+ } else {
852
875
output_lines
853
876
. push ( "==== UNORDERED LINE DID NOT MATCH ====" . to_string ( ) ) ;
854
877
output_lines. push ( format ! (
855
878
" ACTUAL: {}" ,
856
- colors:: red( annotate_whitespace( actual) )
857
- ) ) ;
858
- output_lines. push ( format ! (
859
- "EXPECTED: {}" ,
860
- colors:: green( annotate_whitespace( expected) )
879
+ colors:: red( annotate_whitespace( actual_line) )
861
880
) ) ;
881
+ for expected in expected_lines {
882
+ output_lines. push ( format ! (
883
+ " EXPECTED ANY: {}" ,
884
+ colors:: green( annotate_whitespace( expected) )
885
+ ) ) ;
886
+ }
862
887
return WildcardMatchResult :: Fail ( output_lines. join ( "\n " ) ) ;
863
- } else {
864
- output_lines. push ( format ! (
865
- "<FOUND>{}</FOUND>" ,
866
- colors:: gray( annotate_whitespace( expected) )
867
- ) ) ;
868
888
}
869
889
}
870
890
}
0 commit comments