[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode a3c91282bc 039/222: Add test-case and inde
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode a3c91282bc 039/222: Add test-case and indentation-reference document. |
Date: |
Sun, 6 Feb 2022 16:59:08 -0500 (EST) |
branch: elpa/typescript-mode
commit a3c91282bc516d8b8498d5ceb7657610532e1c8e
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: Jostein Kjønigsen <jostein@kjonigsen.net>
Add test-case and indentation-reference document.
---
test-files/indentation-reference-document.ts | 92 ++++++++++++++++++++++++++++
typescript-mode-tests.el | 34 ++++++++++
2 files changed, 126 insertions(+)
diff --git a/test-files/indentation-reference-document.ts
b/test-files/indentation-reference-document.ts
new file mode 100644
index 0000000000..a6df0e6dc0
--- /dev/null
+++ b/test-files/indentation-reference-document.ts
@@ -0,0 +1,92 @@
+/// <reference types="node" />
+/// <reference path="shared.ts" />
+/// <reference path="session.ts" />
+// used in fs.writeSync
+/* tslint:disable:no-null-keyword */
+
+/*
+ * this file is a butchered copy of TypeScript's tsserver.ts file
+ * made to contain the most important syntactical elements
+ * of TypeScript to verify indentation-code.
+ *
+ * It will not build, and that's NOT a problem!
+ */
+
+// namespaces indent.
+namespace ts.server {
+
+ const net: {
+ connect(options: { port: number }, onConnect?: () => void): NodeSocket
+ } = require("net");
+
+ // functions indent.
+ function getGlobalTypingsCacheLocation() {
+ // We know switch/case is indented incorrectly.
+ // TODO: FIX!
+
+ // switch (process.platform) {
+ // case "win32": {
+ // const basePath = process.env.LOCALAPPDATA ||
+ // process.env.APPDATA;
+ // return combinePaths(normalizeSlashes(basePath),
"Microsoft/TypeScript");
+ // }
+ // case "darwin":
+ // case "linux":
+ // case "android": {
+ // const cacheLocation =
getNonWindowsCacheLocation(process.platform === "darwin");
+ // return combinePaths(cacheLocation, "typescript");
+ // }
+ // default:
+ // Debug.fail(`unsupported platform '${process.platform}'`);
+ // return;
+ // }
+ }
+
+ // interfaces and classes indent.
+ interface NodeChildProcess {
+ send(message: any, sendHandle?: any): void;
+ on(message: "message" | "exit", f: (m: any) => void): void;
+ kill(): void;
+ pid: number;
+ }
+
+ class Logger implements ts.server.Logger {
+ private firstInGroup = true;
+
+ // parameter-lists are currently not indented like tsserver wants it
to...
+ // constructor(private readonly logFilename: string,
+ // private readonly traceToConsole: boolean,
+ // private readonly level: LogLevel) {
+ // }
+
+ // function-typed class-members indent.
+ constructor(private readonly logFilename: string) {
+ console.log("yes");
+ }
+
+ static padStringRight(str: string, padding: string) {
+ return (str + padding).slice(0, padding.length);
+ }
+
+ close() {
+ if (this.fd >= 0) {
+ fs.close(this.fd);
+ }
+ }
+ }
+
+ // object initialization/parameter-lists indent.
+ const ioSession = new IOSession(
+ sys,
+ cancellationToken,
+ eventPort,
+ /*canUseEvents*/ eventPort === undefined,
+ useSingleInferredProject,
+ disableAutomaticTypingAcquisition,
+ getGlobalTypingsCacheLocation(),
+ telemetryEnabled,
+ logger);
+ process.on("uncaughtException", function (err: Error) {
+ ioSession.logError(err, "unknown");
+ });
+}
diff --git a/typescript-mode-tests.el b/typescript-mode-tests.el
new file mode 100644
index 0000000000..fb40785094
--- /dev/null
+++ b/typescript-mode-tests.el
@@ -0,0 +1,34 @@
+
+;;; typescript-mode-tests --- This file contains automated tests for
typescript-mode.el
+
+;;; Commentary:
+;; Run tests using (ert-run-tests-interactively t).
+
+;;; Code:
+
+(require 'ert)
+(require 'typescript-mode)
+
+(defun typescript-test-get-doc ()
+ (buffer-substring-no-properties (point-min) (point-max)))
+
+(defun typescript-test-indent-all ()
+ (delete-trailing-whitespace)
+ (indent-region (point-min) (point-max) nil)
+ (untabify (point-min) (point-max)))
+
+(ert-deftest indentation-reference-document-is-reflowed-correctly ()
+ (let* ((buffer (find-file "test-files/indentation-reference-document.ts")))
+ ;; double ensure mode is active
+ (typescript-mode)
+
+ (let ((test-reference (typescript-test-get-doc)))
+ (typescript-test-indent-all)
+ (should (string-equal test-reference
+ (typescript-test-get-doc))))
+
+ (kill-buffer buffer)))
+
+(provide 'typescript-mode-tests)
+
+;;; typescript-mode-tests.el ends here
- [nongnu] elpa/typescript-mode 447cfbc078 030/222: Improve compilation-mode support., (continued)
- [nongnu] elpa/typescript-mode 447cfbc078 030/222: Improve compilation-mode support., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode b502d8453d 041/222: On second thought, lets NOT support Emacs 24.1 and 24.2., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode f25f4751fe 052/222: Merge pull request #31 from lddubeau/fix/spread-syntax, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 2587e92851 047/222: Don't interpret class members as keywords., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode face381789 083/222: Implement clean make-target to assist local development., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 20af0fec5f 077/222: Extend function prefix font-lock test to check arguments are correct., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 5e2165d4b6 038/222: We need a Gitignore-file., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 330c887241 095/222: Fix indentation of functions with numbers in return type., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode b7074c5dea 106/222: Remove redundant code, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode bf9a4155cc 043/222: Revise Emacs versions tested a little more., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a3c91282bc 039/222: Add test-case and indentation-reference document.,
ELPA Syncer <=
- [nongnu] elpa/typescript-mode d29f31c791 045/222: Fix indentation of methods that are generators., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e780858a86 050/222: Don't interpret spread syntax as a continuation., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode f3140123d6 067/222: Remove a leftover comment., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode aae70b59e6 023/222: Merge pull request #16 from wingyplus/add-as-and-from-keywords, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 3766e37f24 026/222: Add README, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode f6907e8ae3 031/222: Fix error in compilation-mode alist registration., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 316b018d27 040/222: Add CI-config and test-runner., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode ab6d105807 076/222: Add regression tests for function name highlighting., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 2c43dd034c 068/222: Merge pull request #46 from ananthakumaran/fix/union-type-in-return-annotation, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 3361adad67 093/222: Prevent messing up comment fontification when filling paragraphs., ELPA Syncer, 2022/02/06