js/src/tests/test262/ch09/9.8/S9.8_A5_T1.js

Wed, 31 Dec 2014 07:53:36 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:53:36 +0100
branch
TOR_BUG_3246
changeset 5
4ab42b5ab56c
permissions
-rw-r--r--

Correct small whitespace inconsistency, lost while renaming variables.

michael@0 1 // Copyright 2009 the Sputnik authors. All rights reserved.
michael@0 2 // This code is governed by the BSD license found in the LICENSE file.
michael@0 3
michael@0 4 /**
michael@0 5 * Result of String conversion from Object value is conversion
michael@0 6 * from primitive value
michael@0 7 *
michael@0 8 * @path ch09/9.8/S9.8_A5_T1.js
michael@0 9 * @description Some objects convert to String by explicit transformation
michael@0 10 */
michael@0 11
michael@0 12 // CHECK#1
michael@0 13 if (String(new Number()) !== "0") {
michael@0 14 $ERROR('#1: String(new Number()) === "0". Actual: ' + (String(new Number())));
michael@0 15 }
michael@0 16
michael@0 17 // CHECK#2
michael@0 18 if (String(new Number(0)) !== "0") {
michael@0 19 $ERROR('#2: String(new Number(0)) === "0". Actual: ' + (String(new Number(0))));
michael@0 20 }
michael@0 21
michael@0 22 // CHECK#3
michael@0 23 if (String(new Number(Number.NaN)) !== "NaN") {
michael@0 24 $ERROR('#3: String(new Number(Number.NaN)) === Not-a-Number. Actual: ' + (String(new Number(Number.NaN))));
michael@0 25 }
michael@0 26
michael@0 27 // CHECK#4
michael@0 28 if (String(new Number(null)) !== "0") {
michael@0 29 $ERROR('#4: String(new Number(null)) === "0". Actual: ' + (String(new Number(null))));
michael@0 30 }
michael@0 31
michael@0 32 // CHECK#5
michael@0 33 if (String(new Number(void 0)) !== "NaN") {
michael@0 34 $ERROR('#5: String(new Number(void 0)) === Not-a-Number. Actual: ' + (String(new Number(void 0))));
michael@0 35 }
michael@0 36
michael@0 37 // CHECK#6
michael@0 38 if (String(new Number(true)) !== "1") {
michael@0 39 $ERROR('#6: String(new Number(true)) === "1". Actual: ' + (String(new Number(true))));
michael@0 40 }
michael@0 41
michael@0 42 // CHECK#7
michael@0 43 if (String(new Number(false)) !== "0") {
michael@0 44 $ERROR('#7: String(new Number(false)) === "0". Actual: ' + (String(new Number(false))));
michael@0 45 }
michael@0 46
michael@0 47 // CHECK#8
michael@0 48 if (String(new Boolean(true)) !== "true") {
michael@0 49 $ERROR('#8: String(new Boolean(true)) === "true". Actual: ' + (String(new Boolean(true))));
michael@0 50 }
michael@0 51
michael@0 52 // CHECK#9
michael@0 53 if (String(new Boolean(false)) !== "false") {
michael@0 54 $ERROR('#9: Number(new Boolean(false)) === "false". Actual: ' + (Number(new Boolean(false))));
michael@0 55 }
michael@0 56
michael@0 57 // CHECK#10
michael@0 58 if (String(new Array(2,4,8,16,32)) !== "2,4,8,16,32") {
michael@0 59 $ERROR('#10: String(new Array(2,4,8,16,32)) === "2,4,8,16,32". Actual: ' + (String(new Array(2,4,8,16,32))));
michael@0 60 }
michael@0 61
michael@0 62 // CHECK#11
michael@0 63 var myobj1 = {
michael@0 64 toNumber : function(){return 12345;},
michael@0 65 toString : function(){return 67890;},
michael@0 66 valueOf : function(){return "[object MyObj]";}
michael@0 67 };
michael@0 68
michael@0 69 if (String(myobj1) !== "67890"){
michael@0 70 $ERROR("#11: String(myobj) calls ToPrimitive with hint String");
michael@0 71 }
michael@0 72
michael@0 73 // CHECK#12
michael@0 74 var myobj2 = {
michael@0 75 toNumber : function(){return 12345;},
michael@0 76 toString : function(){return {}},
michael@0 77 valueOf : function(){return "[object MyObj]";}
michael@0 78 };
michael@0 79
michael@0 80 if (String(myobj2) !== "[object MyObj]"){
michael@0 81 $ERROR("#12: String(myobj) calls ToPrimitive with hint String");
michael@0 82 }
michael@0 83
michael@0 84 // CHECK#13
michael@0 85 var myobj3 = {
michael@0 86 toNumber : function(){return 12345;},
michael@0 87 valueOf : function(){return "[object MyObj]";}
michael@0 88 };
michael@0 89
michael@0 90 if (String(myobj3) !== "[object Object]"){
michael@0 91 $ERROR("#13: String(myobj) calls ToPrimitive with hint String");
michael@0 92 }
michael@0 93

mercurial