This commit is contained in:
Gordon Williams 2014-05-21 17:57:10 +01:00
parent 6db1009b18
commit c9bef247f4
2 changed files with 7 additions and 5 deletions

View File

@ -227,7 +227,8 @@ JsVar *jswrap_string_slice(JsVar *parent, JsVarInt pStart, JsVar *vEnd) {
if (pEnd<0) pEnd = 0;
res = jsvNewWithFlags(JSV_STRING);
if (!res) return 0; // out of memory
jsvAppendStringVar(res, parent, (size_t)pStart, (size_t)(pEnd-pStart));
if (pEnd>pStart)
jsvAppendStringVar(res, parent, (size_t)pStart, (size_t)(pEnd-pStart));
return res;
}

View File

@ -1,9 +1,10 @@
var r = [
"foobar".slice(-1) === "r", // false, expected true
"foobar".slice(-1, 10) === "r", // false, expected true
"foobar".slice(-1, -1) === "", // false, expected true
"foobar".slice(10, -10) === "", // false, expected true
"foobar".slice(-1) === "r",
"foobar".slice(-1, 10) === "r",
"foobar".slice(-1, -1) === "",
"foobar".slice(10, -10) === "",
"Hello".slice(3,2) === "",
];
var pass = 0;