regress-355829-02.js (1206B)
1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 //----------------------------------------------------------------------------- 7 var BUGNUMBER = 355829; 8 var summary = 'js_ValueToObject should return the original object if OBJ_DEFAULT_VALUE returns a primitive value'; 9 var actual = ''; 10 var expect = ''; 11 12 13 //----------------------------------------------------------------------------- 14 test(); 15 //----------------------------------------------------------------------------- 16 17 function test() 18 { 19 printBugNumber(BUGNUMBER); 20 printStatus (summary); 21 22 expect = actual = 'Good conversion'; 23 24 var primitiveValues = [ 25 true, false, 0, 1, -2, 0.1, -2e100, 0/0, 1/0, -1/1, "", "xxx", 26 undefined, null 27 ]; 28 29 for (var i = 0; i != primitiveValues.length; ++i) { 30 var v = primitiveValues[i]; 31 var obj = { valueOf: function() { return v; } }; 32 var obj2 = Object(obj); 33 if (obj !== obj2) 34 actual = "Bad conversion for '"+v + "'"; 35 } 36 37 reportCompare(expect, actual, summary); 38 }