to-number-conversions.js (1245B)
1 // Copyright (C) 2015 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 es6id: 21.1.2.2 5 description: > 6 Returns the String value with the code unit for the given coerced types. 7 info: | 8 String.fromCodePoint ( ...codePoints ) 9 10 1. Let result be the empty String. 11 2. For each element next of codePoints, do 12 a. Let nextCP be ? ToNumber(next). 13 b. If nextCP is not an integral Number, throw a RangeError exception. 14 c. If ℝ(nextCP) < 0 or ℝ(nextCP) > 0x10FFFF, throw a RangeError exception. 15 d. Set result to the string-concatenation of result and UTF16EncodeCodePoint(ℝ(nextCP)). 16 3. Assert: If codePoints is empty, then result is the empty String. 17 4. Return result. 18 19 Ref: 7.1.3 ToNumber ( argument ) 20 features: [String.fromCodePoint] 21 ---*/ 22 23 assert.sameValue(String.fromCodePoint(null), '\x00'); 24 assert.sameValue(String.fromCodePoint(false), '\x00'); 25 assert.sameValue(String.fromCodePoint(true), '\x01'); 26 assert.sameValue(String.fromCodePoint('42'), '\x2A'); 27 assert.sameValue(String.fromCodePoint('042'), '\x2A'); 28 assert.sameValue( 29 String.fromCodePoint({ 30 valueOf: function() { 31 return 31; 32 } 33 }), 34 '\x1F' 35 ); 36 37 reportCompare(0, 0);