mirror of
https://github.com/robertkrimen/otto.git
synced 2025-12-24 12:58:05 +08:00
Fix RegExp.prototype.toString .length & .prototype
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user