Skip to content

Commit

Permalink
Using CommonJS for tests, because only that allows to use decorators.
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Lischke <mike@lischke-online.de>
  • Loading branch information
mike-lischke committed Dec 26, 2023
1 parent d698dc7 commit fb1d479
Show file tree
Hide file tree
Showing 328 changed files with 2,623 additions and 2,498 deletions.
9 changes: 7 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"plugin:jsdoc/recommended"
],
"ignorePatterns": [
"**/generated/*"
"**/generated/*",
"jest.config.ts"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
Expand Down Expand Up @@ -616,13 +617,17 @@
],
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/no-duplicate-type-constituents": "off",
"@typescript-eslint/no-unsafe-declaration-merging": "off",
"@typescript-eslint/no-base-to-string": "off",
"jsdoc/check-alignment": "error",
"jsdoc/check-indentation": "off",
"jsdoc/require-param-type": "off",
"jsdoc/require-returns-type": "off",
"jsdoc/tag-lines": [
// Have to switch this off, as it is not good enough to be used.
"off"
]
],
"jsdoc/no-undefined-types": "off"
}
}
6 changes: 4 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
"type": "node",
"request": "launch",
"name": "Run current Jest test",
"runtimeExecutable": null,
"runtimeExecutable": "node",
"runtimeArgs": [
"--experimental-vm-modules",
"--no-warnings",
"${workspaceRoot}/node_modules/.bin/jest",
"${fileBasenameNoExtension}.ts",
"${file}",
"--no-coverage",
"--runInBand"
],
Expand Down
11 changes: 11 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,22 @@
"testng",
"typeof",
"unmappable",
"unmocked",
"uxxxx",
"xdescribe",
"ᬠᬣᬦᬪᬫᬬᬭ"
],
"ignorePaths": [
".eslintrc.json"
],
"dictionaries": [
"custom-dictionary"
],
"dictionaryDefinitions": [
{
"name": "custom-dictionary",
"path": "./.cspell/custom-dictionary.txt",
"addWords": true
}
]
}
9 changes: 8 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@ const config: Config = {
"node",
],

//extensionsToTreatAsEsm: [".ts"],

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources
// with a single module
moduleNameMapper: {
"(.+)\\.js": "$1",
},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module
Expand Down Expand Up @@ -204,7 +207,11 @@ const config: Config = {
testTimeout: 30000,

// A map from regular expressions to paths to transformers
// transform: {},
transform: {
"^.+\\.ts$": ["ts-jest", {
tsconfig: "./tests/tsconfig.json",
}],
},

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip
// transformation
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"Java Runtime Environment"
],
"main": "./lib",
"type": "module",
"author": "Mike Lischke",
"license": "MIT",
"dependencies": {
Expand Down
8 changes: 4 additions & 4 deletions src/DefaultJavaEqualityComparator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { isEquatable } from "./type-guards";
import { Arrays } from "./java/util/Arrays";
import { JavaEqualityComparator } from "./JavaEqualityComparator";
import { isEquatable } from "./type-guards.js";
import { Arrays } from "./java/util/Arrays.js";
import { JavaEqualityComparator } from "./JavaEqualityComparator.js";

import { MurmurHash } from "./MurmurHash";
import { MurmurHash } from "./MurmurHash.js";

/**
* A class implementing Java's comparison semantics, which are based on object equality, that is, equality based on
Expand Down
8 changes: 4 additions & 4 deletions src/IteratorWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { JavaObject } from "./java/lang/Object";
import { UnsupportedOperationException } from "./java/lang/UnsupportedOperationException";
import { JavaIterator } from "./java/util/Iterator";
import { Consumer } from "./java/util/function";
import { JavaObject } from "./java/lang/Object.js";
import { UnsupportedOperationException } from "./java/lang/UnsupportedOperationException.js";
import { JavaIterator } from "./java/util/Iterator.js";
import { Consumer } from "./java/util/function/index.js";

/** A JRE iterator which wraps a Typescript iterator. */
export class IteratorWrapper<T> extends JavaObject implements JavaIterator<T> {
Expand Down
12 changes: 6 additions & 6 deletions src/JavaMapEntryIterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { JavaObject } from "./java/lang/Object";
import { UnsupportedOperationException } from "./java/lang/UnsupportedOperationException";
import { HashMapEntry } from "./java/util/HashMapEntry";
import { JavaIterator } from "./java/util/Iterator";
import { JavaMap } from "./java/util/Map";
import { Consumer } from "./java/util/function";
import { JavaObject } from "./java/lang/Object.js";
import { UnsupportedOperationException } from "./java/lang/UnsupportedOperationException.js";
import { HashMapEntry } from "./java/util/HashMapEntry.js";
import { JavaIterator } from "./java/util/Iterator.js";
import { JavaMap } from "./java/util/Map.js";
import { Consumer } from "./java/util/function/Consumer.js";

/** A specialized JRE iterator for Map entries, which wraps a Typescript iterator. */
export class JavaMapEntryIterator<K, V> extends JavaObject implements JavaIterator<JavaMap.Entry<K, V>> {
Expand Down
2 changes: 1 addition & 1 deletion src/MurmurHash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { isEquatable } from "./type-guards";
import { isEquatable } from "./type-guards.js";

/**
* @author Sam Harwell
Expand Down
2 changes: 1 addition & 1 deletion src/ReverseIteratorWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { JavaIterator } from "./java/util/Iterator";
import { JavaIterator } from "./java/util/Iterator.js";

/**
* This is the opposite of the IteratorWrapper class. It wraps a Java iterator (with proper modification checking)
Expand Down
32 changes: 16 additions & 16 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

export * as java from "./java/index";
export * as java from "./java/index.js";

export * from "./java/lang/Object";
export * from "./java/lang/String";
export * from "./java/lang/Boolean";
export * from "./java/lang/Number";
export * from "./java/lang/Object.js";
export * from "./java/lang/String.js";
export * from "./java/lang/Boolean.js";
export * from "./java/lang/Number.js";

export * from "./decorators";
export * from "./DefaultJavaEqualityComparator";
export * from "./JavaEqualityComparator";
export * from "./IteratorWrapper";
export * from "./JavaMapEntryIterator";
export * from "./MurmurHash";
export * from "./NotImplementedError";
export * from "./templates";
export * from "./resource-helpers";
export * from "./string-helpers";
export * from "./types";
export * from "./decorators.js";
export * from "./DefaultJavaEqualityComparator.js";
export * from "./JavaEqualityComparator.js";
export * from "./IteratorWrapper.js";
export * from "./JavaMapEntryIterator.js";
export * from "./MurmurHash.js";
export * from "./NotImplementedError.js";
export * from "./templates.js";
export * from "./resource-helpers.js";
export * from "./string-helpers.js";
export * from "./types.js";
16 changes: 8 additions & 8 deletions src/java/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

export * from "./lang/lang";
export * from "./util/util";
export * from "./io/io";
export * from "./nio/nio";
export * from "./text/text";
export * from "./time/time";
export * from "./security/security";
export * from "./net/net";
export * from "./lang/lang.js";
export * from "./util/util.js";
export * from "./io/io.js";
export * from "./nio/nio.js";
export * from "./text/text.js";
export * from "./time/time.js";
export * from "./security/security.js";
export * from "./net/net.js";
6 changes: 3 additions & 3 deletions src/java/io/BufferedOutputStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { IllegalArgumentException } from "../lang/IllegalArgumentException";
import { FilterOutputStream } from "./FilterOutputStream";
import { OutputStream } from "./OutputStream";
import { IllegalArgumentException } from "../lang/IllegalArgumentException.js";
import { FilterOutputStream } from "./FilterOutputStream.js";
import { OutputStream } from "./OutputStream.js";

export class BufferedOutputStream extends FilterOutputStream {

Expand Down
25 changes: 13 additions & 12 deletions src/java/io/BufferedReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { NotImplementedError } from "../../NotImplementedError";

import type { int, long } from "../../types";
import { OutOfMemoryError, StringBuilder } from "../lang";

import { IllegalArgumentException } from "../lang/IllegalArgumentException";
import { IndexOutOfBoundsException } from "../lang/IndexOutOfBoundsException";
import type { JavaString } from "../lang/String";
import { CharBuffer } from "../nio";
import type { Stream } from "../util/stream/Stream";
import { IOException } from "./IOException";
import { Reader } from "./Reader";
import { NotImplementedError } from "../../NotImplementedError.js";

import type { int, long } from "../../types.js";
import { OutOfMemoryError } from "../lang/OutOfMemoryError.js";

import { IllegalArgumentException } from "../lang/IllegalArgumentException.js";
import { IndexOutOfBoundsException } from "../lang/IndexOutOfBoundsException.js";
import type { JavaString } from "../lang/String.js";
import { CharBuffer } from "../nio/CharBuffer.js";
import type { Stream } from "../util/stream/Stream.js";
import { IOException } from "./IOException.js";
import { Reader } from "./Reader.js";
import { StringBuilder } from "../lang/StringBuilder.js";

/**
* Reads text from a character-input stream, buffering characters so as to provide for the efficient reading of
Expand Down
18 changes: 9 additions & 9 deletions src/java/io/BufferedWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { S } from "../../templates";
import type { int } from "../../types";
import { S } from "../../templates.js";
import type { int } from "../../types.js";

import { JavaString } from "../lang/String";
import { IllegalArgumentException } from "../lang/IllegalArgumentException";
import { IndexOutOfBoundsException } from "../lang/IndexOutOfBoundsException";
import { System } from "../lang/System";
import { IOException } from "./IOException";
import { JavaString } from "../lang/String.js";
import { IllegalArgumentException } from "../lang/IllegalArgumentException.js";
import { IndexOutOfBoundsException } from "../lang/IndexOutOfBoundsException.js";
import { System } from "../lang/System.js";
import { IOException } from "./IOException.js";

import { Writer } from "./Writer";
import { convertStringToUTF16 } from "../../string-helpers";
import { Writer } from "./Writer.js";
import { convertStringToUTF16 } from "../../string-helpers.js";

/**
* Writes text to a character-output stream, buffering characters so as to provide for the efficient writing of single
Expand Down
10 changes: 5 additions & 5 deletions src/java/io/ByteArrayOutputStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import type { int } from "../../types";
import { JavaString } from "../lang/String";
import { ByteBuffer } from "../nio/ByteBuffer";
import { Charset } from "../nio/charset";
import { OutputStream } from "./OutputStream";
import type { int } from "../../types.js";
import { JavaString } from "../lang/String.js";
import { ByteBuffer } from "../nio/ByteBuffer.js";
import { Charset } from "../nio/charset/Charset.js";
import { OutputStream } from "./OutputStream.js";

/**
* This class implements an output stream in which the data is written into a byte array. The buffer automatically
Expand Down
17 changes: 9 additions & 8 deletions src/java/io/CharArrayWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
* Copyright (c) Mike Lischke. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/
import type { char, int } from "../../types";

import { IllegalArgumentException } from "../lang/IllegalArgumentException";
import type { CharSequence } from "../lang/CharSequence";
import { Writer } from "./Writer";
import { JavaString } from "../lang/String";
import { convertStringToUTF16 } from "../../string-helpers";
import { IndexOutOfBoundsException } from "../lang/IndexOutOfBoundsException";

import type { char, int } from "../../types.js";

import { IllegalArgumentException } from "../lang/IllegalArgumentException.js";
import type { CharSequence } from "../lang/CharSequence.js";
import { Writer } from "./Writer.js";
import { JavaString } from "../lang/String.js";
import { convertStringToUTF16 } from "../../string-helpers.js";
import { IndexOutOfBoundsException } from "../lang/IndexOutOfBoundsException.js";

/**
* This class implements a character buffer that can be used as an Writer. The buffer automatically grows when data is
Expand Down
2 changes: 1 addition & 1 deletion src/java/io/Closeable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { AutoCloseable } from "../lang/AutoCloseable";
import { AutoCloseable } from "../lang/AutoCloseable.js";

export interface Closeable extends AutoCloseable {
/** Closes this stream and releases any system resources associated with it. */
Expand Down
2 changes: 1 addition & 1 deletion src/java/io/Console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { JavaObject } from "../lang/Object";
import { JavaObject } from "../lang/Object.js";

export class JavaConsole extends JavaObject {
}
20 changes: 10 additions & 10 deletions src/java/io/File.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
import path from "path";
import os from "os";
import crypto from "crypto";

import { JavaObject } from "../lang/Object";
import { JavaString } from "../lang/String";
import { Comparable } from "../lang/Comparable";
import { Serializable } from "./Serializable";
import { Path } from "../nio/file/Path";
import { URI } from "../net/URI";
import { FileSystems } from "../nio/file/FileSystems";
import { NullPointerException } from "../lang/NullPointerException";
import { IllegalArgumentException } from "../lang/IllegalArgumentException";
import { existsSync, mkdirSync, openSync, rmdirSync, statSync, unlinkSync } from "fs";

import { JavaObject } from "../lang/Object.js";
import { JavaString } from "../lang/String.js";
import { Comparable } from "../lang/Comparable.js";
import { Serializable } from "./Serializable.js";
import { Path } from "../nio/file/Path.js";
import { URI } from "../net/URI.js";
import { FileSystems } from "../nio/file/FileSystems.js";
import { NullPointerException } from "../lang/NullPointerException.js";
import { IllegalArgumentException } from "../lang/IllegalArgumentException.js";

const pendingFiles = new Set<JavaFile>();

/** An abstract representation of file and directory pathnames. */
Expand Down
Loading

0 comments on commit fb1d479

Please sign in to comment.