Mihail Stoykov преди 4 години
родител
ревизия
84c67e9be5
променени са 2 файла, в които са добавени 18 реда и са изтрити 1 реда
  1. 16 0
      builtin_object.go
  2. 2 1
      tc39_test.go

+ 16 - 0
builtin_object.go

@@ -384,6 +384,21 @@ func (r *Runtime) object_entries(call FunctionCall) Value {
 	return r.newArrayValues(values)
 }
 
+func (r *Runtime) object_values(call FunctionCall) Value {
+	obj := call.Argument(0).ToObject(r)
+
+	var values []Value
+	iter := &enumerableIter{
+		wrapped: obj.self.enumerateOwnKeys(),
+	}
+
+	for item, next := iter.next(); next != nil; item, next = next() {
+		values = append(values, obj.self.getStr(item.name, nil))
+	}
+
+	return r.newArrayValues(values)
+}
+
 func (r *Runtime) objectproto_hasOwnProperty(call FunctionCall) Value {
 	p := toPropertyKey(call.Argument(0))
 	o := call.This.ToObject(r)
@@ -563,6 +578,7 @@ func (r *Runtime) initObject() {
 	o._putProp("isExtensible", r.newNativeFunc(r.object_isExtensible, nil, "isExtensible", nil, 1), true, false, true)
 	o._putProp("keys", r.newNativeFunc(r.object_keys, nil, "keys", nil, 1), true, false, true)
 	o._putProp("setPrototypeOf", r.newNativeFunc(r.object_setPrototypeOf, nil, "setPrototypeOf", nil, 2), true, false, true)
+	o._putProp("values", r.newNativeFunc(r.object_values, nil, "values", nil, 1), true, false, true)
 
 	r.addToGlobal("Object", r.global.Object)
 }

+ 2 - 1
tc39_test.go

@@ -327,6 +327,7 @@ var (
 		"sec-object.getownpropertydescriptor",
 		"sec-object.getownpropertydescriptors",
 		"sec-object.entries",
+		"sec-object.values",
 		"sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys",
 	}
 )
@@ -696,7 +697,7 @@ func TestTC39(t *testing.T) {
 	// Tests ignored: 10,453, passed: 14,782
 
 	// at ddfe24afe3043388827aa220ef623b8540958bbd
-	// Tests ignored: 19,183, passed: 14,512
+	// Tests ignored: 19,164, passed: 14,529
 
 	ctx := &tc39TestCtx{
 		base: tc39BASE,