Bug 451580, fix string split assertions and return values. Tests fail with JIT on for other reasons, it seems. r=shaver

This commit is contained in:
Robert Sayre 2008-08-21 14:06:42 -04:00
parent ee5f8e441f
commit c6a7088bae
3 changed files with 25 additions and 4 deletions

View File

@ -60,7 +60,7 @@ BUILTIN3(String_p_concat_1int, LO, LO, LO, P, JSString*, JSContest*, JSString*
BUILTIN4(String_p_match, LO, LO, LO, LO, P, JSObject*, JSContext*, JSString*, jsbytecode*, JSObject*, 1, 1)
BUILTIN4(String_p_replace_str, LO, LO, LO, LO, P, JSString*, JSContext*, JSString*, JSObject*, JSString*, 1, 1)
BUILTIN5(String_p_replace_str3, LO, LO, LO, LO, LO, P, JSString*, JSContext*, JSString*, JSString*, JSString*, JSString*, 1, 1)
BUILTIN3(String_p_split, LO, LO, LO, P, JSString*, JSContext*, JSString*, JSString*, 1, 1)
BUILTIN3(String_p_split, LO, LO, LO, P, JSObject*, JSContext*, JSString*, JSString*, 1, 1)
BUILTIN1(Math_random, LO, F, jsdouble, JSRuntime*, 1, 1)
BUILTIN2(EqualStrings, LO, LO, LO, bool, JSString*, JSString*, 1, 1)
BUILTIN2(CompareStrings, LO, LO, LO, bool, JSString*, JSString*, 1, 1)

View File

@ -303,15 +303,15 @@ js_String_p_replace_str3(JSContext* cx, JSString* str, JSString* patstr, JSStrin
return JSVAL_TO_STRING(vp[0]);
}
JSString* FASTCALL
JSObject* FASTCALL
js_String_p_split(JSContext* cx, JSString* str, JSString* sepstr)
{
// FIXME: optimize by calling into a lower level exported from jsstr.cpp.
jsval vp[3] = { JSVAL_NULL, STRING_TO_JSVAL(str), STRING_TO_JSVAL(sepstr) };
if (!js_str_split(cx, 2, vp))
return NULL;
JS_ASSERT(JSVAL_IS_STRING(vp[0]));
return JSVAL_TO_STRING(vp[0]);
JS_ASSERT(JSVAL_IS_OBJECT(vp[0]));
return JSVAL_TO_OBJECT(vp[0]);
}
jsdouble FASTCALL

View File

@ -813,6 +813,27 @@ function newArrayTest()
newArrayTest.expected="0,0,0,0,0,0,0,0,0,0";
test(newArrayTest);
function stringSplitTest()
{
var s = "a,b"
var a = null;
for (var i = 0; i < 10; ++i)
a = s.split(",");
return a.join();
}
stringSplitTest.expected="a,b";
test(stringSplitTest);
function stringSplitIntoArrayTest()
{
var s = "a,b"
var a = [];
for (var i = 0; i < 10; ++i)
a[i] = s.split(",");
return a.join();
}
stringSplitIntoArrayTest.expected="a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b,a,b";
test(stringSplitIntoArrayTest);
/* Keep these at the end so that we can see the summary after the trace-debug spew. */
print("\npassed:", passes.length && passes.join(","));