7788 * -----
99 * @Last modified by: Nate Corcoran <CLDMV> ([email protected] ) 10- * @Last modified time: 2026-10-12T03:43:25 -07:00 (1791801805 )
10+ * @Last modified time: 2026-10-12T13:27:35 -07:00 (1791836855 )
1111 * -----
1212 * @Copyright : Copyright (c) 2013-2026 Catalyzed Motivation Inc. All rights reserved.
1313 *
1919 * The shape is printed as JSON, which writes `NaN` and both infinities as `null` and `-0` as `0`, so two
2020 * apis differing only in those values would compare equal. Fixture `api_test_special_numbers` exports
2121 * each of them beside a real `0` and `null`. An array's `length` is part of its shape too: `arrays.mjs`
22- * exports two arrays with the same enumerable elements, one with a trailing hole.
22+ * exports two arrays with the same enumerable elements, one with a trailing hole. `nested.mjs` exports a
23+ * member deeper than the display depth, which the shape still compares, and `_hidden()`, which the
24+ * callable paths list.
2325 * @module tests/vitests/suites/api-structures/inspect-api-shape-numbers
2426 */
2527
@@ -33,17 +35,26 @@ const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../.
3335/**
3436 * Run the inspection tool on the fixture and read the api shape it prints.
3537 * @param {"--eager"|"--lazy" } modeFlag - Mode flag.
36- * @returns {object } The api root's members.
38+ * @returns {{stdout: string, members: object}} The tool's output and the api root's members.
3739 */
38- function shapeOf ( modeFlag ) {
40+ function runTool ( modeFlag ) {
3941 const result = spawnSync ( "node" , [ path . join ( ROOT , "tools" , "dev" , "inspect-api-structure.mjs" ) , "api_test_special_numbers" , modeFlag ] , {
4042 cwd : ROOT ,
4143 encoding : "utf8" ,
4244 env : { ...process . env , NODE_ENV : "development" , NODE_OPTIONS : "--conditions=slothlet-dev" }
4345 } ) ;
4446 const line = result . stdout . split ( "\n" ) . find ( ( entry ) => entry . startsWith ( "API Shape: " ) ) ;
4547 expect ( line , result . stderr ) . toBeDefined ( ) ;
46- return JSON . parse ( line . slice ( "API Shape: " . length ) ) . members ;
48+ return { stdout : result . stdout , members : JSON . parse ( line . slice ( "API Shape: " . length ) ) . members } ;
49+ }
50+
51+ /**
52+ * Read the api shape the inspection tool prints for the fixture.
53+ * @param {"--eager"|"--lazy" } modeFlag - Mode flag.
54+ * @returns {object } The api root's members.
55+ */
56+ function shapeOf ( modeFlag ) {
57+ return runTool ( modeFlag ) . members ;
4758}
4859
4960describe . each ( [ "--eager" , "--lazy" ] ) ( "inspect-api-structure shape numbers (%s)" , ( modeFlag ) => {
@@ -61,4 +72,14 @@ describe.each(["--eager", "--lazy"])("inspect-api-structure shape numbers (%s)",
6172 expect ( arrays . holey . length ) . toBe ( 2 ) ;
6273 expect ( arrays . short . length ) . toBe ( 1 ) ;
6374 } ) ;
75+
76+ it ( "compares the whole shape, below the display depth too" , ( ) => {
77+ let node = shapeOf ( modeFlag ) . nested . members . tree ;
78+ for ( const key of [ "a" , "b" , "c" , "d" , "e" , "f" , "g" , "h" , "i" , "j" , "leaf" ] ) node = node . members [ key ] ;
79+ expect ( node ) . toEqual ( { type : "number" , value : 1 } ) ;
80+ } ) ;
81+
82+ it ( "lists an underscore-prefixed function among the callable paths" , ( ) => {
83+ expect ( runTool ( modeFlag ) . stdout ) . toContain ( "api.nested._hidden()" ) ;
84+ } ) ;
6485} ) ;
0 commit comments