@@ -1012,51 +1012,16 @@ impl FilePathMapping {
10121012#[ cfg( test) ]
10131013mod tests {
10141014 use super :: * ;
1015- use std:: borrow:: Cow ;
10161015 use rustc_data_structures:: sync:: Lrc ;
10171016
1018- #[ test]
1019- fn t1 ( ) {
1020- let cm = CodeMap :: new ( FilePathMapping :: empty ( ) ) ;
1021- let fm = cm. new_filemap ( PathBuf :: from ( "blork.rs" ) . into ( ) ,
1022- "first line.\n second line" . to_string ( ) ) ;
1023- fm. next_line ( BytePos ( 0 ) ) ;
1024- // Test we can get lines with partial line info.
1025- assert_eq ! ( fm. get_line( 0 ) , Some ( Cow :: from( "first line." ) ) ) ;
1026- // TESTING BROKEN BEHAVIOR: line break declared before actual line break.
1027- fm. next_line ( BytePos ( 10 ) ) ;
1028- assert_eq ! ( fm. get_line( 1 ) , Some ( Cow :: from( "." ) ) ) ;
1029- fm. next_line ( BytePos ( 12 ) ) ;
1030- assert_eq ! ( fm. get_line( 2 ) , Some ( Cow :: from( "second line" ) ) ) ;
1031- }
1032-
1033- #[ test]
1034- #[ should_panic]
1035- fn t2 ( ) {
1036- let cm = CodeMap :: new ( FilePathMapping :: empty ( ) ) ;
1037- let fm = cm. new_filemap ( PathBuf :: from ( "blork.rs" ) . into ( ) ,
1038- "first line.\n second line" . to_string ( ) ) ;
1039- // TESTING *REALLY* BROKEN BEHAVIOR:
1040- fm. next_line ( BytePos ( 0 ) ) ;
1041- fm. next_line ( BytePos ( 10 ) ) ;
1042- fm. next_line ( BytePos ( 2 ) ) ;
1043- }
1044-
10451017 fn init_code_map ( ) -> CodeMap {
10461018 let cm = CodeMap :: new ( FilePathMapping :: empty ( ) ) ;
1047- let fm1 = cm. new_filemap ( PathBuf :: from ( "blork.rs" ) . into ( ) ,
1048- "first line.\n second line" . to_string ( ) ) ;
1049- let fm2 = cm. new_filemap ( PathBuf :: from ( "empty.rs" ) . into ( ) ,
1050- "" . to_string ( ) ) ;
1051- let fm3 = cm. new_filemap ( PathBuf :: from ( "blork2.rs" ) . into ( ) ,
1052- "first line.\n second line" . to_string ( ) ) ;
1053-
1054- fm1. next_line ( BytePos ( 0 ) ) ;
1055- fm1. next_line ( BytePos ( 12 ) ) ;
1056- fm2. next_line ( fm2. start_pos ) ;
1057- fm3. next_line ( fm3. start_pos ) ;
1058- fm3. next_line ( fm3. start_pos + BytePos ( 12 ) ) ;
1059-
1019+ cm. new_filemap ( PathBuf :: from ( "blork.rs" ) . into ( ) ,
1020+ "first line.\n second line" . to_string ( ) ) ;
1021+ cm. new_filemap ( PathBuf :: from ( "empty.rs" ) . into ( ) ,
1022+ "" . to_string ( ) ) ;
1023+ cm. new_filemap ( PathBuf :: from ( "blork2.rs" ) . into ( ) ,
1024+ "first line.\n second line" . to_string ( ) ) ;
10601025 cm
10611026 }
10621027
@@ -1109,26 +1074,10 @@ mod tests {
11091074 fn init_code_map_mbc ( ) -> CodeMap {
11101075 let cm = CodeMap :: new ( FilePathMapping :: empty ( ) ) ;
11111076 // € is a three byte utf8 char.
1112- let fm1 =
1113- cm. new_filemap ( PathBuf :: from ( "blork.rs" ) . into ( ) ,
1114- "fir€st €€€€ line.\n second line" . to_string ( ) ) ;
1115- let fm2 = cm. new_filemap ( PathBuf :: from ( "blork2.rs" ) . into ( ) ,
1116- "first line€€.\n € second line" . to_string ( ) ) ;
1117-
1118- fm1. next_line ( BytePos ( 0 ) ) ;
1119- fm1. next_line ( BytePos ( 28 ) ) ;
1120- fm2. next_line ( fm2. start_pos ) ;
1121- fm2. next_line ( fm2. start_pos + BytePos ( 20 ) ) ;
1122-
1123- fm1. record_multibyte_char ( BytePos ( 3 ) , 3 ) ;
1124- fm1. record_multibyte_char ( BytePos ( 9 ) , 3 ) ;
1125- fm1. record_multibyte_char ( BytePos ( 12 ) , 3 ) ;
1126- fm1. record_multibyte_char ( BytePos ( 15 ) , 3 ) ;
1127- fm1. record_multibyte_char ( BytePos ( 18 ) , 3 ) ;
1128- fm2. record_multibyte_char ( fm2. start_pos + BytePos ( 10 ) , 3 ) ;
1129- fm2. record_multibyte_char ( fm2. start_pos + BytePos ( 13 ) , 3 ) ;
1130- fm2. record_multibyte_char ( fm2. start_pos + BytePos ( 18 ) , 3 ) ;
1131-
1077+ cm. new_filemap ( PathBuf :: from ( "blork.rs" ) . into ( ) ,
1078+ "fir€st €€€€ line.\n second line" . to_string ( ) ) ;
1079+ cm. new_filemap ( PathBuf :: from ( "blork2.rs" ) . into ( ) ,
1080+ "first line€€.\n € second line" . to_string ( ) ) ;
11321081 cm
11331082 }
11341083
0 commit comments