File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -288,6 +288,12 @@ impl Expect {
288288fn locate_end ( expect_invocation_to_eof : & str ) -> Option < usize > {
289289 static TRAILER : Lazy < Regex > = Lazy :: new ( || Regex :: new ( r##""#*(\s*]])"## ) . unwrap ( ) ) ;
290290
291+ // First, check for `expect![[]]` (no literal).
292+ let mut chars = expect_invocation_to_eof. chars ( ) . skip_while ( |c| c. is_whitespace ( ) ) ;
293+ if ( ']' , ']' ) == ( chars. next ( ) ?, chars. next ( ) ?) {
294+ return Some ( 0 ) ;
295+ }
296+
291297 let trailer = TRAILER . captures ( expect_invocation_to_eof) ?;
292298 let literal_end = trailer. get ( 0 ) . unwrap ( ) . end ( ) - trailer[ 1 ] . len ( ) ;
293299 Some ( literal_end)
@@ -693,5 +699,8 @@ line1
693699 // [["\"]]"]],
694700 // [[r#""]]"#]],
695701 ) ;
702+
703+ // Check `expect![[ ]]` as well.
704+ assert_eq ! ( locate_end( " ]]" ) , Some ( 0 ) ) ;
696705 }
697706}
You can’t perform that action at this time.
0 commit comments