space-number-float.js (813B)
1 // Copyright (C) 2012 Ecma International. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-json.stringify 5 description: > 6 Numeric space parameter is truncated to integer part. 7 info: | 8 JSON.stringify ( value [ , replacer [ , space ] ] ) 9 10 [...] 11 6. If Type(space) is Number, then 12 a. Set space to min(10, ! ToInteger(space)). 13 ---*/ 14 15 var obj = { 16 a1: { 17 b1: [1, 2, 3, 4], 18 b2: { 19 c1: 1, 20 c2: 2, 21 }, 22 }, 23 a2: 'a2', 24 }; 25 26 assert.sameValue( 27 JSON.stringify(obj, null, -1.99999), 28 JSON.stringify(obj, null, -1) 29 ); 30 31 assert.sameValue( 32 JSON.stringify(obj, null, new Number(5.11111)), 33 JSON.stringify(obj, null, 5) 34 ); 35 36 assert.sameValue( 37 JSON.stringify(obj, null, 6.99999), 38 JSON.stringify(obj, null, 6) 39 ); 40 41 reportCompare(0, 0);