Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/defineProperty/symbol-data-property-default-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 default data property definition
7 flags: [onlyStrict]
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.throws(TypeError, function() {
38 delete obj[sym];
39 });
40
41 assert.notSameValue(
42 Object.getOwnPropertyDescriptor(obj, sym),
43 undefined,
44 "`Object.getOwnPropertyDescriptor(obj, sym)` does not return `undefined`"
45 );
46
47 assert.throws(TypeError, function() {
48 obj[sym] = 2;
49 });
50
51 assert.sameValue(obj[sym], 1, "The value of `obj[sym]` is `1`");