From ac313061bd46d87a0a2e5a9c000af4e2ac96bf22 Mon Sep 17 00:00:00 2001 From: kjw142857 Date: Wed, 11 Mar 2026 11:17:11 +0800 Subject: [PATCH 1/6] Include current and planned features in README --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 4ec8997..a7d5229 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ Open-source Implementation of the Java language in TypeScript. ( Date: Wed, 18 Mar 2026 07:37:06 +0800 Subject: [PATCH 2/6] Update compiler README --- eslint.config.mjs | 7 +++++ src/compiler/__tests__/index.ts | 15 +++-------- .../__tests__/tests/typeConversion.test.ts | 27 +++++++++++++++++++ 3 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 eslint.config.mjs create mode 100644 src/compiler/__tests__/tests/typeConversion.test.ts diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..17f865b --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,7 @@ +import markdown from "@eslint/markdown"; +import { defineConfig } from "eslint/config"; + +export default defineConfig([ + { ignores: ["**/*.js", "**/*.cjs", "**/*.mjs"] }, + { files: ["**/*.md"], plugins: { markdown }, language: "markdown/gfm" }, +]); diff --git a/src/compiler/__tests__/index.ts b/src/compiler/__tests__/index.ts index 8f31ef5..a4cec45 100644 --- a/src/compiler/__tests__/index.ts +++ b/src/compiler/__tests__/index.ts @@ -1,3 +1,4 @@ +/* import { printlnTest } from "./tests/println.test"; import { variableDeclarationTest } from "./tests/variableDeclaration.test"; import { arithmeticExpressionTest } from "./tests/arithmeticExpression.test"; @@ -9,17 +10,9 @@ import { methodInvocationTest } from "./tests/methodInvocation.test"; import { importTest } from "./tests/import.test"; import { arrayTest } from "./tests/array.test"; import { classTest } from "./tests/class.test"; +*/ +import { typeConversionTest } from "./tests/typeConversion.test"; describe("compiler tests", () => { - printlnTest(); - variableDeclarationTest(); - arithmeticExpressionTest(); - unaryExpressionTest(); - ifElseTest(); - whileTest(); - forTest(); - methodInvocationTest(); - importTest(); - arrayTest(); - classTest(); + typeConversionTest(); }) \ No newline at end of file diff --git a/src/compiler/__tests__/tests/typeConversion.test.ts b/src/compiler/__tests__/tests/typeConversion.test.ts new file mode 100644 index 0000000..d69c7a0 --- /dev/null +++ b/src/compiler/__tests__/tests/typeConversion.test.ts @@ -0,0 +1,27 @@ +import { + runTest, + testCase, +} from "../__utils__/test-utils"; + +const testCases: testCase[] = [ + { + comment: "int to float widening type", + program: ` + public class Main { + public static void main(String[] args) { + int x = 1; + float y = x; + System.out.println(y); + } + } + `, + expectedLines: ["1.0"], + } +]; + +export const typeConversionTest = () => describe("type conversion", () => { + for (let testCase of testCases) { + const { comment: comment, program: program, expectedLines: expectedLines } = testCase; + it(comment, () => runTest(program, expectedLines)); + } +}); From 5947148310bb4352d34b12adeb59a4fef18ea087 Mon Sep 17 00:00:00 2001 From: kjw142857 <122250318+kjw142857@users.noreply.github.com> Date: Wed, 18 Mar 2026 07:44:05 +0800 Subject: [PATCH 3/6] Delete src/compiler/__tests__/tests/typeConversion.test.ts --- .../__tests__/tests/typeConversion.test.ts | 27 ------------------- 1 file changed, 27 deletions(-) delete mode 100644 src/compiler/__tests__/tests/typeConversion.test.ts diff --git a/src/compiler/__tests__/tests/typeConversion.test.ts b/src/compiler/__tests__/tests/typeConversion.test.ts deleted file mode 100644 index d69c7a0..0000000 --- a/src/compiler/__tests__/tests/typeConversion.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { - runTest, - testCase, -} from "../__utils__/test-utils"; - -const testCases: testCase[] = [ - { - comment: "int to float widening type", - program: ` - public class Main { - public static void main(String[] args) { - int x = 1; - float y = x; - System.out.println(y); - } - } - `, - expectedLines: ["1.0"], - } -]; - -export const typeConversionTest = () => describe("type conversion", () => { - for (let testCase of testCases) { - const { comment: comment, program: program, expectedLines: expectedLines } = testCase; - it(comment, () => runTest(program, expectedLines)); - } -}); From d560925888bd611e3df3823b80358086bc3d9203 Mon Sep 17 00:00:00 2001 From: kjw142857 <122250318+kjw142857@users.noreply.github.com> Date: Wed, 18 Mar 2026 07:44:38 +0800 Subject: [PATCH 4/6] Delete eslint.config.mjs --- eslint.config.mjs | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 eslint.config.mjs diff --git a/eslint.config.mjs b/eslint.config.mjs deleted file mode 100644 index 17f865b..0000000 --- a/eslint.config.mjs +++ /dev/null @@ -1,7 +0,0 @@ -import markdown from "@eslint/markdown"; -import { defineConfig } from "eslint/config"; - -export default defineConfig([ - { ignores: ["**/*.js", "**/*.cjs", "**/*.mjs"] }, - { files: ["**/*.md"], plugins: { markdown }, language: "markdown/gfm" }, -]); From 65b51ef537b82830e125dc6f64dea75cd71ff27b Mon Sep 17 00:00:00 2001 From: kjw142857 <122250318+kjw142857@users.noreply.github.com> Date: Wed, 18 Mar 2026 07:45:35 +0800 Subject: [PATCH 5/6] Add files via upload --- src/compiler/__tests__/index.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/compiler/__tests__/index.ts b/src/compiler/__tests__/index.ts index a4cec45..8f31ef5 100644 --- a/src/compiler/__tests__/index.ts +++ b/src/compiler/__tests__/index.ts @@ -1,4 +1,3 @@ -/* import { printlnTest } from "./tests/println.test"; import { variableDeclarationTest } from "./tests/variableDeclaration.test"; import { arithmeticExpressionTest } from "./tests/arithmeticExpression.test"; @@ -10,9 +9,17 @@ import { methodInvocationTest } from "./tests/methodInvocation.test"; import { importTest } from "./tests/import.test"; import { arrayTest } from "./tests/array.test"; import { classTest } from "./tests/class.test"; -*/ -import { typeConversionTest } from "./tests/typeConversion.test"; describe("compiler tests", () => { - typeConversionTest(); + printlnTest(); + variableDeclarationTest(); + arithmeticExpressionTest(); + unaryExpressionTest(); + ifElseTest(); + whileTest(); + forTest(); + methodInvocationTest(); + importTest(); + arrayTest(); + classTest(); }) \ No newline at end of file From 668d673dbcca062bf7246fec07d0fe7afc680812 Mon Sep 17 00:00:00 2001 From: kjw142857 <122250318+kjw142857@users.noreply.github.com> Date: Wed, 18 Mar 2026 07:49:16 +0800 Subject: [PATCH 6/6] Add files via upload --- src/compiler/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/compiler/README.md b/src/compiler/README.md index a184cd4..c182555 100644 --- a/src/compiler/README.md +++ b/src/compiler/README.md @@ -1,5 +1,7 @@ This is a bookkeeping of the planned scope of the compiler. It will be updated from time to time to reflect the current status of the compiler and to make the scope clearer. For a more formal treatment of what features are being supported, see scope.txt for a BNF-form of the Java sub-language. +Note that the compiler is separate from the Java Playground in Source Academy, which runs in tandem with the ECE. As such, any program run in the Playground will follow the features implemented in the ECE (e.g. widening type conversions), rather than the features below. + **Features that are already supported** - Single source file, single public class, with exactly one main method @@ -30,3 +32,8 @@ This is a bookkeeping of the planned scope of the compiler. It will be updated f - Generics - Type casting +**Testing** +Unit tests are located in the "__tests__/tests" folder. The main testing file is "__tests__/index.ts", in which the tests to be run can be specified. To run, navigate to the main java-slang folder and run: +```bash +$ yarn test src/compiler/__tests__/index.ts +``` \ No newline at end of file