Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/defineProperty/symbol-data-property-default-non-strict.js

raw
1 // Copyright (C) 2013 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 es6id: 19.1.2.4
5 description: >
6 Symbol used as property for property definition
7 flags: [noStrict]
8 features: [Symbol]
9 ---*/
10 var sym = Symbol();
11 var obj = {};
12
13
14 Object.defineProperty(obj, sym, {
15 value: 1,
16 });
17
18 assert.sameValue(sym in obj, true, "The result of `sym in obj` is `true`");
19 assert.sameValue(
20 Object.hasOwnProperty.call(obj, sym),
21 true,
22 "`Object.hasOwnProperty.call(obj, sym)` returns `true`"
23 );
24
25 var desc = Object.getOwnPropertyDescriptor(obj, sym);
26
27 assert.sameValue(desc.value, 1, "The value of `desc.value` is `1`");
28 assert.sameValue(desc.configurable, false, "The value of `desc.configurable` is `false`");
29 assert.sameValue(desc.writable, false, "The value of `desc.writable` is `false`");
30 assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`");
31 assert.sameValue(
32 Object.prototype.propertyIsEnumerable.call(obj, sym),
33 false,
34 "`Object.prototype.propertyIsEnumerable.call(obj, sym)` returns `false`"
35 );
36
37 assert.sameValue(delete obj[sym], false, "The result of `delete obj[sym]` is `false`");
38
39 assert.notSameValue(
40 Object.getOwnPropertyDescriptor(obj, sym),
41 undefined,
42 "`Object.getOwnPropertyDescriptor(obj, sym)` does not return `undefined`"
43 );
44
45 obj[sym] = 2;
46
47 assert.sameValue(obj[sym], 1, "The value of `obj[sym]` is `1`");