Browse Source

Merge branch 'master' of ssh://github.com:/dop251/goja

Dmitry Panov 4 years ago
parent
commit
4b8079b256
2 changed files with 10 additions and 2 deletions
  1. 6 2
      builtin_string.go
  2. 4 0
      tc39_test.go

+ 6 - 2
builtin_string.go

@@ -940,8 +940,12 @@ func (r *Runtime) initString() {
 	o._putProp("toString", r.newNativeFunc(r.stringproto_toString, nil, "toString", nil, 0), true, false, true)
 	o._putProp("toString", r.newNativeFunc(r.stringproto_toString, nil, "toString", nil, 0), true, false, true)
 	o._putProp("toUpperCase", r.newNativeFunc(r.stringproto_toUpperCase, nil, "toUpperCase", nil, 0), true, false, true)
 	o._putProp("toUpperCase", r.newNativeFunc(r.stringproto_toUpperCase, nil, "toUpperCase", nil, 0), true, false, true)
 	o._putProp("trim", r.newNativeFunc(r.stringproto_trim, nil, "trim", nil, 0), true, false, true)
 	o._putProp("trim", r.newNativeFunc(r.stringproto_trim, nil, "trim", nil, 0), true, false, true)
-	o._putProp("trimEnd", r.newNativeFunc(r.stringproto_trimEnd, nil, "trimEnd", nil, 0), true, false, true)
-	o._putProp("trimStart", r.newNativeFunc(r.stringproto_trimStart, nil, "trimStart", nil, 0), true, false, true)
+	trimEnd := r.newNativeFunc(r.stringproto_trimEnd, nil, "trimEnd", nil, 0)
+	trimStart := r.newNativeFunc(r.stringproto_trimStart, nil, "trimStart", nil, 0)
+	o._putProp("trimEnd", trimEnd, true, false, true)
+	o._putProp("trimStart", trimStart, true, false, true)
+	o._putProp("trimRight", trimEnd, true, false, true)
+	o._putProp("trimLeft", trimStart, true, false, true)
 	o._putProp("valueOf", r.newNativeFunc(r.stringproto_valueOf, nil, "valueOf", nil, 0), true, false, true)
 	o._putProp("valueOf", r.newNativeFunc(r.stringproto_valueOf, nil, "valueOf", nil, 0), true, false, true)
 
 
 	o._putSym(SymIterator, valueProp(r.newNativeFunc(r.stringproto_iterator, nil, "[Symbol.iterator]", nil, 0), true, false, true))
 	o._putSym(SymIterator, valueProp(r.newNativeFunc(r.stringproto_iterator, nil, "[Symbol.iterator]", nil, 0), true, false, true))

+ 4 - 0
tc39_test.go

@@ -321,6 +321,8 @@ var (
 		"sec-arraybuffer-length",
 		"sec-arraybuffer-length",
 		"sec-arraybuffer",
 		"sec-arraybuffer",
 		"sec-regexp",
 		"sec-regexp",
+		"sec-string.prototype.trimLeft",
+		"sec-string.prototype.trimRight",
 	}
 	}
 )
 )
 
 
@@ -719,6 +721,8 @@ func TestTC39(t *testing.T) {
 		ctx.runTC39Tests("test/language/white-space")
 		ctx.runTC39Tests("test/language/white-space")
 		ctx.runTC39Tests("test/built-ins")
 		ctx.runTC39Tests("test/built-ins")
 		ctx.runTC39Tests("test/annexB/built-ins/String/prototype/substr")
 		ctx.runTC39Tests("test/annexB/built-ins/String/prototype/substr")
+		ctx.runTC39Tests("test/annexB/built-ins/String/prototype/trimLeft")
+		ctx.runTC39Tests("test/annexB/built-ins/String/prototype/trimRight")
 		ctx.runTC39Tests("test/annexB/built-ins/escape")
 		ctx.runTC39Tests("test/annexB/built-ins/escape")
 		ctx.runTC39Tests("test/annexB/built-ins/unescape")
 		ctx.runTC39Tests("test/annexB/built-ins/unescape")
 		ctx.runTC39Tests("test/annexB/built-ins/RegExp")
 		ctx.runTC39Tests("test/annexB/built-ins/RegExp")