]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/test/lazy.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / node-gyp / node_modules / path-array / node_modules / array-index / node_modules / es6-symbol / node_modules / d / test / lazy.js
1 'use strict';
2
3 var d = require('../')
4
5   , getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
6
7 module.exports = function (t, a) {
8         var Foo = function () {}, i = 1, o, o2, desc;
9         Object.defineProperties(Foo.prototype, t({
10                 bar: d(function () { return ++i; }),
11                 bar2: d(function () { return this.bar + 23; }),
12                 bar3: d(function () { return this.bar2 + 34; }, { desc: 'ew' }),
13                 bar4: d(function () { return this.bar3 + 12; }, { cacheName: '_bar4_' }),
14                 bar5: d(function () { return this.bar4 + 3; },
15                         { cacheName: '_bar5_', desc: 'e' })
16         }));
17
18         desc = getOwnPropertyDescriptor(Foo.prototype, 'bar');
19         a(desc.configurable, true, "Configurable: default");
20         a(desc.enumerable, false, "Enumerable: default");
21
22         o = new Foo();
23         a.deep([o.bar, o.bar2, o.bar3, o.bar4, o.bar5], [2, 25, 59, 71, 74],
24                 "Values");
25
26         a.deep(getOwnPropertyDescriptor(o, 'bar3'), { configurable: false,
27                 enumerable: true, writable: true, value: 59 }, "Desc");
28         a(o.hasOwnProperty('bar4'), false, "Cache not exposed");
29         desc = getOwnPropertyDescriptor(o, 'bar5');
30         a.deep(desc, { configurable: false,
31                 enumerable: true, get: desc.get, set: desc.set }, "Cache & Desc: desc");
32
33         o2 = Object.create(o);
34         o2.bar = 30;
35         o2.bar3 = 100;
36
37         a.deep([o2.bar, o2.bar2, o2.bar3, o2.bar4, o2.bar5], [30, 25, 100, 112, 115],
38                 "Extension Values");
39
40         Foo = function () {};
41         Object.defineProperties(Foo.prototype, t({
42                 test: d('w', function () { return 'raz'; }),
43                 test2: d('', function () { return 'raz'; }, { desc: 'w' }),
44                 test3: d('', function () { return 'raz'; },
45                         { cacheName: '__test3__', desc: 'w' }),
46                 test4: d('w', 'bar')
47         }));
48
49         o = new Foo();
50         o.test = 'marko';
51         a.deep(getOwnPropertyDescriptor(o, 'test'),
52                 { configurable: false, enumerable: false, writable: true, value: 'marko' },
53                 "Set before get");
54         o.test2 = 'marko2';
55         a.deep(getOwnPropertyDescriptor(o, 'test2'),
56                 { configurable: false, enumerable: false, writable: true, value: 'marko2' },
57                 "Set before get: Custom desc");
58         o.test3 = 'marko3';
59         a.deep(getOwnPropertyDescriptor(o, '__test3__'),
60                 { configurable: false, enumerable: false, writable: true, value: 'marko3' },
61                 "Set before get: Custom cache name");
62         a(o.test4, 'bar', "Resolve by value");
63
64         a.h1("Flat");
65         Object.defineProperties(Foo.prototype, t({
66                 flat: d(function () { return 'foo'; }, { flat: true }),
67                 flat2: d(function () { return 'bar'; }, { flat: true })
68         }));
69
70         a.h2("Instance");
71         a(o.flat, 'foo', "Value");
72         a(o.hasOwnProperty('flat'), false, "Instance");
73         a(Foo.prototype.flat, 'foo', "Prototype");
74
75         a.h2("Direct");
76         a(Foo.prototype.flat2, 'bar');
77 };