]> 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/es5-ext/test/array/of/shim.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 / es5-ext / test / array / of / shim.js
1 // Most tests taken from https://github.com/mathiasbynens/Array.of/blob/master/tests/tests.js
2 // Thanks @mathiasbynens
3
4 'use strict';
5
6 var defineProperty = Object.defineProperty;
7
8 module.exports = function (t, a) {
9         var x = {}, testObject, MyType;
10
11         a.deep(t(), [], "No arguments");
12         a.deep(t(3), [3], "One numeric argument");
13         a.deep(t(3, 'raz', null, x, undefined), [3, 'raz', null, x, undefined],
14                 "Many arguments");
15
16         a(t.length, 0, "Length");
17
18         a.deep(t('abc'), ['abc'], "String");
19         a.deep(t(undefined), [undefined], "Undefined");
20         a.deep(t(null), [null], "Null");
21         a.deep(t(false), [false], "Boolean");
22         a.deep(t(-Infinity), [-Infinity], "Infinity");
23         a.deep(t(-0), [-0], "-0");
24         a.deep(t(+0), [+0], "+0");
25         a.deep(t(1), [1], "1");
26         a.deep(t(1, 2, 3), [1, 2, 3], "Numeric args");
27         a.deep(t(+Infinity), [+Infinity], "+Infinity");
28         a.deep(t({ '0': 'a', '1': 'b', '2': 'c', length: 3 }),
29                 [{ '0': 'a', '1': 'b', '2': 'c', length: 3 }], "Array like");
30         a.deep(t(undefined, null, false, -Infinity, -0, +0, 1, 2, +Infinity),
31                 [undefined, null, false, -Infinity, -0, +0, 1, 2, +Infinity], "Falsy arguments");
32
33         a.h1("Null context");
34         a.deep(t.call(null, 'abc'), ['abc'], "String");
35         a.deep(t.call(null, undefined), [undefined], "Undefined");
36         a.deep(t.call(null, null), [null], "Null");
37         a.deep(t.call(null, false), [false], "Boolean");
38         a.deep(t.call(null, -Infinity), [-Infinity], "-Infinity");
39         a.deep(t.call(null, -0), [-0], "-0");
40         a.deep(t.call(null, +0), [+0], "+0");
41         a.deep(t.call(null, 1), [1], "1");
42         a.deep(t.call(null, 1, 2, 3), [1, 2, 3], "Numeric");
43         a.deep(t.call(null, +Infinity), [+Infinity], "+Infinity");
44         a.deep(t.call(null, { '0': 'a', '1': 'b', '2': 'c', length: 3 }),
45                 [{ '0': 'a', '1': 'b', '2': 'c', length: 3 }], "Array-like");
46         a.deep(t.call(null, undefined, null, false, -Infinity, -0, +0, 1, 2, +Infinity),
47                 [undefined, null, false, -Infinity, -0, +0, 1, 2, +Infinity], "Falsy");
48
49         a.h1("Other constructor context");
50         a.deep(t.call(Object, 1, 2, 3), { '0': 1, '1': 2, '2': 3, length: 3 }, "Many arguments");
51
52         testObject = Object(3);
53         testObject[0] = 1;
54         testObject[1] = 2;
55         testObject[2] = 3;
56         testObject.length = 3;
57         a.deep(t.call(Object, 1, 2, 3), testObject, "Test object");
58         a(t.call(Object).length, 0, "No arguments");
59         a.throws(function () { t.call(function () { return Object.freeze({}); }); }, TypeError,
60                 "Frozen instance");
61
62         // Ensure no setters are called for the indexes
63         MyType = function () {};
64         defineProperty(MyType.prototype, '0', {
65                 set: function (x) { throw new Error('Setter called: ' + x); }
66         });
67         a.deep(t.call(MyType, 'abc'), { '0': 'abc', length: 1 }, "Define, not set");
68 };