@@ -33,6 +33,7 @@ import {
3333 type InterfaceType ,
3434 type LiteralType ,
3535 type NodeHandle ,
36+ type Program ,
3637 type Project ,
3738 type Signature ,
3839 SignatureKind ,
@@ -303,6 +304,10 @@ function assertOptionalProjectsEquivalent(actual: Project | undefined, expected:
303304 assertOptionalEquivalent ( actual , expected , assertProjectsEquivalent , message ) ;
304305}
305306
307+ function assertProgramsEquivalent ( actual : Program , expected : Program , message ?: string ) : void {
308+ assertProjectsEquivalent ( actual . getProject ( ) , expected . getProject ( ) , message ) ;
309+ }
310+
306311function assertSnapshotsEquivalent ( actual : Snapshot , expected : Snapshot , message ?: string ) : void {
307312 const actualProjects = actual . getProjects ( ) ;
308313 const expectedProjects = expected . getProjects ( ) ;
@@ -723,6 +728,7 @@ describe("API - generator batching", () => {
723728 parityCase ( "API" , "transpileDeclaration" , api . transpileDeclaration , assertDeepEquivalent , "export function declared(value: string): number { return value.length; }" ) ,
724729 parityCase ( "API" , "transpileDeclarationFromFile" , api . transpileDeclarationFromFile , assertDeepEquivalent , "/src/index.ts" ) ,
725730 parityCase ( "API" , "updateSnapshot" , api . updateSnapshot , assertSnapshotsEquivalent , { openProject : "/tsconfig.json" } ) ,
731+ parityCase ( "API" , "createProgram" , api . createProgram , assertProgramsEquivalent , [ "/src/index.ts" ] , { compilerOptions : { noLib : true } } ) ,
726732 parityCase ( "API" , "runWithTemporaryFileUpdate" , api . runWithTemporaryFileUpdate , assertDeepEquivalent , snapshot , "/src/index.ts" , parityFiles [ "/src/index.ts" ] . replace ( "123" , '"fixed"' ) , ( temporarySnapshot : Snapshot ) => {
727733 temporaryProjects . push ( temporarySnapshot . getProjects ( ) [ 0 ] . configFileName ) ;
728734 } ) ,
@@ -906,6 +912,11 @@ describe("API - generator batching", () => {
906912 assert . equal ( disposableSnapshot . isDisposed ( ) , true ) ;
907913 assert . equal ( disposableSnapshot . dispose ( ) , undefined ) ;
908914 exercisedMethods . add ( "Snapshot.dispose" ) ;
915+ const disposableProgram = destructiveAPI . batch ( destructiveAPI . createProgram . gen ( [ "/src/index.ts" ] , { compilerOptions : { noLib : true } } ) ) [ 0 ] ;
916+ destructiveAPI . batch ( disposableProgram . dispose . gen ( ) ) ;
917+ assert . throws ( ( ) => disposableProgram . getSourceFileNames ( ) , / s n a p s h o t .* n o t f o u n d / ) ;
918+ assert . equal ( disposableProgram . dispose ( ) , undefined ) ;
919+ exercisedMethods . add ( "Program.dispose" ) ;
909920 destructiveAPI . batch ( destructiveAPI . close . gen ( ) ) ;
910921 assert . equal ( destructiveAPI . close ( ) , undefined ) ;
911922 exercisedMethods . add ( "API.close" ) ;
0 commit comments