-
Notifications
You must be signed in to change notification settings - Fork 291
Expand file tree
/
Copy pathTestLambda.test.ts
More file actions
31 lines (28 loc) · 963 Bytes
/
TestLambda.test.ts
File metadata and controls
31 lines (28 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { beforeAll, describe, expect, test } from "vitest";
import { expectJavaError, getJava } from "../testHelpers";
import { Java } from "../java";
describe("Java8", () => {
let java!: Java;
beforeAll(async () => {
java = await getJava();
});
test("call methods of a class that uses lambda expressions", () => {
try {
const TestLambda = java.import("TestLambda");
const lambda = new TestLambda();
const sum = lambda.testLambdaAdditionSync(23, 42);
expect(sum).toBe(65);
const diff = lambda.testLambdaSubtractionSync(23, 42);
expect(diff).toBe(-19);
} catch (err) {
expectJavaError(err);
const unsupportedVersion = java.instanceOf(err.cause, "java.lang.UnsupportedClassVersionError");
if (unsupportedVersion) {
console.log("JRE 1.8 not available");
} else {
console.error("Java8 test failed with unknown error:", err);
throw err;
}
}
});
});