Debian Codegraph @

js/src/tests/test262/built-ins/JSON/isRawJSON/basic.js

raw
1 // |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) -- json-parse-with-source is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2023 the V8 project authors. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-json.israwjson
7 description: Basic functionality of JSON.isRawJSON()
8 info: |
9 JSON.isRawJSON ( O )
10
11 1. If Type(O) is Object and O has an [[IsRawJSON]] internal slot, return true.
12 2. Return false.
13
14 features: [json-parse-with-source]
15 ---*/
16
17 const values = [1, 1.1, null, false, true, '123'];
18 for (const value of values) {
19 assert(!JSON.isRawJSON(value));
20 assert(JSON.isRawJSON(JSON.rawJSON(value)));
21 }
22 assert(!JSON.isRawJSON(undefined));
23 assert(!JSON.isRawJSON(Symbol('123')));
24 assert(!JSON.isRawJSON([]));
25 assert(!JSON.isRawJSON({}));
26 assert(!JSON.isRawJSON({ rawJSON: '123' }));
27
28 reportCompare(0, 0);