Add 'override' modifier to overwritten properties in file types, generate test coverage for all runtimes
Some checks failed
timw4mail/scroll/pipeline/head There was a failure building this commit
Some checks failed
timw4mail/scroll/pipeline/head There was a failure building this commit
This commit is contained in:
parent
db3e5dd685
commit
d20c308f53
@ -8,5 +8,9 @@ save = false
|
||||
# always enable coverage
|
||||
coverage = true
|
||||
|
||||
coverageReporter = ["text", "lcov"]
|
||||
coverageDir = "coverage/raw"
|
||||
coverageThreshold = 0.7
|
||||
|
||||
# disable code coverage counting test files
|
||||
coverageSkipTestFiles = true
|
@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
rm -fr /coverage/
|
||||
deno test --allow-all --coverage=coverage
|
||||
deno coverage coverage --lcov > coverage/coverage.lcov
|
||||
genhtml -o coverage coverage/coverage.lcov
|
||||
rm coverage/*.json
|
@ -13,6 +13,6 @@
|
||||
"semiColons": true,
|
||||
"singleQuote": true
|
||||
},
|
||||
"nodeModulesDir": true,
|
||||
"nodeModulesDir": "auto",
|
||||
"exclude": ["src/bun/"]
|
||||
}
|
||||
|
10
justfile
10
justfile
@ -3,14 +3,14 @@ default:
|
||||
@just --list
|
||||
|
||||
# Test coverage
|
||||
coverage: deno-coverage bun-coverage
|
||||
coverage: deno-coverage bun-coverage tsx-coverage
|
||||
|
||||
# Generate test coverage and open report in default browser
|
||||
open-coverage: coverage
|
||||
open coverage/index.html
|
||||
open coverage
|
||||
|
||||
# Typescript checking
|
||||
check: deno-check bun-check
|
||||
check: deno-check bun-check tsx-check
|
||||
|
||||
# Generate source docs
|
||||
docs:
|
||||
@ -93,6 +93,10 @@ tsx-check:
|
||||
tsx-test:
|
||||
npm run tsx-test
|
||||
|
||||
# Create test coverage report with tsx
|
||||
tsx-coverage:
|
||||
npm run tsx-coverage
|
||||
|
||||
# Run with tsx (NodeJS)
|
||||
tsx-run file="":
|
||||
npm run tsx-run {{file}}
|
||||
|
@ -8,15 +8,16 @@
|
||||
},
|
||||
"scripts": {
|
||||
"bun-check": "bunx tsc",
|
||||
"bun-coverage": "bun test --coverage",
|
||||
"bun-coverage": "./tools/bun-coverage.sh",
|
||||
"bun-run": "bun run ./src/scroll.ts",
|
||||
"bun-test": "bun test",
|
||||
"deno-lint": "deno lint",
|
||||
"deno-check": "deno check --all -c deno.jsonc ./src/deno/*.ts ./src/common/*.ts ./src/tsx/*.ts",
|
||||
"deno-coverage": "./coverage.sh",
|
||||
"deno-coverage": "./tools/deno-coverage.sh",
|
||||
"deno-run": "deno run --allow-all --deny-hrtime ./src/scroll.ts",
|
||||
"deno-test": "deno test --allow-all",
|
||||
"tsx-check": "npx tsc",
|
||||
"tsx-coverage": "./tools/tsx-coverage.sh",
|
||||
"tsx-run": "tsx ./src/scroll.ts",
|
||||
"tsx-test": "tsx --test './src/common/all_test.ts'"
|
||||
},
|
||||
|
@ -452,6 +452,7 @@ export default class Editor {
|
||||
for (let y = 0; y < this.screen.rows; y++) {
|
||||
this.buffer.append(Ansi.ClearLine);
|
||||
const fileRow = y + this.offset.y;
|
||||
|
||||
if (fileRow >= this.numRows) {
|
||||
this.drawPlaceholderRow(fileRow);
|
||||
} else {
|
||||
@ -479,7 +480,12 @@ export default class Editor {
|
||||
this.buffer.append(row.render(this.offset.x, len));
|
||||
}
|
||||
|
||||
/**
|
||||
* Visually display an empty row
|
||||
*/
|
||||
protected drawPlaceholderRow(y: number): void {
|
||||
// Show program name and version in the middle of the screen in
|
||||
// empty, clean documents
|
||||
if (y === Math.trunc(this.screen.rows / 2) && this.document.isEmpty()) {
|
||||
const message = `Scroll editor -- version ${SCROLL_VERSION}`;
|
||||
const messageLen = (message.length > this.screen.cols)
|
||||
@ -494,9 +500,11 @@ export default class Editor {
|
||||
}
|
||||
|
||||
this.buffer.append(message, messageLen);
|
||||
} else {
|
||||
this.buffer.append('~');
|
||||
return;
|
||||
}
|
||||
|
||||
// Display an empty row with a starting tilde
|
||||
this.buffer.append('~');
|
||||
}
|
||||
|
||||
protected drawStatusBar(): void {
|
||||
|
@ -7,11 +7,11 @@ import {
|
||||
} from './base.ts';
|
||||
|
||||
export class CFile extends AbstractFileType {
|
||||
public readonly name: FileLang = FileLang.C;
|
||||
public readonly singleLineComment = Some('//');
|
||||
public readonly multiLineCommentStart: Option<string> = Some('/*');
|
||||
public readonly multiLineCommentEnd: Option<string> = Some('*/');
|
||||
public readonly keywords1 = [
|
||||
public override readonly name: FileLang = FileLang.C;
|
||||
public override readonly singleLineComment = Some('//');
|
||||
public override readonly multiLineCommentStart: Option<string> = Some('/*');
|
||||
public override readonly multiLineCommentEnd: Option<string> = Some('*/');
|
||||
public override readonly keywords1 = [
|
||||
'continue',
|
||||
'register',
|
||||
'restrict',
|
||||
@ -44,7 +44,7 @@ export class CFile extends AbstractFileType {
|
||||
'do',
|
||||
'if',
|
||||
];
|
||||
public readonly keywords2 = [
|
||||
public override readonly keywords2 = [
|
||||
'#include',
|
||||
'unsigned',
|
||||
'uint32_t',
|
||||
@ -74,7 +74,7 @@ export class CFile extends AbstractFileType {
|
||||
'int',
|
||||
'#if',
|
||||
];
|
||||
public readonly operators = [
|
||||
public override readonly operators = [
|
||||
'>>>=',
|
||||
'**=',
|
||||
'&&=',
|
||||
@ -143,7 +143,7 @@ export class CFile extends AbstractFileType {
|
||||
',',
|
||||
';',
|
||||
];
|
||||
public readonly hlOptions: HighlightingOptions = {
|
||||
public override readonly hlOptions: HighlightingOptions = {
|
||||
...defaultHighlightOptions,
|
||||
characters: true,
|
||||
hexNumbers: true,
|
||||
|
@ -7,11 +7,11 @@ import {
|
||||
} from './base.ts';
|
||||
|
||||
export class CSSFile extends AbstractFileType {
|
||||
public readonly name: FileLang = FileLang.CSS;
|
||||
public readonly singleLineComment = None;
|
||||
public readonly multiLineCommentStart: Option<string> = Some('/*');
|
||||
public readonly multiLineCommentEnd: Option<string> = Some('*/');
|
||||
public readonly keywords1 = [
|
||||
public override readonly name: FileLang = FileLang.CSS;
|
||||
public override readonly singleLineComment = None;
|
||||
public override readonly multiLineCommentStart: Option<string> = Some('/*');
|
||||
public override readonly multiLineCommentEnd: Option<string> = Some('*/');
|
||||
public override readonly keywords1 = [
|
||||
':active',
|
||||
':any-link',
|
||||
':autofill',
|
||||
@ -87,7 +87,7 @@ export class CSSFile extends AbstractFileType {
|
||||
'@supports',
|
||||
'@view-transition',
|
||||
];
|
||||
public readonly keywords2 = [
|
||||
public override readonly keywords2 = [
|
||||
'animation-range-end',
|
||||
'animation-range-start',
|
||||
'accent-color',
|
||||
@ -386,8 +386,8 @@ export class CSSFile extends AbstractFileType {
|
||||
'overscroll-behavior-y',
|
||||
'overflow-clip-margin',
|
||||
];
|
||||
public readonly operators = ['::', ':', ',', '+', '>', '~', '-'];
|
||||
public readonly hlOptions: HighlightingOptions = {
|
||||
public override readonly operators = ['::', ':', ',', '+', '>', '~', '-'];
|
||||
public override readonly hlOptions: HighlightingOptions = {
|
||||
...defaultHighlightOptions,
|
||||
};
|
||||
}
|
||||
|
@ -7,11 +7,11 @@ import {
|
||||
} from './base.ts';
|
||||
|
||||
export class JavaScriptFile extends AbstractFileType {
|
||||
public readonly name: FileLang = FileLang.JavaScript;
|
||||
public readonly singleLineComment = Some('//');
|
||||
public readonly multiLineCommentStart: Option<string> = Some('/*');
|
||||
public readonly multiLineCommentEnd: Option<string> = Some('*/');
|
||||
public readonly keywords1 = [
|
||||
public override readonly name: FileLang = FileLang.JavaScript;
|
||||
public override readonly singleLineComment = Some('//');
|
||||
public override readonly multiLineCommentStart: Option<string> = Some('/*');
|
||||
public override readonly multiLineCommentEnd: Option<string> = Some('*/');
|
||||
public override readonly keywords1 = [
|
||||
'=>',
|
||||
'await',
|
||||
'break',
|
||||
@ -53,7 +53,7 @@ export class JavaScriptFile extends AbstractFileType {
|
||||
'with',
|
||||
'yield',
|
||||
];
|
||||
public readonly keywords2 = [
|
||||
public override readonly keywords2 = [
|
||||
'arguments',
|
||||
'as',
|
||||
'async',
|
||||
@ -72,7 +72,7 @@ export class JavaScriptFile extends AbstractFileType {
|
||||
'Symbol',
|
||||
'undefined',
|
||||
];
|
||||
public readonly operators = [
|
||||
public override readonly operators = [
|
||||
'>>>=',
|
||||
'**=',
|
||||
'<<=',
|
||||
@ -121,7 +121,7 @@ export class JavaScriptFile extends AbstractFileType {
|
||||
',',
|
||||
';',
|
||||
];
|
||||
public readonly hlOptions: HighlightingOptions = {
|
||||
public override readonly hlOptions: HighlightingOptions = {
|
||||
...defaultHighlightOptions,
|
||||
octalNumbers: true,
|
||||
hexNumbers: true,
|
||||
@ -131,8 +131,8 @@ export class JavaScriptFile extends AbstractFileType {
|
||||
}
|
||||
|
||||
export class TypeScriptFile extends JavaScriptFile {
|
||||
public readonly name: FileLang = FileLang.TypeScript;
|
||||
public readonly keywords2 = [
|
||||
public override readonly name: FileLang = FileLang.TypeScript;
|
||||
public override readonly keywords2 = [
|
||||
...super.secondaryKeywords,
|
||||
// Typescript-specific
|
||||
'any',
|
||||
|
@ -7,11 +7,11 @@ import {
|
||||
} from './base.ts';
|
||||
|
||||
export class RustFile extends AbstractFileType {
|
||||
public readonly name: FileLang = FileLang.Rust;
|
||||
public readonly singleLineComment = Some('//');
|
||||
public readonly multiLineCommentStart: Option<string> = Some('/*');
|
||||
public readonly multiLineCommentEnd: Option<string> = Some('*/');
|
||||
public readonly keywords1 = [
|
||||
public override readonly name: FileLang = FileLang.Rust;
|
||||
public override readonly singleLineComment = Some('//');
|
||||
public override readonly multiLineCommentStart: Option<string> = Some('/*');
|
||||
public override readonly multiLineCommentEnd: Option<string> = Some('*/');
|
||||
public override readonly keywords1 = [
|
||||
'continue',
|
||||
'return',
|
||||
'static',
|
||||
@ -47,7 +47,7 @@ export class RustFile extends AbstractFileType {
|
||||
'if',
|
||||
'in',
|
||||
];
|
||||
public readonly keywords2 = [
|
||||
public override readonly keywords2 = [
|
||||
'DoubleEndedIterator',
|
||||
'ExactSizeIterator',
|
||||
'IntoIterator',
|
||||
@ -109,7 +109,7 @@ export class RustFile extends AbstractFileType {
|
||||
'&self',
|
||||
'self',
|
||||
];
|
||||
public readonly operators = [
|
||||
public override readonly operators = [
|
||||
'||=',
|
||||
'>>=',
|
||||
'<=>',
|
||||
@ -160,7 +160,7 @@ export class RustFile extends AbstractFileType {
|
||||
',',
|
||||
'-',
|
||||
];
|
||||
public readonly hlOptions: HighlightingOptions = {
|
||||
public override readonly hlOptions: HighlightingOptions = {
|
||||
...defaultHighlightOptions,
|
||||
characters: true,
|
||||
binNumbers: true,
|
||||
|
@ -7,9 +7,9 @@ import {
|
||||
} from './base.ts';
|
||||
|
||||
export class ShellFile extends AbstractFileType {
|
||||
public readonly name: FileLang = FileLang.Shell;
|
||||
public readonly singleLineComment = Some('#');
|
||||
public readonly keywords1 = [
|
||||
public override readonly name: FileLang = FileLang.Shell;
|
||||
public override readonly singleLineComment = Some('#');
|
||||
public override readonly keywords1 = [
|
||||
'case',
|
||||
'do',
|
||||
'done',
|
||||
@ -28,9 +28,9 @@ export class ShellFile extends AbstractFileType {
|
||||
'while',
|
||||
'declare',
|
||||
];
|
||||
public readonly keywords2 = ['set'];
|
||||
public readonly operators = ['[[', ']]'];
|
||||
public readonly hlOptions: HighlightingOptions = {
|
||||
public override readonly keywords2 = ['set'];
|
||||
public override readonly operators = ['[[', ']]'];
|
||||
public override readonly hlOptions: HighlightingOptions = {
|
||||
...defaultHighlightOptions,
|
||||
numbers: false,
|
||||
};
|
||||
|
3
tools/bun-coverage.sh
Executable file
3
tools/bun-coverage.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
bun test --coverage
|
||||
genhtml -o coverage/bun coverage/raw/lcov.info
|
5
tools/deno-coverage.sh
Executable file
5
tools/deno-coverage.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
deno test --allow-all --coverage=coverage/raw
|
||||
deno coverage coverage/raw --lcov > coverage/raw/deno.lcov
|
||||
rm -rf coverage/raw/*.json
|
||||
genhtml --ignore-errors inconsistent,inconsistent -o coverage/deno coverage/raw/deno.lcov
|
12
tools/tsx-coverage.sh
Executable file
12
tools/tsx-coverage.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
PARENT_DIR="$(dirname "$(realpath "$0")")"
|
||||
TSX="$(realpath "${PARENT_DIR}/../node_modules/.bin/tsx")"
|
||||
|
||||
"${TSX}" --test --experimental-test-coverage \
|
||||
--test-reporter=dot \
|
||||
--test-reporter-destination=stdout \
|
||||
--test-reporter=lcov \
|
||||
--test-reporter-destination=coverage/raw/tsx.lcov './src/common/all_test.ts'
|
||||
|
||||
genhtml --ignore-errors inconsistent,inconsistent -o coverage/tsx coverage/raw/tsx.lcov
|
Loading…
x
Reference in New Issue
Block a user