@@ -5,7 +5,7 @@ import type { LJDiagnostic } from '../types/diagnostics';
55import type { LiquidJavaTestApi } from '../types/test-api' ;
66
77suite ( 'Bundled LiquidJava extension' , ( ) => {
8- test ( 'activates, becomes ready, and verifies the failing fixture' , async ( ) => {
8+ test ( 'activates, becomes ready, and verifies its isolated fixture' , async ( ) => {
99 const installed = vscode . extensions . getExtension < LiquidJavaTestApi > ( 'AlcidesFonseca.liquid-java' ) ;
1010 assert . ok ( installed , 'LiquidJava must be loaded in the Extension Host' ) ;
1111 assert . equal ( installed . packageJSON . main , './dist/extension.js' ) ;
@@ -16,12 +16,16 @@ suite('Bundled LiquidJava extension', () => {
1616 assert . notEqual ( api . getState ( ) . status , 'stopped' ) ;
1717
1818 const workspace = vscode . workspace . workspaceFolders ?. [ 0 ] ;
19- assert . ok ( workspace , 'the failing fixture must have its own workspace' ) ;
20- const uri = vscode . Uri . joinPath ( workspace . uri , 'src/main/java/FailingRefinement.java' ) ;
19+ assert . ok ( workspace , 'the fixture must have its own workspace' ) ;
20+ const passing = path . basename ( workspace . uri . fsPath ) === 'passing' ;
21+ const file = passing ? 'PassingRefinement.java' : 'FailingRefinement.java' ;
22+ const uri = vscode . Uri . joinPath ( workspace . uri , `src/main/java/${ file } ` ) ;
2123 const subscriptions : vscode . Disposable [ ] = [ ] ;
2224 const nextFixtureDiagnostics = ( ) => new Promise < LJDiagnostic [ ] > ( ( resolve ) => {
2325 const subscription = api . onDiagnostics ( ( diagnostics ) => {
24- if ( diagnostics . some ( d => d . type === 'refinement-error' && path . resolve ( d . file ) === uri . fsPath ) ) {
26+ const matches = passing ? diagnostics . length === 0
27+ : diagnostics . some ( d => d . type === 'refinement-error' && vscode . Uri . file ( path . resolve ( d . file ) ) . fsPath === uri . fsPath ) ;
28+ if ( matches ) {
2529 subscription . dispose ( ) ;
2630 resolve ( diagnostics ) ;
2731 }
@@ -38,12 +42,17 @@ suite('Bundled LiquidJava extension', () => {
3842 const manualDiagnostics = nextFixtureDiagnostics ( ) ;
3943 await vscode . commands . executeCommand ( 'liquidjava.verify' ) ;
4044 const diagnostics = await manualDiagnostics ;
41- const error = diagnostics . find ( d => d . type === 'refinement-error' && path . resolve ( d . file ) === uri . fsPath ) ;
42- assert . ok ( error ) ;
43- assert . equal ( error . category , 'error' ) ;
44- assert . equal ( error . title , 'Refinement Error' ) ;
45- assert . ok ( error . position , 'the diagnostic must identify the invalid assignment' ) ;
46- assert . equal ( api . getState ( ) . status , 'failed' ) ;
45+ if ( passing ) {
46+ assert . deepEqual ( diagnostics , [ ] , 'correct code must emit an explicit empty result' ) ;
47+ assert . equal ( api . getState ( ) . status , 'passed' ) ;
48+ } else {
49+ const error = diagnostics . find ( d => d . type === 'refinement-error' && vscode . Uri . file ( path . resolve ( d . file ) ) . fsPath === uri . fsPath ) ;
50+ assert . ok ( error ) ;
51+ assert . equal ( error . category , 'error' ) ;
52+ assert . equal ( error . title , 'Refinement Error' ) ;
53+ assert . ok ( error . position , 'the diagnostic must identify the invalid assignment' ) ;
54+ assert . equal ( api . getState ( ) . status , 'failed' ) ;
55+ }
4756 assert . deepEqual ( api . getState ( ) . diagnostics , diagnostics ) ;
4857 } finally {
4958 subscriptions . forEach ( subscription => subscription . dispose ( ) ) ;
0 commit comments