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
|
# always enable coverage
|
||||||
coverage = true
|
coverage = true
|
||||||
|
|
||||||
|
coverageReporter = ["text", "lcov"]
|
||||||
|
coverageDir = "coverage/raw"
|
||||||
|
coverageThreshold = 0.7
|
||||||
|
|
||||||
# disable code coverage counting test files
|
# disable code coverage counting test files
|
||||||
coverageSkipTestFiles = true
|
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,
|
"semiColons": true,
|
||||||
"singleQuote": true
|
"singleQuote": true
|
||||||
},
|
},
|
||||||
"nodeModulesDir": true,
|
"nodeModulesDir": "auto",
|
||||||
"exclude": ["src/bun/"]
|
"exclude": ["src/bun/"]
|
||||||
}
|
}
|
||||||
|
10
justfile
10
justfile
@ -3,14 +3,14 @@ default:
|
|||||||
@just --list
|
@just --list
|
||||||
|
|
||||||
# Test coverage
|
# Test coverage
|
||||||
coverage: deno-coverage bun-coverage
|
coverage: deno-coverage bun-coverage tsx-coverage
|
||||||
|
|
||||||
# Generate test coverage and open report in default browser
|
# Generate test coverage and open report in default browser
|
||||||
open-coverage: coverage
|
open-coverage: coverage
|
||||||
open coverage/index.html
|
open coverage
|
||||||
|
|
||||||
# Typescript checking
|
# Typescript checking
|
||||||
check: deno-check bun-check
|
check: deno-check bun-check tsx-check
|
||||||
|
|
||||||
# Generate source docs
|
# Generate source docs
|
||||||
docs:
|
docs:
|
||||||
@ -93,6 +93,10 @@ tsx-check:
|
|||||||
tsx-test:
|
tsx-test:
|
||||||
npm run tsx-test
|
npm run tsx-test
|
||||||
|
|
||||||
|
# Create test coverage report with tsx
|
||||||
|
tsx-coverage:
|
||||||
|
npm run tsx-coverage
|
||||||
|
|
||||||
# Run with tsx (NodeJS)
|
# Run with tsx (NodeJS)
|
||||||
tsx-run file="":
|
tsx-run file="":
|
||||||
npm run tsx-run {{file}}
|
npm run tsx-run {{file}}
|
||||||
|
@ -8,15 +8,16 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"bun-check": "bunx tsc",
|
"bun-check": "bunx tsc",
|
||||||
"bun-coverage": "bun test --coverage",
|
"bun-coverage": "./tools/bun-coverage.sh",
|
||||||
"bun-run": "bun run ./src/scroll.ts",
|
"bun-run": "bun run ./src/scroll.ts",
|
||||||
"bun-test": "bun test",
|
"bun-test": "bun test",
|
||||||
"deno-lint": "deno lint",
|
"deno-lint": "deno lint",
|
||||||
"deno-check": "deno check --all -c deno.jsonc ./src/deno/*.ts ./src/common/*.ts ./src/tsx/*.ts",
|
"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-run": "deno run --allow-all --deny-hrtime ./src/scroll.ts",
|
||||||
"deno-test": "deno test --allow-all",
|
"deno-test": "deno test --allow-all",
|
||||||
"tsx-check": "npx tsc",
|
"tsx-check": "npx tsc",
|
||||||
|
"tsx-coverage": "./tools/tsx-coverage.sh",
|
||||||
"tsx-run": "tsx ./src/scroll.ts",
|
"tsx-run": "tsx ./src/scroll.ts",
|
||||||
"tsx-test": "tsx --test './src/common/all_test.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++) {
|
for (let y = 0; y < this.screen.rows; y++) {
|
||||||
this.buffer.append(Ansi.ClearLine);
|
this.buffer.append(Ansi.ClearLine);
|
||||||
const fileRow = y + this.offset.y;
|
const fileRow = y + this.offset.y;
|
||||||
|
|
||||||
if (fileRow >= this.numRows) {
|
if (fileRow >= this.numRows) {
|
||||||
this.drawPlaceholderRow(fileRow);
|
this.drawPlaceholderRow(fileRow);
|
||||||
} else {
|
} else {
|
||||||
@ -479,7 +480,12 @@ export default class Editor {
|
|||||||
this.buffer.append(row.render(this.offset.x, len));
|
this.buffer.append(row.render(this.offset.x, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visually display an empty row
|
||||||
|
*/
|
||||||
protected drawPlaceholderRow(y: number): void {
|
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()) {
|
if (y === Math.trunc(this.screen.rows / 2) && this.document.isEmpty()) {
|
||||||
const message = `Scroll editor -- version ${SCROLL_VERSION}`;
|
const message = `Scroll editor -- version ${SCROLL_VERSION}`;
|
||||||
const messageLen = (message.length > this.screen.cols)
|
const messageLen = (message.length > this.screen.cols)
|
||||||
@ -494,9 +500,11 @@ export default class Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.buffer.append(message, messageLen);
|
this.buffer.append(message, messageLen);
|
||||||
} else {
|
return;
|
||||||
this.buffer.append('~');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Display an empty row with a starting tilde
|
||||||
|
this.buffer.append('~');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected drawStatusBar(): void {
|
protected drawStatusBar(): void {
|
||||||
|
@ -7,11 +7,11 @@ import {
|
|||||||
} from './base.ts';
|
} from './base.ts';
|
||||||
|
|
||||||
export class CFile extends AbstractFileType {
|
export class CFile extends AbstractFileType {
|
||||||
public readonly name: FileLang = FileLang.C;
|
public override readonly name: FileLang = FileLang.C;
|
||||||
public readonly singleLineComment = Some('//');
|
public override readonly singleLineComment = Some('//');
|
||||||
public readonly multiLineCommentStart: Option<string> = Some('/*');
|
public override readonly multiLineCommentStart: Option<string> = Some('/*');
|
||||||
public readonly multiLineCommentEnd: Option<string> = Some('*/');
|
public override readonly multiLineCommentEnd: Option<string> = Some('*/');
|
||||||
public readonly keywords1 = [
|
public override readonly keywords1 = [
|
||||||
'continue',
|
'continue',
|
||||||
'register',
|
'register',
|
||||||
'restrict',
|
'restrict',
|
||||||
@ -44,7 +44,7 @@ export class CFile extends AbstractFileType {
|
|||||||
'do',
|
'do',
|
||||||
'if',
|
'if',
|
||||||
];
|
];
|
||||||
public readonly keywords2 = [
|
public override readonly keywords2 = [
|
||||||
'#include',
|
'#include',
|
||||||
'unsigned',
|
'unsigned',
|
||||||
'uint32_t',
|
'uint32_t',
|
||||||
@ -74,7 +74,7 @@ export class CFile extends AbstractFileType {
|
|||||||
'int',
|
'int',
|
||||||
'#if',
|
'#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,
|
...defaultHighlightOptions,
|
||||||
characters: true,
|
characters: true,
|
||||||
hexNumbers: true,
|
hexNumbers: true,
|
||||||
|
@ -7,11 +7,11 @@ import {
|
|||||||
} from './base.ts';
|
} from './base.ts';
|
||||||
|
|
||||||
export class CSSFile extends AbstractFileType {
|
export class CSSFile extends AbstractFileType {
|
||||||
public readonly name: FileLang = FileLang.CSS;
|
public override readonly name: FileLang = FileLang.CSS;
|
||||||
public readonly singleLineComment = None;
|
public override readonly singleLineComment = None;
|
||||||
public readonly multiLineCommentStart: Option<string> = Some('/*');
|
public override readonly multiLineCommentStart: Option<string> = Some('/*');
|
||||||
public readonly multiLineCommentEnd: Option<string> = Some('*/');
|
public override readonly multiLineCommentEnd: Option<string> = Some('*/');
|
||||||
public readonly keywords1 = [
|
public override readonly keywords1 = [
|
||||||
':active',
|
':active',
|
||||||
':any-link',
|
':any-link',
|
||||||
':autofill',
|
':autofill',
|
||||||
@ -87,7 +87,7 @@ export class CSSFile extends AbstractFileType {
|
|||||||
'@supports',
|
'@supports',
|
||||||
'@view-transition',
|
'@view-transition',
|
||||||
];
|
];
|
||||||
public readonly keywords2 = [
|
public override readonly keywords2 = [
|
||||||
'animation-range-end',
|
'animation-range-end',
|
||||||
'animation-range-start',
|
'animation-range-start',
|
||||||
'accent-color',
|
'accent-color',
|
||||||
@ -386,8 +386,8 @@ export class CSSFile extends AbstractFileType {
|
|||||||
'overscroll-behavior-y',
|
'overscroll-behavior-y',
|
||||||
'overflow-clip-margin',
|
'overflow-clip-margin',
|
||||||
];
|
];
|
||||||
public readonly operators = ['::', ':', ',', '+', '>', '~', '-'];
|
public override readonly operators = ['::', ':', ',', '+', '>', '~', '-'];
|
||||||
public readonly hlOptions: HighlightingOptions = {
|
public override readonly hlOptions: HighlightingOptions = {
|
||||||
...defaultHighlightOptions,
|
...defaultHighlightOptions,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,11 @@ import {
|
|||||||
} from './base.ts';
|
} from './base.ts';
|
||||||
|
|
||||||
export class JavaScriptFile extends AbstractFileType {
|
export class JavaScriptFile extends AbstractFileType {
|
||||||
public readonly name: FileLang = FileLang.JavaScript;
|
public override readonly name: FileLang = FileLang.JavaScript;
|
||||||
public readonly singleLineComment = Some('//');
|
public override readonly singleLineComment = Some('//');
|
||||||
public readonly multiLineCommentStart: Option<string> = Some('/*');
|
public override readonly multiLineCommentStart: Option<string> = Some('/*');
|
||||||
public readonly multiLineCommentEnd: Option<string> = Some('*/');
|
public override readonly multiLineCommentEnd: Option<string> = Some('*/');
|
||||||
public readonly keywords1 = [
|
public override readonly keywords1 = [
|
||||||
'=>',
|
'=>',
|
||||||
'await',
|
'await',
|
||||||
'break',
|
'break',
|
||||||
@ -53,7 +53,7 @@ export class JavaScriptFile extends AbstractFileType {
|
|||||||
'with',
|
'with',
|
||||||
'yield',
|
'yield',
|
||||||
];
|
];
|
||||||
public readonly keywords2 = [
|
public override readonly keywords2 = [
|
||||||
'arguments',
|
'arguments',
|
||||||
'as',
|
'as',
|
||||||
'async',
|
'async',
|
||||||
@ -72,7 +72,7 @@ export class JavaScriptFile extends AbstractFileType {
|
|||||||
'Symbol',
|
'Symbol',
|
||||||
'undefined',
|
'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,
|
...defaultHighlightOptions,
|
||||||
octalNumbers: true,
|
octalNumbers: true,
|
||||||
hexNumbers: true,
|
hexNumbers: true,
|
||||||
@ -131,8 +131,8 @@ export class JavaScriptFile extends AbstractFileType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class TypeScriptFile extends JavaScriptFile {
|
export class TypeScriptFile extends JavaScriptFile {
|
||||||
public readonly name: FileLang = FileLang.TypeScript;
|
public override readonly name: FileLang = FileLang.TypeScript;
|
||||||
public readonly keywords2 = [
|
public override readonly keywords2 = [
|
||||||
...super.secondaryKeywords,
|
...super.secondaryKeywords,
|
||||||
// Typescript-specific
|
// Typescript-specific
|
||||||
'any',
|
'any',
|
||||||
|
@ -7,11 +7,11 @@ import {
|
|||||||
} from './base.ts';
|
} from './base.ts';
|
||||||
|
|
||||||
export class RustFile extends AbstractFileType {
|
export class RustFile extends AbstractFileType {
|
||||||
public readonly name: FileLang = FileLang.Rust;
|
public override readonly name: FileLang = FileLang.Rust;
|
||||||
public readonly singleLineComment = Some('//');
|
public override readonly singleLineComment = Some('//');
|
||||||
public readonly multiLineCommentStart: Option<string> = Some('/*');
|
public override readonly multiLineCommentStart: Option<string> = Some('/*');
|
||||||
public readonly multiLineCommentEnd: Option<string> = Some('*/');
|
public override readonly multiLineCommentEnd: Option<string> = Some('*/');
|
||||||
public readonly keywords1 = [
|
public override readonly keywords1 = [
|
||||||
'continue',
|
'continue',
|
||||||
'return',
|
'return',
|
||||||
'static',
|
'static',
|
||||||
@ -47,7 +47,7 @@ export class RustFile extends AbstractFileType {
|
|||||||
'if',
|
'if',
|
||||||
'in',
|
'in',
|
||||||
];
|
];
|
||||||
public readonly keywords2 = [
|
public override readonly keywords2 = [
|
||||||
'DoubleEndedIterator',
|
'DoubleEndedIterator',
|
||||||
'ExactSizeIterator',
|
'ExactSizeIterator',
|
||||||
'IntoIterator',
|
'IntoIterator',
|
||||||
@ -109,7 +109,7 @@ export class RustFile extends AbstractFileType {
|
|||||||
'&self',
|
'&self',
|
||||||
'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,
|
...defaultHighlightOptions,
|
||||||
characters: true,
|
characters: true,
|
||||||
binNumbers: true,
|
binNumbers: true,
|
||||||
|
@ -7,9 +7,9 @@ import {
|
|||||||
} from './base.ts';
|
} from './base.ts';
|
||||||
|
|
||||||
export class ShellFile extends AbstractFileType {
|
export class ShellFile extends AbstractFileType {
|
||||||
public readonly name: FileLang = FileLang.Shell;
|
public override readonly name: FileLang = FileLang.Shell;
|
||||||
public readonly singleLineComment = Some('#');
|
public override readonly singleLineComment = Some('#');
|
||||||
public readonly keywords1 = [
|
public override readonly keywords1 = [
|
||||||
'case',
|
'case',
|
||||||
'do',
|
'do',
|
||||||
'done',
|
'done',
|
||||||
@ -28,9 +28,9 @@ export class ShellFile extends AbstractFileType {
|
|||||||
'while',
|
'while',
|
||||||
'declare',
|
'declare',
|
||||||
];
|
];
|
||||||
public readonly keywords2 = ['set'];
|
public override readonly keywords2 = ['set'];
|
||||||
public readonly operators = ['[[', ']]'];
|
public override readonly operators = ['[[', ']]'];
|
||||||
public readonly hlOptions: HighlightingOptions = {
|
public override readonly hlOptions: HighlightingOptions = {
|
||||||
...defaultHighlightOptions,
|
...defaultHighlightOptions,
|
||||||
numbers: false,
|
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