1// Copyright JS Foundation and other contributors, http://js.foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// Tests with valid inputs
16assert(String.fromCodePoint(42) === "*")
17assert(String.fromCodePoint(65, 90) === "AZ");
18assert(String.fromCodePoint(0x404) === "Є");
19assert(String.fromCodePoint(194564) === "�");
20assert(String.fromCodePoint(0x1D306, 0x61, 0x1D307) === "�a�");
21assert(String.fromCodePoint(0x1F303) === "�");
22
23// Tests with invalid inputs
24try {
25    assert(String.fromCodePoint('_'));
26    assert(false);
27} catch (e) {
28    assert(e instanceof RangeError);
29}
30
31try {
32    assert(String.fromCodePoint(Infinity));
33    assert(false);
34} catch (e) {
35    assert(e instanceof RangeError);
36}
37
38try {
39    assert(String.fromCodePoint(-1));
40    assert(false);
41} catch (e) {
42    assert(e instanceof RangeError);
43}
44
45try {
46    assert(String.fromCodePoint(3.14));
47    assert(false);
48} catch (e) {
49    assert(e instanceof RangeError);
50}
51
52try {
53    assert(String.fromCodePoint(3e-2));
54    assert(false);
55} catch (e) {
56    assert(e instanceof RangeError);
57}
58
59try {
60    assert(String.fromCodePoint(NaN));
61    assert(false);
62} catch (e) {
63    assert(e instanceof RangeError);
64}
65