Fix RegExp.prototype.toString .length & .prototype

This commit is contained in:
Robert Krimen
2013-05-02 20:23:07 +02:00
parent bc84827b09
commit 596af0a836
2 changed files with 13 additions and 1 deletions

View File

@@ -668,7 +668,7 @@ func newContext() *_runtime {
"RegExp", builtinRegExp,
builtinNewRegExp,
self.Global.RegExpPrototype,
"toString", 0, builtinRegExp_toString,
"toString", -0xff, builtinRegExp_toString,
"exec", -1, builtinRegExp_exec,
"test", -1, builtinRegExp_test,
)
@@ -829,6 +829,10 @@ func (runtime *_runtime) newNativeFunction(_nativeFunction _nativeFunction, leng
// TODO Do this a better way...
if 0 > length {
length *= -1
// TODO Achk... hack
if length == 0xff {
length = 0
}
prototype = false
}
self := runtime.newNativeFunctionObject(_nativeFunction, length, name)

View File

@@ -139,6 +139,14 @@ func TestRegExp_test(t *testing.T) {
test(`RegExp.prototype.test.prototype`, "undefined")
}
func TestRegExp_toString(t *testing.T) {
Terst(t)
test := runTest()
test(`RegExp.prototype.toString.length`, "0")
test(`RegExp.prototype.toString.prototype`, "undefined")
}
func TestRegExp_zaacbbbcac(t *testing.T) {
Terst(t)