@@ -88,10 +88,25 @@ test('every transport-restricted requirement explains why in note', () => {
8888 expect ( missing ) . toEqual ( [ ] ) ;
8989} ) ;
9090
91- test ( 'every supersedes reference points at an existing requirement id' , ( ) => {
91+ test ( 'supersedes/supersededBy links are symmetric and resolve' , ( ) => {
92+ const bad : string [ ] = [ ] ;
9293 for ( const [ id , req ] of Object . entries ( REQUIREMENTS ) ) {
93- if ( req . supersedes !== undefined ) {
94- expect ( REQUIREMENTS [ req . supersedes ] , `${ id } supersedes unknown id '${ req . supersedes } '` ) . toBeDefined ( ) ;
94+ for ( const oldId of req . supersedes ?? [ ] ) {
95+ const old = REQUIREMENTS [ oldId ] ;
96+ if ( ! old ) bad . push ( `${ id } : supersedes unknown id '${ oldId } '` ) ;
97+ else if ( old . supersededBy !== id )
98+ bad . push ( `${ id } : supersedes '${ oldId } ', but that entry's supersededBy is '${ old . supersededBy } '` ) ;
99+ }
100+ if ( req . supersededBy !== undefined ) {
101+ const successor = REQUIREMENTS [ req . supersededBy ] ;
102+ if ( ! successor ) bad . push ( `${ id } : supersededBy unknown id '${ req . supersededBy } '` ) ;
103+ else if ( ! successor . supersedes ?. includes ( id ) )
104+ bad . push ( `${ id } : supersededBy '${ req . supersededBy } ', but that entry's supersedes array does not include '${ id } '` ) ;
105+ if ( req . removedInSpecVersion === undefined )
106+ bad . push ( `${ id } : has supersededBy but no removedInSpecVersion (only a retired entry can be superseded)` ) ;
95107 }
108+ if ( req . supersedes !== undefined && req . addedInSpecVersion === undefined )
109+ bad . push ( `${ id } : has supersedes but no addedInSpecVersion (a superseding entry is by definition new)` ) ;
96110 }
111+ expect ( bad ) . toEqual ( [ ] ) ;
97112} ) ;
0 commit comments