Skip to content

Commit

Permalink
Update String.fromCodePoint info to align with latest ECMAScript spec
Browse files Browse the repository at this point in the history
  • Loading branch information
yossydev authored and ptomato committed Feb 12, 2025
1 parent b0319e4 commit c23db80
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 63 deletions.
14 changes: 6 additions & 8 deletions test/built-ins/String/fromCodePoint/argument-is-Symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ description: >
info: |
String.fromCodePoint ( ...codePoints )
1. Let codePoints be a List containing the arguments passed to this function.
2. Let length be the number of elements in codePoints.
3. Let elements be a new List.
4. Let nextIndex be 0.
5. Repeat while nextIndex < length
a. Let next be codePoints[nextIndex].
b. Let nextCP be ToNumber(next).
c. ReturnIfAbrupt(nextCP).
1. Let result be the empty String.
2. For each element next of codePoints, do
a. Let nextCP be ? ToNumber(next).
b. If nextCP is not an integral Number, throw a RangeError exception.
c. If ℝ(nextCP) < 0 or ℝ(nextCP) > 0x10FFFF, throw a RangeError exception.
...
features: [Symbol, String.fromCodePoint]
---*/

Expand Down
14 changes: 4 additions & 10 deletions test/built-ins/String/fromCodePoint/argument-is-not-integer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@ description: >
info: |
String.fromCodePoint ( ...codePoints )
1. Let codePoints be a List containing the arguments passed to this function.
2. Let length be the number of elements in codePoints.
3. Let elements be a new List.
4. Let nextIndex be 0.
5. Repeat while nextIndex < length
a. Let next be codePoints[nextIndex].
b. Let nextCP be ToNumber(next).
c. ReturnIfAbrupt(nextCP).
d. If SameValue(nextCP, ToInteger(nextCP)) is false, throw a RangeError
exception.
1. Let result be the empty String.
2. For each element next of codePoints, do
a. Let nextCP be ? ToNumber(next).
b. If nextCP is not an integral Number, throw a RangeError exception.
...
features: [String.fromCodePoint]
---*/
Expand Down
16 changes: 8 additions & 8 deletions test/built-ins/String/fromCodePoint/argument-not-coercible.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ description: >
info: |
String.fromCodePoint ( ...codePoints )
1. Let codePoints be a List containing the arguments passed to this function.
2. Let length be the number of elements in codePoints.
3. Let elements be a new List.
4. Let nextIndex be 0.
5. Repeat while nextIndex < length
a. Let next be codePoints[nextIndex].
b. Let nextCP be ToNumber(next).
c. ReturnIfAbrupt(nextCP).
1. Let result be the empty String.
2. For each element next of codePoints, do
a. Let nextCP be ? ToNumber(next).
b. If nextCP is not an integral Number, throw a RangeError exception.
c. If ℝ(nextCP) < 0 or ℝ(nextCP) > 0x10FFFF, throw a RangeError exception.
d. Set result to the string-concatenation of result and UTF16EncodeCodePoint(ℝ(nextCP)).
3. Assert: If codePoints is empty, then result is the empty String.
4. Return result.
features: [String.fromCodePoint]
---*/

Expand Down
13 changes: 4 additions & 9 deletions test/built-ins/String/fromCodePoint/arguments-is-empty.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@ description: >
info: |
String.fromCodePoint ( ...codePoints )
1. Let codePoints be a List containing the arguments passed to this function.
...
5. Repeat while nextIndex < length
1. Let result be the empty String.
2. For each element next of codePoints, do
...
f. Append the elements of the UTF16Encoding (10.1.1) of nextCP to the end of
elements.
g. Let nextIndex be nextIndex + 1.
6. Return the String value whose elements are, in order, the elements in the
List elements. If length is 0, the empty string is returned.
3. Assert: If codePoints is empty, then result is the empty String.
4. Return result.
features: [String.fromCodePoint]
---*/

Expand Down
16 changes: 5 additions & 11 deletions test/built-ins/String/fromCodePoint/number-is-out-of-range.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,11 @@ description: >
info: |
String.fromCodePoint ( ...codePoints )
1. Let codePoints be a List containing the arguments passed to this function.
2. Let length be the number of elements in codePoints.
3. Let elements be a new List.
4. Let nextIndex be 0.
5. Repeat while nextIndex < length
a. Let next be codePoints[nextIndex].
b. Let nextCP be ToNumber(next).
c. ReturnIfAbrupt(nextCP).
d. If SameValue(nextCP, ToInteger(nextCP)) is false, throw a RangeError
exception.
e. If nextCP < 0 or nextCP > 0x10FFFF, throw a RangeError exception.
1. Let result be the empty String.
2. For each element next of codePoints, do
a. Let nextCP be ? ToNumber(next).
b. If nextCP is not an integral Number, throw a RangeError exception.
c. If ℝ(nextCP) < 0 or ℝ(nextCP) > 0x10FFFF, throw a RangeError exception.
...
features: [String.fromCodePoint]
---*/
Expand Down
12 changes: 4 additions & 8 deletions test/built-ins/String/fromCodePoint/return-string-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ description: >
info: |
String.fromCodePoint ( ...codePoints )
1. Let codePoints be a List containing the arguments passed to this function.
...
5. Repeat while nextIndex < length
1. Let result be the empty String.
2. For each element next of codePoints, do
...
f. Append the elements of the UTF16Encoding (10.1.1) of nextCP to the end of
elements.
g. Let nextIndex be nextIndex + 1.
6. Return the String value whose elements are, in order, the elements in the
List elements. If length is 0, the empty string is returned.
3. Assert: If codePoints is empty, then result is the empty String.
4. Return result.
features: [String.fromCodePoint]
---*/

Expand Down
18 changes: 9 additions & 9 deletions test/built-ins/String/fromCodePoint/to-number-conversions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ description: >
info: |
String.fromCodePoint ( ...codePoints )
1. Let codePoints be a List containing the arguments passed to this function.
...
5. Repeat while nextIndex < length
a. Let next be codePoints[nextIndex].
b. Let nextCP be ToNumber(next).
...
6. Return the String value whose elements are, in order, the elements in the
List elements. If length is 0, the empty string is returned.
1. Let result be the empty String.
2. For each element next of codePoints, do
a. Let nextCP be ? ToNumber(next).
b. If nextCP is not an integral Number, throw a RangeError exception.
c. If ℝ(nextCP) < 0 or ℝ(nextCP) > 0x10FFFF, throw a RangeError exception.
d. Set result to the string-concatenation of result and UTF16EncodeCodePoint(ℝ(nextCP)).
3. Assert: If codePoints is empty, then result is the empty String.
4. Return result.
Ref: 7.1.3 ToNumber ( argument )
features: [String.fromCodePoint]
---*/
Expand Down

0 comments on commit c23db80

Please sign in to comment.