1/* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 17// Disable ENABLE_NEXT_OPTIMIZATION cannot run the following tests 18 19{ 20 // chainese and english space with length 9 21 let obj = { a: 1, b: { c: 2 } }; 22 let expected = `{ 23中文-En9+"a": 1, 24中文-En9+"b": { 25中文-En9+中文-En9+"c": 2 26中文-En9+} 27}`; 28 29 let space = "中文-En9+"; 30 assert_equal(JSON.stringify(obj, null, space), expected); 31} 32 33{ 34 // chainese and english space with length 10 35 let obj = { a: 1, b: { c: 2 } }; 36 let expected = `{ 37混合Mixin-12"a": 1, 38混合Mixin-12"b": { 39混合Mixin-12混合Mixin-12"c": 2 40混合Mixin-12} 41}`; 42 let space = "混合Mixin-12"; 43 assert_equal(JSON.stringify(obj, null, space), expected); 44} 45 46{ 47 // chainese and english space with length 11 48 let obj = { a: 1, b: { c: 2 } }; 49 let expected = `{ 50测试Test-567"a": 1, 51测试Test-567"b": { 52测试Test-567测试Test-567"c": 2 53测试Test-567} 54}`; 55 let space = "测试Test-5678"; 56 assert_equal(JSON.stringify(obj, null, space), expected); 57} 58 59{ 60 // chainese characters and space 61 let obj = { a: 1, b: { c: 2 } }; 62 let expected = `{ 63九空格 "a": 1, 64九空格 "b": { 65九空格 九空格 "c": 2 66九空格 } 67}`; 68 let space = "九空格 "; 69 assert_equal(JSON.stringify(obj, null, space), expected); 70} 71 72test_end();