json-value-object.js (2033B)
1 // |reftest| module 2 // Copyright (C) 2021 the V8 project authors. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 /*--- 5 esid: sec-parse-json-module 6 description: Correctly parses the JSON representation of an ordinary object 7 info: | 8 # 1.4 ParseJSONModule ( source ) 9 10 The abstract operation ParseJSONModule takes a single argument source which 11 is a String representing the contents of a module. 12 13 1. Let json be ? Call(%JSON.parse%, undefined, « source »). 14 2. Return CreateDefaultExportSyntheticModule(json). 15 16 To more fully verify parsing correctness, the source text of the imported 17 module record includes non-printable characters (specifically, all four forms 18 of JSON's so-called "whitespace" token) both before and after the "value." 19 flags: [module] 20 includes: [propertyHelper.js] 21 features: [import-attributes, json-modules] 22 ---*/ 23 24 import value from './json-value-object_FIXTURE.json' with { type: 'json' }; 25 26 assert.sameValue(Object.getPrototypeOf(value), Object.prototype); 27 assert.sameValue(Object.getOwnPropertyNames(value).length, 6); 28 29 verifyProperty(value, 'number', { 30 value: -1.2345, 31 writable: true, 32 enumerable: true, 33 configurable: true 34 }); 35 36 verifyProperty(value, 'boolean', { 37 value: true, 38 writable: true, 39 enumerable: true, 40 configurable: true 41 }); 42 43 verifyProperty(value, 'string', { 44 value: 'a string value', 45 writable: true, 46 enumerable: true, 47 configurable: true 48 }); 49 50 verifyProperty(value, 'null', { 51 value: null, 52 writable: true, 53 enumerable: true, 54 configurable: true 55 }); 56 57 assert.sameValue(Object.getPrototypeOf(value.object), Object.prototype); 58 assert.sameValue(Object.getOwnPropertyNames(value.object).length, 0); 59 60 assert( 61 Array.isArray(value.array), 'the value of the "array" property is an array' 62 ); 63 assert.sameValue( 64 Object.getPrototypeOf(value.array), 65 Array.prototype, 66 'the value of the "array" property is not a subclass of Array' 67 ); 68 assert.sameValue(Object.getOwnPropertyNames(value.array).length, 1); 69 70 reportCompare(0, 0);