shim.js
3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* eslint no-useless-call: "off" */
// Taken from: https://github.com/mathiasbynens/String.prototype.codePointAt
// /blob/master/tests/tests.js
"use strict";
module.exports = function (t, a) {
a(t.length, 1, "Length");
// String that starts with a BMP symbol
a(t.call("abc\uD834\uDF06def", ""), 0x61);
a(t.call("abc\uD834\uDF06def", "_"), 0x61);
a(t.call("abc\uD834\uDF06def"), 0x61);
a(t.call("abc\uD834\uDF06def", -Infinity), undefined);
a(t.call("abc\uD834\uDF06def", -1), undefined);
a(t.call("abc\uD834\uDF06def", -0), 0x61);
a(t.call("abc\uD834\uDF06def", 0), 0x61);
a(t.call("abc\uD834\uDF06def", 3), 0x1d306);
a(t.call("abc\uD834\uDF06def", 4), 0xdf06);
a(t.call("abc\uD834\uDF06def", 5), 0x64);
a(t.call("abc\uD834\uDF06def", 42), undefined);
a(t.call("abc\uD834\uDF06def", Infinity), undefined);
a(t.call("abc\uD834\uDF06def", Infinity), undefined);
a(t.call("abc\uD834\uDF06def", NaN), 0x61);
a(t.call("abc\uD834\uDF06def", false), 0x61);
a(t.call("abc\uD834\uDF06def", null), 0x61);
a(t.call("abc\uD834\uDF06def", undefined), 0x61);
// String that starts with an astral symbol
a(t.call("\uD834\uDF06def", ""), 0x1d306);
a(t.call("\uD834\uDF06def", "1"), 0xdf06);
a(t.call("\uD834\uDF06def", "_"), 0x1d306);
a(t.call("\uD834\uDF06def"), 0x1d306);
a(t.call("\uD834\uDF06def", -1), undefined);
a(t.call("\uD834\uDF06def", -0), 0x1d306);
a(t.call("\uD834\uDF06def", 0), 0x1d306);
a(t.call("\uD834\uDF06def", 1), 0xdf06);
a(t.call("\uD834\uDF06def", 42), undefined);
a(t.call("\uD834\uDF06def", false), 0x1d306);
a(t.call("\uD834\uDF06def", null), 0x1d306);
a(t.call("\uD834\uDF06def", undefined), 0x1d306);
// Lone high surrogates
a(t.call("\uD834abc", ""), 0xd834);
a(t.call("\uD834abc", "_"), 0xd834);
a(t.call("\uD834abc"), 0xd834);
a(t.call("\uD834abc", -1), undefined);
a(t.call("\uD834abc", -0), 0xd834);
a(t.call("\uD834abc", 0), 0xd834);
a(t.call("\uD834abc", false), 0xd834);
a(t.call("\uD834abc", NaN), 0xd834);
a(t.call("\uD834abc", null), 0xd834);
a(t.call("\uD834abc", undefined), 0xd834);
// Lone low surrogates
a(t.call("\uDF06abc", ""), 0xdf06);
a(t.call("\uDF06abc", "_"), 0xdf06);
a(t.call("\uDF06abc"), 0xdf06);
a(t.call("\uDF06abc", -1), undefined);
a(t.call("\uDF06abc", -0), 0xdf06);
a(t.call("\uDF06abc", 0), 0xdf06);
a(t.call("\uDF06abc", false), 0xdf06);
a(t.call("\uDF06abc", NaN), 0xdf06);
a(t.call("\uDF06abc", null), 0xdf06);
a(t.call("\uDF06abc", undefined), 0xdf06);
a.throws(function () {
t.call(undefined);
}, TypeError);
a.throws(function () {
t.call(undefined, 4);
}, TypeError);
a.throws(function () {
t.call(null);
}, TypeError);
a.throws(function () {
t.call(null, 4);
}, TypeError);
a(t.call(42, 0), 0x34);
a(t.call(42, 1), 0x32);
a(
t.call(
{
toString: function () {
return "abc";
}
},
2
),
0x63
);
a.throws(function () {
t.apply(undefined);
}, TypeError);
a.throws(function () {
t.apply(undefined, [4]);
}, TypeError);
a.throws(function () {
t.apply(null);
}, TypeError);
a.throws(function () {
t.apply(null, [4]);
}, TypeError);
a(t.apply(42, [0]), 0x34);
a(t.apply(42, [1]), 0x32);
a(
t.apply(
{
toString: function () {
return "abc";
}
},
[2]
),
0x63
);
};