@@ -940,51 +940,16 @@ impl FilePathMapping {
940
940
#[ cfg( test) ]
941
941
mod tests {
942
942
use super :: * ;
943
- use std:: borrow:: Cow ;
944
943
use rustc_data_structures:: sync:: Lrc ;
945
944
946
- #[ test]
947
- fn t1 ( ) {
948
- let cm = CodeMap :: new ( FilePathMapping :: empty ( ) ) ;
949
- let fm = cm. new_filemap ( PathBuf :: from ( "blork.rs" ) . into ( ) ,
950
- "first line.\n second line" . to_string ( ) ) ;
951
- fm. next_line ( BytePos ( 0 ) ) ;
952
- // Test we can get lines with partial line info.
953
- assert_eq ! ( fm. get_line( 0 ) , Some ( Cow :: from( "first line." ) ) ) ;
954
- // TESTING BROKEN BEHAVIOR: line break declared before actual line break.
955
- fm. next_line ( BytePos ( 10 ) ) ;
956
- assert_eq ! ( fm. get_line( 1 ) , Some ( Cow :: from( "." ) ) ) ;
957
- fm. next_line ( BytePos ( 12 ) ) ;
958
- assert_eq ! ( fm. get_line( 2 ) , Some ( Cow :: from( "second line" ) ) ) ;
959
- }
960
-
961
- #[ test]
962
- #[ should_panic]
963
- fn t2 ( ) {
964
- let cm = CodeMap :: new ( FilePathMapping :: empty ( ) ) ;
965
- let fm = cm. new_filemap ( PathBuf :: from ( "blork.rs" ) . into ( ) ,
966
- "first line.\n second line" . to_string ( ) ) ;
967
- // TESTING *REALLY* BROKEN BEHAVIOR:
968
- fm. next_line ( BytePos ( 0 ) ) ;
969
- fm. next_line ( BytePos ( 10 ) ) ;
970
- fm. next_line ( BytePos ( 2 ) ) ;
971
- }
972
-
973
945
fn init_code_map ( ) -> CodeMap {
974
946
let cm = CodeMap :: new ( FilePathMapping :: empty ( ) ) ;
975
- let fm1 = cm. new_filemap ( PathBuf :: from ( "blork.rs" ) . into ( ) ,
976
- "first line.\n second line" . to_string ( ) ) ;
977
- let fm2 = cm. new_filemap ( PathBuf :: from ( "empty.rs" ) . into ( ) ,
978
- "" . to_string ( ) ) ;
979
- let fm3 = cm. new_filemap ( PathBuf :: from ( "blork2.rs" ) . into ( ) ,
980
- "first line.\n second line" . to_string ( ) ) ;
981
-
982
- fm1. next_line ( BytePos ( 0 ) ) ;
983
- fm1. next_line ( BytePos ( 12 ) ) ;
984
- fm2. next_line ( fm2. start_pos ) ;
985
- fm3. next_line ( fm3. start_pos ) ;
986
- fm3. next_line ( fm3. start_pos + BytePos ( 12 ) ) ;
987
-
947
+ cm. new_filemap ( PathBuf :: from ( "blork.rs" ) . into ( ) ,
948
+ "first line.\n second line" . to_string ( ) ) ;
949
+ cm. new_filemap ( PathBuf :: from ( "empty.rs" ) . into ( ) ,
950
+ "" . to_string ( ) ) ;
951
+ cm. new_filemap ( PathBuf :: from ( "blork2.rs" ) . into ( ) ,
952
+ "first line.\n second line" . to_string ( ) ) ;
988
953
cm
989
954
}
990
955
@@ -1037,26 +1002,10 @@ mod tests {
1037
1002
fn init_code_map_mbc ( ) -> CodeMap {
1038
1003
let cm = CodeMap :: new ( FilePathMapping :: empty ( ) ) ;
1039
1004
// € is a three byte utf8 char.
1040
- let fm1 =
1041
- cm. new_filemap ( PathBuf :: from ( "blork.rs" ) . into ( ) ,
1042
- "fir€st €€€€ line.\n second line" . to_string ( ) ) ;
1043
- let fm2 = cm. new_filemap ( PathBuf :: from ( "blork2.rs" ) . into ( ) ,
1044
- "first line€€.\n € second line" . to_string ( ) ) ;
1045
-
1046
- fm1. next_line ( BytePos ( 0 ) ) ;
1047
- fm1. next_line ( BytePos ( 28 ) ) ;
1048
- fm2. next_line ( fm2. start_pos ) ;
1049
- fm2. next_line ( fm2. start_pos + BytePos ( 20 ) ) ;
1050
-
1051
- fm1. record_multibyte_char ( BytePos ( 3 ) , 3 ) ;
1052
- fm1. record_multibyte_char ( BytePos ( 9 ) , 3 ) ;
1053
- fm1. record_multibyte_char ( BytePos ( 12 ) , 3 ) ;
1054
- fm1. record_multibyte_char ( BytePos ( 15 ) , 3 ) ;
1055
- fm1. record_multibyte_char ( BytePos ( 18 ) , 3 ) ;
1056
- fm2. record_multibyte_char ( fm2. start_pos + BytePos ( 10 ) , 3 ) ;
1057
- fm2. record_multibyte_char ( fm2. start_pos + BytePos ( 13 ) , 3 ) ;
1058
- fm2. record_multibyte_char ( fm2. start_pos + BytePos ( 18 ) , 3 ) ;
1059
-
1005
+ cm. new_filemap ( PathBuf :: from ( "blork.rs" ) . into ( ) ,
1006
+ "fir€st €€€€ line.\n second line" . to_string ( ) ) ;
1007
+ cm. new_filemap ( PathBuf :: from ( "blork2.rs" ) . into ( ) ,
1008
+ "first line€€.\n € second line" . to_string ( ) ) ;
1060
1009
cm
1061
1010
}
1062
1011
0 commit comments