test262/src/generators/yield-identifier-spread-non-strict.case
Philip Chimento d87a7da6e1 Replace Object.hasOwnProperty.call with Object.prototype.hasOwnProperty.call
While we're at it, use assert() instead of assert.sameValue() for brevity,
if we are not specifically testing that the return value of hasOwnProperty
is the value true or false; and add more informative assertion messages to
help with debugging.

In some cases, the Object.hasOwnProperty.call could be replaced with
verifyProperty(), if the property descriptor was also being verified at
the same time.

This fixes some tests that were faulty to begin with: a common mistake was
Object.hasOwnProperty(obj, prop) which is probably going to return false
when that's not what you want.

The only instances left of `Object.hasOwnProperty` are one regression test
in implementation-contributed which I can't tell if it was intentionally
needed to trigger the regression, and a few instances of
`Object.hasOwnProperty('prototype')` which would defeat the purpose to
convert into `Object.prototype.hasOwnProperty.call(Object, 'prototype')`
form.

Closes: #3524
2022-11-30 16:04:02 -08:00

50 lines
1.2 KiB
Plaintext

// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: >
Mixed use of object spread and yield as a valid identifier in a function body
inside a generator body in non strict mode
template: non-strict
info: |
Spread Properties
PropertyDefinition[Yield]:
(...)
...AssignmentExpression[In, ?Yield]
features: [Symbol, object-spread]
flags: [noStrict]
---*/
//- setup
var s = Symbol('s');
//- body
yield {
...yield yield,
...(function(arg) {
var yield = arg;
return {...yield};
}(yield)),
...yield,
}
//- assertions
var iter = gen();
iter.next();
iter.next();
iter.next({ x: 10, a: 0, b: 0, [s]: 1 });
iter.next({ y: 20, a: 1, b: 1, [s]: 42 });
var item = iter.next({ z: 30, b: 2 });
var value = item.value;
assert.sameValue(item.done, false);
assert.sameValue(value.x, 10);
assert.sameValue(value.y, 20);
assert.sameValue(value.z, 30);
assert.sameValue(value.a, 1);
assert.sameValue(value.b, 2);
assert.sameValue(value[s], 42);
assert(Object.prototype.hasOwnProperty.call(value, s), "s is an own property");
assert.sameValue(Object.keys(value).length, 5);