@@ -79,11 +79,29 @@ type StringModule() =
7979
8080 [<Test>]
8181 member this.MapI () =
82- let e1 = String.mapi ( fun i c -> char ( int c + i )) " foo "
83- Assert.AreEqual( " fpq " , e1)
82+ let e1 = String.mapi ( fun _ c -> c ) " 12345 "
83+ Assert.AreEqual( " 12345 " , e1)
8484
85- let e2 = String.mapi ( fun i c -> c) null
86- Assert.AreEqual( " " , e2)
85+ let e2 = String.mapi ( fun _ c -> c + char 1 ) " 1"
86+ Assert.AreEqual( " 2" , e2)
87+
88+ let e3 = String.mapi ( fun _ c -> c + char 1 ) " AB"
89+ Assert.AreEqual( " BC" , e3)
90+
91+ let e4 = String.mapi ( fun i c -> char( int c + i)) " foo"
92+ Assert.AreEqual( " fpq" , e4)
93+
94+ let e5 = String.mapi ( fun _ c -> c) null
95+ Assert.AreEqual( " " , e5)
96+
97+ let e6 = String.mapi ( fun _ c -> c) String.Empty
98+ Assert.AreEqual( " " , e6)
99+
100+ let e7 = String.mapi ( fun _ _ -> failwith " should not fail" ) null
101+ Assert.AreEqual( " " , e7)
102+
103+ let e8 = String.mapi ( fun i _ -> if i = 1 then failwith " should not fail" else char i) " X"
104+ Assert.AreEqual( " \u0000 " , e8)
87105
88106 [<Test>]
89107 member this.Filter () =
0 commit comments