]>
git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/vim-mode/node_modules/grim/node_modules/emissary/node_modules/es6-weak-map/node_modules/es5-ext/test/string/#/at.js
2447a9f64d5d83c3075e2df9ac335ec76bb32758
1 // See tests at https://github.com/mathiasbynens/String.prototype.at
5 module
.exports = function (t
, a
) {
6 a(t
.length
, 1, "Length");
9 a(t
.call('abc\uD834\uDF06def', -Infinity
), '', "-Infinity");
10 a(t
.call('abc\uD834\uDF06def', -1), '', "-1");
11 a(t
.call('abc\uD834\uDF06def', -0), 'a', "-0");
12 a(t
.call('abc\uD834\uDF06def', +0), 'a', "+0");
13 a(t
.call('abc\uD834\uDF06def', 1), 'b', "1");
14 a(t
.call('abc\uD834\uDF06def', 3), '\uD834\uDF06', "3");
15 a(t
.call('abc\uD834\uDF06def', 4), '\uDF06', "4");
16 a(t
.call('abc\uD834\uDF06def', 5), 'd', "5");
17 a(t
.call('abc\uD834\uDF06def', 42), '', "42");
18 a(t
.call('abc\uD834\uDF06def', +Infinity
), '', "+Infinity");
19 a(t
.call('abc\uD834\uDF06def', null), 'a', "null");
20 a(t
.call('abc\uD834\uDF06def', undefined), 'a', "undefined");
21 a(t
.call('abc\uD834\uDF06def'), 'a', "No argument");
22 a(t
.call('abc\uD834\uDF06def', false), 'a', "false");
23 a(t
.call('abc\uD834\uDF06def', NaN
), 'a', "NaN");
24 a(t
.call('abc\uD834\uDF06def', ''), 'a', "Empty string");
25 a(t
.call('abc\uD834\uDF06def', '_'), 'a', "_");
26 a(t
.call('abc\uD834\uDF06def', '1'), 'b', "'1'");
27 a(t
.call('abc\uD834\uDF06def', []), 'a', "[]");
28 a(t
.call('abc\uD834\uDF06def', {}), 'a', "{}");
29 a(t
.call('abc\uD834\uDF06def', -0.9), 'a', "-0.9");
30 a(t
.call('abc\uD834\uDF06def', 1.9), 'b', "1.9");
31 a(t
.call('abc\uD834\uDF06def', 7.9), 'f', "7.9");
32 a(t
.call('abc\uD834\uDF06def', Math
.pow(2, 32)), '', "Big number");
34 a
.h1("Astral symbol");
35 a(t
.call('\uD834\uDF06def', -Infinity
), '', "-Infinity");
36 a(t
.call('\uD834\uDF06def', -1), '', "-1");
37 a(t
.call('\uD834\uDF06def', -0), '\uD834\uDF06', "-0");
38 a(t
.call('\uD834\uDF06def', +0), '\uD834\uDF06', "+0");
39 a(t
.call('\uD834\uDF06def', 1), '\uDF06', "1");
40 a(t
.call('\uD834\uDF06def', 2), 'd', "2");
41 a(t
.call('\uD834\uDF06def', 3), 'e', "3");
42 a(t
.call('\uD834\uDF06def', 4), 'f', "4");
43 a(t
.call('\uD834\uDF06def', 42), '', "42");
44 a(t
.call('\uD834\uDF06def', +Infinity
), '', "+Infinity");
45 a(t
.call('\uD834\uDF06def', null), '\uD834\uDF06', "null");
46 a(t
.call('\uD834\uDF06def', undefined), '\uD834\uDF06', "undefined");
47 a(t
.call('\uD834\uDF06def'), '\uD834\uDF06', "No arguments");
48 a(t
.call('\uD834\uDF06def', false), '\uD834\uDF06', "false");
49 a(t
.call('\uD834\uDF06def', NaN
), '\uD834\uDF06', "NaN");
50 a(t
.call('\uD834\uDF06def', ''), '\uD834\uDF06', "Empty string");
51 a(t
.call('\uD834\uDF06def', '_'), '\uD834\uDF06', "_");
52 a(t
.call('\uD834\uDF06def', '1'), '\uDF06', "'1'");
54 a
.h1("Lone high surrogates");
55 a(t
.call('\uD834abc', -Infinity
), '', "-Infinity");
56 a(t
.call('\uD834abc', -1), '', "-1");
57 a(t
.call('\uD834abc', -0), '\uD834', "-0");
58 a(t
.call('\uD834abc', +0), '\uD834', "+0");
59 a(t
.call('\uD834abc', 1), 'a', "1");
60 a(t
.call('\uD834abc', 42), '', "42");
61 a(t
.call('\uD834abc', +Infinity
), '', "Infinity");
62 a(t
.call('\uD834abc', null), '\uD834', "null");
63 a(t
.call('\uD834abc', undefined), '\uD834', "undefined");
64 a(t
.call('\uD834abc'), '\uD834', "No arguments");
65 a(t
.call('\uD834abc', false), '\uD834', "false");
66 a(t
.call('\uD834abc', NaN
), '\uD834', "NaN");
67 a(t
.call('\uD834abc', ''), '\uD834', "Empty string");
68 a(t
.call('\uD834abc', '_'), '\uD834', "_");
69 a(t
.call('\uD834abc', '1'), 'a', "'a'");
71 a
.h1("Lone low surrogates");
72 a(t
.call('\uDF06abc', -Infinity
), '', "-Infinity");
73 a(t
.call('\uDF06abc', -1), '', "-1");
74 a(t
.call('\uDF06abc', -0), '\uDF06', "-0");
75 a(t
.call('\uDF06abc', +0), '\uDF06', "+0");
76 a(t
.call('\uDF06abc', 1), 'a', "1");
77 a(t
.call('\uDF06abc', 42), '', "42");
78 a(t
.call('\uDF06abc', +Infinity
), '', "+Infinity");
79 a(t
.call('\uDF06abc', null), '\uDF06', "null");
80 a(t
.call('\uDF06abc', undefined), '\uDF06', "undefined");
81 a(t
.call('\uDF06abc'), '\uDF06', "No arguments");
82 a(t
.call('\uDF06abc', false), '\uDF06', "false");
83 a(t
.call('\uDF06abc', NaN
), '\uDF06', "NaN");
84 a(t
.call('\uDF06abc', ''), '\uDF06', "Empty string");
85 a(t
.call('\uDF06abc', '_'), '\uDF06', "_");
86 a(t
.call('\uDF06abc', '1'), 'a', "'1'");
89 a
.throws(function () { t
.call(undefined); }, TypeError
, "Undefined");
90 a
.throws(function () { t
.call(undefined, 4); }, TypeError
,
91 "Undefined + argument");
92 a
.throws(function () { t
.call(null); }, TypeError
, "Null");
93 a
.throws(function () { t
.call(null, 4); }, TypeError
, "Null + argument");
94 a(t
.call(42, 0), '4', "Number #1");
95 a(t
.call(42, 1), '2', "Number #2");
96 a(t
.call({ toString: function () { return 'abc'; } }, 2), 'c', "Object");