Skip to content

Commit d1dc8e1

Browse files
committed
Update tests
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
1 parent c19d6ed commit d1dc8e1

File tree

4 files changed

+16
-38
lines changed

4 files changed

+16
-38
lines changed

src/analysis/java/JavaAnalysis.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,7 @@ export class JavaAnalysis {
145145
}
146146

147147
public async getSymbolTable(): Promise<Record<string, JCompilationUnitType>> {
148-
if (!this.application) {
149-
this.application = await this._initialize_application();
150-
}
151-
return this.application.symbol_table;
148+
return (await this.getApplication()).symbol_table;
152149
}
153150
}
154151

test/conftest.test.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

test/conftest.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ import * as path from 'path';
2323
import * as https from 'https';
2424
import extract from 'extract-zip';
2525
import {beforeAll, afterAll } from "bun:test";
26-
26+
import { CLDK } from "../src/CLDK";
2727

2828
/*
2929
* Set up sample applications for testing
3030
* This is a one-time setup. Daytrader 8 will be downloaded and extracted
3131
*/
32-
33-
export let dayTraderApp: string;
32+
let dayTraderApp: string;
33+
export let daytraderJavaAnalysis: JavaAnalysis;
3434

3535
beforeAll(async () => {
3636
const javaSampleAppsDir = path.join(__dirname, "test-applications", "java");
@@ -47,6 +47,14 @@ beforeAll(async () => {
4747
*/
4848
// Set the dayTraderApp variable to the extracted directory
4949
dayTraderApp = extractedDir;
50+
51+
/**
52+
* Let's also create the JavaAnalysis instance here for testing purposes.
53+
*/
54+
daytraderJavaAnalysis = CLDK.for("java").analysis({
55+
projectPath: extractedDir,
56+
analysisLevel: "symbol table",
57+
})
5058
})
5159

5260
/**
Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
1-
import { CLDK } from "../../../../src/";
2-
import {dayTraderApp} from "../../../conftest";
1+
import {daytraderJavaAnalysis} from "../../../conftest";
32
import {expect, test } from "bun:test";
43

54
test("Must get analysis object from JavaAnalysis object", () => {
6-
const analysis = CLDK.for("java").analysis({
7-
projectPath: dayTraderApp,
8-
analysisLevel: "Symbol Table",
9-
});
10-
expect(analysis).toBeDefined();
5+
expect(daytraderJavaAnalysis).toBeDefined();
116
});
127

138
test("Must get JApplication instance", async () => {
14-
const analysis = CLDK.for("java").analysis({
15-
projectPath: dayTraderApp,
16-
analysisLevel: "Symbol Table",
17-
});
18-
const jApplication = await analysis.getApplication();
9+
const jApplication = await daytraderJavaAnalysis.getApplication();
1910
expect(jApplication).toBeDefined();
2011
});
2112

2213
test("Must get Symbol Table", async () => {
23-
const analysis = CLDK.for("java").analysis({
24-
projectPath: dayTraderApp,
25-
analysisLevel: "Symbol Table",
26-
});
27-
const symbolTable = await analysis.getSymbolTable();
14+
const symbolTable = await daytraderJavaAnalysis.getSymbolTable();
2815
expect(symbolTable).toBeDefined();
2916
});

0 commit comments

Comments
 (0)