@@ -380,8 +380,7 @@ fn span_default_and_updates() {
380380 assert_eq ! ( default . start, Location :: default ( ) ) ;
381381 assert_eq ! ( default . end, Location :: default ( ) ) ;
382382
383- let mut span = Span :: default ( ) ;
384- span. end = Location :: new ( 55 , 100 ) ;
383+ let span = Span { end : Location :: new ( 55 , 100 ) , ..Default :: default ( ) } ;
385384
386385 assert_eq ! ( span. start, Location :: default ( ) ) ;
387386 assert_eq ! ( span. end, Location { line: 55 , column: 100 } ) ;
@@ -424,11 +423,13 @@ fn parse_comments() {
424423
425424 use crate :: { ast:: ParsedSqlFileSet , files:: SqlFileSet } ;
426425 let path = Path :: new ( "sql_files" ) ;
427- let set = SqlFileSet :: new ( path, None ) . unwrap ( ) ;
428- let parsed_set = ParsedSqlFileSet :: parse_all ( set) . unwrap ( ) ;
429- for file in parsed_set. files ( ) . iter ( ) {
430- let parsed_comments = Comments :: parse_all_comments_from_file ( file) . unwrap ( ) ;
431- match file. file ( ) . path ( ) . to_str ( ) . unwrap ( ) {
426+ let set = SqlFileSet :: new ( path, None ) . unwrap_or_else ( |e| panic ! ( "panicked on {e}" ) ) ;
427+ let parsed_set = ParsedSqlFileSet :: parse_all ( set) . unwrap_or_else ( |e| panic ! ( "panicked on {e}" ) ) ;
428+ for file in parsed_set. files ( ) {
429+ let parsed_comments = Comments :: parse_all_comments_from_file ( file)
430+ . unwrap_or_else ( |e| panic ! ( "panicked on {e}" ) ) ;
431+ let file_path = file. file ( ) . path ( ) . to_str ( ) . map_or_else ( || panic ! ( "panicked" ) , |val| val) ;
432+ match file_path {
432433 "sql_files/with_single_line_comments.sql" => {
433434 let expected = [
434435 "Users table stores user account information" ,
@@ -514,14 +515,22 @@ fn single_line_comment_spans_are_correct() {
514515
515516 use crate :: { ast:: ParsedSqlFileSet , files:: SqlFileSet } ;
516517 let path = Path :: new ( "sql_files" ) ;
517- let set = SqlFileSet :: new ( path, None ) . unwrap ( ) ;
518- let parsed_set = ParsedSqlFileSet :: parse_all ( set) . unwrap ( ) ;
519- let file = parsed_set
520- . files ( )
521- . iter ( )
522- . find ( |f| f. file ( ) . path ( ) . to_str ( ) . unwrap ( ) . ends_with ( "with_single_line_comments.sql" ) )
523- . expect ( "with_single_line_comments.sql should be present" ) ;
524- let comments = Comments :: parse_all_comments_from_file ( file) . unwrap ( ) ;
518+ let set = SqlFileSet :: new ( path, None ) . unwrap_or_else ( |e| panic ! ( "panicked on {e}" ) ) ;
519+ let parsed_set = ParsedSqlFileSet :: parse_all ( set) . unwrap_or_else ( |e| panic ! ( "panicked on {e}" ) ) ;
520+ let file = {
521+ let Some ( f) = parsed_set. files ( ) . iter ( ) . find ( |f| {
522+ let Some ( path) = f. file ( ) . path ( ) . to_str ( ) else {
523+ return false ;
524+ } ;
525+ path. ends_with ( "with_single_line_comments.sql" )
526+ } ) else {
527+ panic ! ( "with_single_line_comments.sql should be present" ) ;
528+ } ;
529+ f
530+ } ;
531+
532+ let comments =
533+ Comments :: parse_all_comments_from_file ( file) . unwrap_or_else ( |e| panic ! ( "panicked on {e}" ) ) ;
525534 let comments = comments. comments ( ) ;
526535 assert_eq ! ( comments. len( ) , 11 ) ;
527536 let first = & comments[ 0 ] ;
@@ -544,14 +553,21 @@ fn multiline_comment_spans_are_correct() {
544553
545554 use crate :: { ast:: ParsedSqlFileSet , files:: SqlFileSet } ;
546555 let path = Path :: new ( "sql_files" ) ;
547- let set = SqlFileSet :: new ( path, None ) . unwrap ( ) ;
548- let parsed_set = ParsedSqlFileSet :: parse_all ( set) . unwrap ( ) ;
549- let file = parsed_set
550- . files ( )
551- . iter ( )
552- . find ( |f| f. file ( ) . path ( ) . to_str ( ) . unwrap ( ) . ends_with ( "with_multiline_comments.sql" ) )
553- . expect ( "with_multiline_comments.sql should be present" ) ;
554- let comments = Comments :: parse_all_comments_from_file ( file) . unwrap ( ) ;
556+ let set = SqlFileSet :: new ( path, None ) . unwrap_or_else ( |e| panic ! ( "panicked on {e}" ) ) ;
557+ let parsed_set = ParsedSqlFileSet :: parse_all ( set) . unwrap_or_else ( |e| panic ! ( "panicked on {e}" ) ) ;
558+ let file = {
559+ let Some ( f) = parsed_set. files ( ) . iter ( ) . find ( |f| {
560+ let Some ( path) = f. file ( ) . path ( ) . to_str ( ) else {
561+ return false ;
562+ } ;
563+ path. ends_with ( "with_multiline_comments.sql" )
564+ } ) else {
565+ panic ! ( "with_multiline_comments.sql should be present" ) ;
566+ } ;
567+ f
568+ } ;
569+ let comments =
570+ Comments :: parse_all_comments_from_file ( file) . unwrap_or_else ( |e| panic ! ( "panicked on {e}" ) ) ;
555571 let comments = comments. comments ( ) ;
556572 assert_eq ! ( comments. len( ) , 11 ) ;
557573 let first = & comments[ 0 ] ;
0 commit comments