]> git.r.bdr.sh - rbdr/dotfiles/blob
866005b03df29b9098df040ac784d9b2eeedd793
[rbdr/dotfiles] /
1 'use strict';
2
3 module.exports = function (t, a) {
4 var o, o1, o2, x, y = {}, z = {};
5 o = { inherited: true };
6 o1 = Object.create(o);
7 o1.visible = z;
8 o1.nonremovable = 'raz';
9 Object.defineProperty(o1, 'hidden', { value: 'hidden' });
10
11 o2 = Object.defineProperties({}, { nonremovable: { value: y } });
12 o2.other = 'other';
13
14 try { t(o2, o1); } catch (ignore) {}
15
16 a(o2.visible, z, "Enumerable");
17 a(o1.hidden, 'hidden', "Not Enumerable");
18 a(o2.propertyIsEnumerable('visible'), true, "Enumerable is enumerable");
19 a(o2.propertyIsEnumerable('hidden'), false,
20 "Not enumerable is not enumerable");
21
22 a(o2.hasOwnProperty('inherited'), false, "Extend only own");
23 a(o2.inherited, undefined, "Extend ony own: value");
24
25 a(o2.nonremovable, y, "Do not overwrite non configurable");
26 a(o2.other, 'other', "Own kept");
27
28 x = {};
29 t(x, o2);
30 try { t(x, o1); } catch (ignore) {}
31
32 a(x.visible, z, "Enumerable");
33 a(x.hidden, 'hidden', "Not Enumerable");
34 a(x.propertyIsEnumerable('visible'), true, "Enumerable is enumerable");
35 a(x.propertyIsEnumerable('hidden'), false,
36 "Not enumerable is not enumerable");
37
38 a(x.hasOwnProperty('inherited'), false, "Extend only own");
39 a(x.inherited, undefined, "Extend ony own: value");
40
41 a(x.nonremovable, y, "Ignored non configurable");
42 a(x.other, 'other', "Other");
43
44 x.visible = 3;
45 a(x.visible, 3, "Writable is writable");
46
47 x = {};
48 t(x, o1);
49 a.throws(function () {
50 x.hidden = 3;
51 }, "Not writable is not writable");
52
53 x = {};
54 t(x, o1);
55 delete x.visible;
56 a.ok(!x.hasOwnProperty('visible'), "Configurable is configurable");
57
58 x = {};
59 t(x, o1);
60 a.throws(function () {
61 delete x.hidden;
62 }, "Not configurable is not configurable");
63
64 x = Object.defineProperty({}, 'foo',
65 { configurable: false, writable: true, enumerable: false, value: 'bar' });
66
67 try { t(x, { foo: 'lorem' }); } catch (ignore) {}
68 a(x.foo, 'bar', "Writable, not enumerable");
69 };