Simon Krajewski 13 gadi atpakaļ
vecāks
revīzija
fba9d21994
2 mainītis faili ar 6 papildinājumiem un 1 dzēšanām
  1. 1 1
      std/php/Boot.hx
  2. 5 0
      tests/unit/TestBasetypes.hx

+ 1 - 1
std/php/Boot.hx

@@ -398,7 +398,7 @@ function _hx_is_numeric($v)
 }
 
 function _hx_last_index_of($s, $value, $startIndex = null) {
-	$x = strrpos($s, $value, $startIndex === null ? null : strlen($s) - $startIndex);
+	$x = strrpos($s, $value, $startIndex === null ? 0 : $startIndex-strlen($s));
 	if($x === false)
 		return -1;
 	else

+ 5 - 0
tests/unit/TestBasetypes.hx

@@ -127,6 +127,11 @@ class TestBasetypes extends Test {
 		eq( Std.string(e), "C(0,h)");
 		
 		eq(Std.string([e]), "[C(0,h)]");
+		
+		var tester:String = "show me the (show me!) index of show me";
+		eq(tester.lastIndexOf("show me"), 32);
+		eq(tester.lastIndexOf("show me", 1), 0);
+		eq(tester.lastIndexOf("show me",28), 13);
 	}
 
 	function testMath() {