S9.9_A5.js (2109B)
1 // Copyright 2009 the Sputnik authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 info: | 6 ToObject conversion from String: create a new String object 7 whose [[value]] property is set to the value of the string 8 es5id: 9.9_A5 9 description: Converting from various strings to Object 10 ---*/ 11 assert.sameValue( 12 Object("some string").valueOf(), 13 "some string", 14 'Object("some string").valueOf() must return "some string"' 15 ); 16 17 assert.sameValue( 18 typeof Object("some string"), 19 "object", 20 'The value of `typeof Object("some string")` is expected to be "object"' 21 ); 22 23 assert.sameValue( 24 Object("some string").constructor.prototype, 25 String.prototype, 26 'The value of Object("some string").constructor.prototype is expected to equal the value of String.prototype' 27 ); 28 29 assert.sameValue(Object("").valueOf(), "", 'Object("").valueOf() must return ""'); 30 assert.sameValue(typeof Object(""), "object", 'The value of `typeof Object("")` is expected to be "object"'); 31 32 assert.sameValue( 33 Object("").constructor.prototype, 34 String.prototype, 35 'The value of Object("").constructor.prototype is expected to equal the value of String.prototype' 36 ); 37 38 assert.sameValue(Object("\r\t\b\n\v\f").valueOf(), "\r\t\b\n\v\f", 'Object("rtbnvf").valueOf() must return "rtbnvf"'); 39 40 assert.sameValue( 41 typeof Object("\r\t\b\n\v\f"), 42 "object", 43 'The value of `typeof Object("rtbnvf")` is expected to be "object"' 44 ); 45 46 assert.sameValue( 47 Object("\r\t\b\n\v\f").constructor.prototype, 48 String.prototype, 49 'The value of Object("rtbnvf").constructor.prototype is expected to equal the value of String.prototype' 50 ); 51 52 assert.sameValue(Object(String(10)).valueOf(), "10", 'Object(String(10)).valueOf() must return "10"'); 53 54 assert.sameValue( 55 typeof Object(String(10)), 56 "object", 57 'The value of `typeof Object(String(10))` is expected to be "object"' 58 ); 59 60 assert.sameValue( 61 Object(String(10)).constructor.prototype, 62 String.prototype, 63 'The value of Object(String(10)).constructor.prototype is expected to equal the value of String.prototype' 64 ); 65 66 reportCompare(0, 0);