@@ -228,13 +228,20 @@ public function testMovingCursorWithoutEchoDoesNotNeedToRedraw()
228228 $ this ->assertSame ($ this ->readline , $ this ->readline ->moveCursorBy (2 ));
229229 }
230230
231- public function testDataEventWillBeEmittedForCompleteLine ()
231+ public function testDataEventWillBeEmittedForCompleteLineWithNl ()
232232 {
233233 $ this ->readline ->on ('data ' , $ this ->expectCallableOnceWith ("hello \n" ));
234234
235235 $ this ->input ->emit ('data ' , array ("hello \n" ));
236236 }
237237
238+ public function testDataEventWillBeEmittedWithNlAlsoForCompleteLineWithCr ()
239+ {
240+ $ this ->readline ->on ('data ' , $ this ->expectCallableOnceWith ("hello \n" ));
241+
242+ $ this ->input ->emit ('data ' , array ("hello \r" ));
243+ }
244+
238245 public function testDataEventWillNotBeEmittedForIncompleteLineButWillStayInInputBuffer ()
239246 {
240247 $ this ->readline ->on ('data ' , $ this ->expectCallableNever ());
@@ -981,6 +988,23 @@ public function testBindCustomFunctionCanOverwriteAutocompleteBehavior()
981988 $ this ->input ->emit ('data ' , array ("\t" ));
982989 }
983990
991+ public function testBindCustomFunctionToNlOverwritesDataEvent ()
992+ {
993+ $ this ->readline ->on ("\n" , $ this ->expectCallableOnceWith ("\n" ));
994+ $ this ->readline ->on ('line ' , $ this ->expectCallableNever ());
995+
996+ $ this ->input ->emit ('data ' , array ("hello \n" ));
997+ }
998+
999+ public function testBindCustomFunctionToNlFiresOnCr ()
1000+ {
1001+ $ this ->readline ->on ("\n" , $ this ->expectCallableOnceWith ("\n" ));
1002+ $ this ->readline ->on ("\r" , $ this ->expectCallableNever ());
1003+ $ this ->readline ->on ('line ' , $ this ->expectCallableNever ());
1004+
1005+ $ this ->input ->emit ('data ' , array ("hello \r" ));
1006+ }
1007+
9841008 public function testEmitEmptyInputOnEnter ()
9851009 {
9861010 $ this ->readline ->on ('data ' , $ this ->expectCallableOnceWith ("\n" ));
0 commit comments