@@ -13,7 +13,7 @@ const before={config:norm(input.config.data),namespaces:input.namespaces.map(x=>
1313assert . equal ( before . defs . length , 33 ) ; assert . equal ( before . defs . reduce ( ( n , d ) => n + d . tests . length , 0 ) , 2 ) ; assert . equal ( before . defs . reduce ( ( n , d ) => n + d . examples . length , 0 ) , 0 ) ;
1414assert . deepEqual ( q ( 'config' ) , before . config ) ; assert . deepEqual ( q ( 'ns' ) . namespaces . map ( n => q ( 'ns' , n ) ) , before . namespaces ) ;
1515for ( const d of before . defs ) assert . deepEqual ( q ( 'def' , d . id ) , d ) ;
16- const expected = structuredClone ( before ) , ops = [ ] , sites = [ ] , counts = { merge :0 , identity :0 , css :0 , dom :0 , watcher :0 , host :0 , schema :0 } ;
16+ const expected = structuredClone ( before ) , ops = [ ] , sites = [ ] , counts = { merge :0 , identity :0 , css :0 , dom :0 , watcher :0 , host :0 , schema :0 , languageTrait : 0 , languageSchema : 0 } ;
1717const show = ( id , path ) => JSON . parse ( run ( 'tree' , 'show' , id , '--path' , '@' + path . join ( '.' ) , '--format' , 'json' ) ) . tree ;
1818const replace = ( id , path , value ) => ops . push ( [ 'tree' , 'replace' , id , '--path' , '@' + path . join ( '.' ) , '--input-format' , 'json-ast' , '--code' , JSON . stringify ( value ) ] ) ;
1919const map = [ '::' , "'Map" , "'Tag" , "'Dynamic" ] , dispatch = [ '::' , "'Fn" , [ '{}' , [ ':rest' , "'Dynamic" ] , [ ':return' , "'Unit" ] , [ ':args' , [ '[]' , "'Dynamic" ] ] ] ] ;
@@ -47,13 +47,16 @@ for(const d of expected.defs)d.code=walk(d.code,[],d.id);
4747const render = expected . defs . find ( d => d . id === 'app.main/render-app!' ) ; assert . equal ( render . schema , null ) ;
4848render . schema = structuredClone ( before . defs . find ( d => d . id === 'app.main/main!' ) . schema ) ;
4949ops . push ( [ 'edit' , 'schema' , render . id , '--input-format' , 'json-ast' , '--code' , JSON . stringify ( [ '::' , "'Fn" , [ '{}' , ...render . schema . slice ( 1 ) . filter ( x => x [ 0 ] !== ':kind' ) ] ] ) ] ) ; counts . schema ++ ;
50- assert . deepEqual ( counts , { merge :6 , identity :1 , css :53 , dom :1 , watcher :2 , host :1 , schema :1 } ) ; assert . equal ( ops . length , 65 ) ;
51- for ( const d of before . defs ) { const e = expected . defs . find ( x => x . id === d . id ) ; for ( const k of Object . keys ( d ) . filter ( k => k !== 'code' && ( d . id !== render . id || k !== 'schema' ) ) ) assert . deepEqual ( e [ k ] , d [ k ] ) ; }
52- for ( const id of [ 'app.schema/Action' , 'app.schema/Store' , 'app.schema/Showcase' , 'app.schema/ToolInfo' , 'app.updater/decode-action' , 'app.updater/updater' , 'app.schema/store' , 'app.main/*reel' , 'app.main/dispatch!' , 'app.main/mount-target' , 'app.main/save-store!' , 'app.comp.showcase/showcases' , 'app.util/highlighter' , 'app.util/register-language!' , 'app.util/inline' , 'app.util/HighlightHost' , 'app.util/HighlightResult' , 'app.util/supported-langs' ] ) assert . deepEqual ( expected . defs . find ( d => d . id === id ) , before . defs . find ( d => d . id === id ) ) ;
50+ const trait = expected . defs . find ( d => d . id === 'app.util/HighlightHost' ) , traitPath = [ 3 , 1 , 2 , 1 , 1 , 3 ] ; assert . equal ( show ( trait . id , traitPath ) , "'JsObject" ) ; assert . equal ( trait . code [ 3 ] [ 0 ] , '.register-language!' ) ; trait . code [ 3 ] [ 1 ] [ 2 ] [ 1 ] [ 1 ] [ 3 ] = "'Fn" ; replace ( trait . id , traitPath , "'Fn" ) ; counts . languageTrait ++ ;
51+ const language = expected . defs . find ( d => d . id === 'app.util/register-language!' ) ; const languageArgs = language . schema . find ( x => Array . isArray ( x ) && x [ 0 ] === ':args' ) [ 1 ] ; assert . deepEqual ( languageArgs , [ '[]' , "'String" , "'JsObject" ] ) ; languageArgs [ 2 ] = "'Fn" ;
52+ ops . push ( [ 'edit' , 'schema' , language . id , '--input-format' , 'json-ast' , '--code' , JSON . stringify ( [ '::' , "'Fn" , [ '{}' , ...language . schema . slice ( 1 ) . filter ( x => x [ 0 ] !== ':kind' ) ] ] ) ] ) ; counts . languageSchema ++ ;
53+ assert . deepEqual ( counts , { merge :6 , identity :1 , css :53 , dom :1 , watcher :2 , host :1 , schema :1 , languageTrait :1 , languageSchema :1 } ) ; assert . equal ( ops . length , 67 ) ;
54+ for ( const d of before . defs ) { const e = expected . defs . find ( x => x . id === d . id ) ; for ( const k of Object . keys ( d ) . filter ( k => k !== 'code' && ( ! [ render . id , language . id ] . includes ( d . id ) || k !== 'schema' ) ) ) assert . deepEqual ( e [ k ] , d [ k ] ) ; }
55+ for ( const id of [ 'app.schema/Action' , 'app.schema/Store' , 'app.schema/Showcase' , 'app.schema/ToolInfo' , 'app.updater/decode-action' , 'app.updater/updater' , 'app.schema/store' , 'app.main/*reel' , 'app.main/dispatch!' , 'app.main/mount-target' , 'app.main/save-store!' , 'app.comp.showcase/showcases' , 'app.util/highlighter' , 'app.util/inline' , 'app.util/HighlightResult' , 'app.util/supported-langs' ] ) assert . deepEqual ( expected . defs . find ( d => d . id === id ) , before . defs . find ( d => d . id === id ) ) ;
5356const main = expected . defs . find ( d => d . id === 'app.main/main!' ) , oldMain = before . defs . find ( d => d . id === main . id ) ; assert . deepEqual ( main . code [ 6 ] , oldMain . code [ 6 ] ) ; assert . equal ( main . code [ 6 ] [ 0 ] , 'match' ) ; assert . equal ( main . code [ 7 ] [ 0 ] , 'render-app!' ) ; assert . deepEqual ( main . code [ 11 ] , oldMain . code [ 11 ] ) ;
5457const reload = expected . defs . find ( d => d . id === 'app.main/reload!' ) , oldReload = before . defs . find ( d => d . id === reload . id ) ; assert . deepEqual ( reload . code [ 3 ] [ 2 ] [ 5 ] , oldReload . code [ 3 ] [ 2 ] [ 5 ] ) ; assert . deepEqual ( reload . code [ 3 ] [ 3 ] , oldReload . code [ 3 ] [ 3 ] ) ;
5558mkdirSync ( 'acceptance' , { recursive :true } ) ; for ( const [ name , value ] of Object . entries ( { before, expected, sites, operations :ops } ) ) writeFileSync ( 'acceptance/' + name + '.json' , JSON . stringify ( value , null , 2 ) ) ;
5659const txn = [ 'edit' , 'transaction' , '--file' , 'acceptance/operations.json' , '--format' , 'json' ] , preview = JSON . parse ( run ( ...txn , '--dry-run' ) ) ; assert . ok ( preview . scoped_revision ) ; writeFileSync ( 'acceptance/preview.json' , JSON . stringify ( preview , null , 2 ) ) ; writeFileSync ( 'acceptance/applied.json' , run ( ...txn , '--expect-revision' , preview . scoped_revision ) ) ;
5760const after = { config :q ( 'config' ) , namespaces :q ( 'ns' ) . namespaces . map ( n => q ( 'ns' , n ) ) , defs :expected . defs . map ( d => q ( 'def' , d . id ) ) } ; assert . deepEqual ( after , expected ) ;
5861writeFileSync ( 'acceptance/after.json' , JSON . stringify ( after , null , 2 ) ) ; writeFileSync ( 'acceptance/snapshot-after-blob.txt' , blob ( ) ) ;
59- writeFileSync ( 'acceptance/summary.json' , JSON . stringify ( { definitions :33 , tests :2 , examples :0 , operations :65 , counts, unsafeBefore :0 , unsafeAfter :0 , preserved :'Allpublicschemasexceptpreviouslymissingrender -app!Unitjsffi;imports /metadata/config/original2tests/Store/Action/decoder/updater/showcasecontents/randompick/highlighter/JSFFItraits /mainmjs/HUD/restorefirst remain. Nohelpers/casts/budgets/tests/frameworks/compiler rules.' } , null , 2 ) ) ;
62+ writeFileSync ( 'acceptance/summary.json' , JSON . stringify ( { definitions :33 , tests :2 , examples :0 , operations :67 , counts, unsafeBefore :0 , unsafeAfter :0 , preserved :'Publicschemasexceptpreviouslymissingrender -app!Unitjsffiandregister-language!languageFnnotfakeJsObject;matchingHighlightHostparameterFn. Imports /metadata/config/original2tests/Store/Action/decoder/updater/showcasecontents/randompick/highlighter/mainmjs/HUD/restorefirst remain. Nohelpers/casts/budgets/tests/frameworks/compiler rules.' } , null , 2 ) ) ;
0 commit comments