diff --git a/global.go b/global.go index cb96e08..cd00aae 100644 --- a/global.go +++ b/global.go @@ -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) diff --git a/regexp_test.go b/regexp_test.go index 93f2abb..afee5be 100644 --- a/regexp_test.go +++ b/regexp_test.go @@ -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)