diff --git a/.gitattributes b/.gitattributes index 04f32be0..6313b56c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1 @@ -# Make sure baseline files have consistent line endings -*.txt text eol=lf -*.snap text eol=lf -*.debug-check text eol=lf \ No newline at end of file +* text=auto eol=lf diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b6e328f5..65f195dc 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,6 +1,6 @@ trigger: - master - - releases-* + - release-* variables: AST_COMPARE: true @@ -31,6 +31,7 @@ jobs: vmImage: vs2017-win2016 variables: node_version: 10 + TEST_CRLF: true steps: - template: .azure-pipelines/dev.yml diff --git a/jest.config.js b/jest.config.js index 1b6f86a6..c837041a 100644 --- a/jest.config.js +++ b/jest.config.js @@ -17,13 +17,9 @@ module.exports = { "jest-snapshot-serializer-ansi" ], testRegex: "jsfmt\\.spec\\.js$|__tests__/.*\\.js$", - testPathIgnorePatterns: ["tests/new_react", "tests/more_react"] - .concat(isOldNode ? requiresPrettierInternals : []) - .concat( - require("os").EOL == "\n" - ? ["tests_integration/__tests__/eol-crlf.js"] - : ["tests_integration/__tests__/eol-lf.js"] - ), + testPathIgnorePatterns: ["tests/new_react", "tests/more_react"].concat( + isOldNode ? requiresPrettierInternals : [] + ), collectCoverage: ENABLE_COVERAGE, collectCoverageFrom: ["src/**/*.js", "index.js", "!/node_modules/"], coveragePathIgnorePatterns: [ diff --git a/package.json b/package.json index f4eb07ff..025040e2 100644 --- a/package.json +++ b/package.json @@ -71,8 +71,8 @@ "unicode-regex": "2.0.0", "unified": "6.1.6", "vnopts": "1.0.2", - "yaml": "1.0.0-rc.8", - "yaml-unist-parser": "1.0.0-rc.4" + "yaml": "1.0.2", + "yaml-unist-parser": "1.0.0" }, "devDependencies": { "@babel/cli": "7.1.5", diff --git a/src/common/util.js b/src/common/util.js index 86d483bd..891a061a 100644 --- a/src/common/util.js +++ b/src/common/util.js @@ -675,7 +675,19 @@ function isWithinParentArrayProperty(path, propertyName) { return parent[propertyName][key] === node; } +function replaceEndOfLineWith(text, replacement) { + const parts = []; + for (const part of text.split("\n")) { + if (parts.length !== 0) { + parts.push(replacement); + } + parts.push(part); + } + return parts; +} + module.exports = { + replaceEndOfLineWith, getStringWidth, getMaxContinuousCount, getPrecedence, diff --git a/src/language-css/printer-postcss.js b/src/language-css/printer-postcss.js index 2027952a..d58484fc 100644 --- a/src/language-css/printer-postcss.js +++ b/src/language-css/printer-postcss.js @@ -110,11 +110,7 @@ function genericPrint(path, options, print) { } case "css-comment": { if (node.raws.content) { - return ( - node.raws.content - // there's a bug in the less parser that trailing `\r`s are included in inline comments - .replace(/^(\/\/[^]+)\r+$/, "$1") - ); + return node.raws.content; } const text = options.originalText.slice( options.locStart(node), diff --git a/src/language-html/parser-html.js b/src/language-html/parser-html.js index 36b7e160..57c77611 100644 --- a/src/language-html/parser-html.js +++ b/src/language-html/parser-html.js @@ -265,7 +265,6 @@ function createParser({ allowHtmComponentClosingTags = false } = {}) { return { - preprocess: text => text.replace(/\r\n?/g, "\n"), parse: (text, parsers, options) => _parse(text, options, { recognizeSelfClosing, diff --git a/src/language-html/printer-html.js b/src/language-html/printer-html.js index 1cab5dea..c9bcada1 100644 --- a/src/language-html/printer-html.js +++ b/src/language-html/printer-html.js @@ -34,12 +34,11 @@ const { isTextLikeNode, normalizeParts, preferHardlineAsLeadingSpaces, - replaceDocNewlines, - replaceNewlines, shouldNotPrintClosingTag, shouldPreserveContent, unescapeQuoteEntities } = require("./utils"); +const { replaceEndOfLineWith } = require("../common/util"); const preprocess = require("./preprocess"); const assert = require("assert"); const { insertPragma } = require("./pragma"); @@ -147,10 +146,7 @@ function embed(path, print, textToDoc, options) { hardline, node.value.trim().length === 0 ? "" - : replaceDocNewlines( - textToDoc(node.value, { parser: "yaml" }), - literalline - ), + : textToDoc(node.value, { parser: "yaml" }), "---" ]) ); @@ -287,7 +283,7 @@ function genericPrint(path, options, print) { ? node.value.replace(trailingNewlineRegex, "") : node.value; return concat([ - concat(replaceNewlines(value, literalline)), + concat(replaceEndOfLineWith(value, literalline)), hasTrailingNewline ? hardline : "" ]); } @@ -316,7 +312,7 @@ function genericPrint(path, options, print) { return concat([ printOpeningTagPrefix(node, options), concat( - replaceNewlines( + replaceEndOfLineWith( options.originalText.slice( options.locStart(node), options.locEnd(node) @@ -341,7 +337,7 @@ function genericPrint(path, options, print) { "=", quote, concat( - replaceNewlines( + replaceEndOfLineWith( quote === '"' ? value.replace(/"/g, """) : value.replace(/'/g, "'"), @@ -354,7 +350,7 @@ function genericPrint(path, options, print) { } case "yaml": case "toml": - return node.raw; + return concat(replaceEndOfLineWith(node.raw, literalline)); default: throw new Error(`Unexpected node type ${node.type}`); } @@ -473,7 +469,7 @@ function printChildren(path, options, print) { return concat( [].concat( printOpeningTagPrefix(child, options), - replaceNewlines( + replaceEndOfLineWith( options.originalText.slice( options.locStart(child) + (child.prev && @@ -497,7 +493,7 @@ function printChildren(path, options, print) { [].concat( printOpeningTagPrefix(child, options), group(printOpeningTag(childPath, options, print)), - replaceNewlines( + replaceEndOfLineWith( options.originalText.slice( child.startSourceSpan.end.offset + (child.firstChild && @@ -620,7 +616,7 @@ function printOpeningTag(path, options, print) { const attr = attrPath.getValue(); return hasPrettierIgnoreAttribute(attr) ? concat( - replaceNewlines( + replaceEndOfLineWith( options.originalText.slice( options.locStart(attr), options.locEnd(attr) @@ -894,8 +890,8 @@ function printClosingTagEndMarker(node, options) { function getTextValueParts(node, value = node.value) { return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive - ? replaceNewlines(value, literalline) - : replaceNewlines( + ? replaceEndOfLineWith(value, literalline) + : replaceEndOfLineWith( dedentString(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline ) @@ -1037,7 +1033,7 @@ function printEmbeddedAttributeValue(node, originalTextToDoc, options) { const parts = []; value.split(interpolationRegex).forEach((part, index) => { if (index % 2 === 0) { - parts.push(concat(replaceNewlines(part, literalline))); + parts.push(concat(replaceEndOfLineWith(part, literalline))); } else { try { parts.push( @@ -1056,7 +1052,11 @@ function printEmbeddedAttributeValue(node, originalTextToDoc, options) { ) ); } catch (e) { - parts.push("{{", concat(replaceNewlines(part, literalline)), "}}"); + parts.push( + "{{", + concat(replaceEndOfLineWith(part, literalline)), + "}}" + ); } } }); diff --git a/src/language-html/utils.js b/src/language-html/utils.js index 1c9940e7..fe1b6d31 100644 --- a/src/language-html/utils.js +++ b/src/language-html/utils.js @@ -1,10 +1,5 @@ "use strict"; -const { - builders: { concat }, - utils: { mapDoc } -} = require("../doc"); - const { CSS_DISPLAY_TAGS, CSS_DISPLAY_DEFAULT, @@ -263,20 +258,6 @@ function isDanglingSpaceSensitiveNode(node) { ); } -function replaceNewlines(text, replacement) { - return text - .split(/(\n)/g) - .map((data, index) => (index % 2 === 1 ? replacement : data)); -} - -function replaceDocNewlines(doc, replacement) { - return mapDoc(doc, currentDoc => - typeof currentDoc === "string" && currentDoc.includes("\n") - ? concat(replaceNewlines(currentDoc, replacement)) - : currentDoc - ); -} - function forceNextEmptyLine(node) { return ( isFrontMatterNode(node) || @@ -645,8 +626,6 @@ module.exports = { normalizeParts, preferHardlineAsLeadingSpaces, preferHardlineAsTrailingSpaces, - replaceDocNewlines, - replaceNewlines, shouldNotPrintClosingTag, shouldPreserveContent, unescapeQuoteEntities diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 6e094890..81fc2f85 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -2395,7 +2395,10 @@ function printPathNoParens(path, options, print, args) { "${" + printDocToString( doc, - Object.assign({}, options, { printWidth: Infinity }) + Object.assign({}, options, { + printWidth: Infinity, + endOfLine: "lf" + }) ).formatted + "}" ); diff --git a/src/language-markdown/embed.js b/src/language-markdown/embed.js index 3c8068b0..846318ba 100644 --- a/src/language-markdown/embed.js +++ b/src/language-markdown/embed.js @@ -42,7 +42,7 @@ function embed(path, print, textToDoc, options) { concat([ "---", hardline, - node.value.trim() + node.value && node.value.trim() ? replaceNewlinesWithLiterallines( textToDoc(node.value, { parser: "yaml" }) ) diff --git a/src/language-markdown/pragma.js b/src/language-markdown/pragma.js index d7018bd7..070fb50d 100644 --- a/src/language-markdown/pragma.js +++ b/src/language-markdown/pragma.js @@ -9,7 +9,7 @@ function startWithPragma(text) { const regex = new RegExp( [ ``, - `` + `` ].join("|"), "m" ); diff --git a/src/language-markdown/printer-markdown.js b/src/language-markdown/printer-markdown.js index a6b43ddb..9b73c20b 100644 --- a/src/language-markdown/printer-markdown.js +++ b/src/language-markdown/printer-markdown.js @@ -27,6 +27,7 @@ const { splitText, punctuationPattern } = require("./utils"); +const { replaceEndOfLineWith } = require("../common/util"); const TRAILING_HARDLINE_NODES = ["importExport"]; @@ -209,7 +210,10 @@ function genericPrint(path, options, print) { const alignment = " ".repeat(4); return align( alignment, - concat([alignment, replaceNewlinesWith(node.value, hardline)]) + concat([ + alignment, + concat(replaceEndOfLineWith(node.value, hardline)) + ]) ); } @@ -225,9 +229,11 @@ function genericPrint(path, options, print) { style, node.lang || "", hardline, - replaceNewlinesWith( - getFencedCodeBlockValue(node, options.originalText), - hardline + concat( + replaceEndOfLineWith( + getFencedCodeBlockValue(node, options.originalText), + hardline + ) ), hardline, style @@ -247,9 +253,11 @@ function genericPrint(path, options, print) { ? node.value.trimRight() : node.value; const isHtmlComment = /^$/.test(value); - return replaceNewlinesWith( - value, - isHtmlComment ? hardline : markAsRoot(literalline) + return concat( + replaceEndOfLineWith( + value, + isHtmlComment ? hardline : markAsRoot(literalline) + ) ); } case "list": { @@ -394,7 +402,7 @@ function genericPrint(path, options, print) { ? concat([" ", markAsRoot(literalline)]) : concat(["\\", hardline]); case "liquidNode": - return replaceNewlinesWith(node.value, hardline); + return concat(replaceEndOfLineWith(node.value, hardline)); // MDX case "importExport": case "jsx": @@ -404,7 +412,10 @@ function genericPrint(path, options, print) { "$$", hardline, node.value - ? concat([replaceNewlinesWith(node.value, hardline), hardline]) + ? concat([ + concat(replaceEndOfLineWith(node.value, hardline)), + hardline + ]) : "", "$$" ]); @@ -467,10 +478,6 @@ function getNthListSiblingIndex(node, parentNode) { ); } -function replaceNewlinesWith(str, doc) { - return join(doc, str.replace(/\r\n?/g, "\n").split("\n")); -} - function getNthSiblingIndex(node, parentNode, condition) { condition = condition || (() => true); diff --git a/src/language-markdown/utils.js b/src/language-markdown/utils.js index b15d92c7..83736b60 100644 --- a/src/language-markdown/utils.js +++ b/src/language-markdown/utils.js @@ -148,7 +148,7 @@ function getFencedCodeBlockValue(node, originalText) { const leadingSpaceCount = text.match(/^\s*/)[0].length; const replaceRegex = new RegExp(`^\\s{0,${leadingSpaceCount}}`); - const lineContents = text.replace(/\r\n?/g, "\n").split("\n"); + const lineContents = text.split("\n"); const markerStyle = text[leadingSpaceCount]; // ` or ~ const marker = text diff --git a/src/language-yaml/parser-yaml.js b/src/language-yaml/parser-yaml.js index cbcd5d02..3d7c9bf8 100644 --- a/src/language-yaml/parser-yaml.js +++ b/src/language-yaml/parser-yaml.js @@ -29,11 +29,7 @@ const parser = { parse, hasPragma, locStart: node => node.position.start.offset, - locEnd: node => node.position.end.offset, - - // workaround for https://github.com/eemeli/yaml/issues/20 - preprocess: text => - text.indexOf("\r") === -1 ? text : text.replace(/\r\n?/g, "\n") + locEnd: node => node.position.end.offset }; module.exports = { diff --git a/src/language-yaml/printer-yaml.js b/src/language-yaml/printer-yaml.js index 2e80c6e0..96d757a2 100644 --- a/src/language-yaml/printer-yaml.js +++ b/src/language-yaml/printer-yaml.js @@ -38,6 +38,7 @@ const { markAsRoot, softline } = docBuilders; +const { replaceEndOfLineWith } = require("../common/util"); function preprocess(ast) { return mapNode(ast, defineShortcuts); @@ -104,9 +105,14 @@ function genericPrint(path, options, print) { ]) : "", hasPrettierIgnore(path) - ? options.originalText.slice( - node.position.start.offset, - node.position.end.offset + ? concat( + replaceEndOfLineWith( + options.originalText.slice( + node.position.start.offset, + node.position.end.offset + ), + literalline + ) ) : group(_print(node, parentNode, path, options, print)), hasTrailingComment(node) && !isNode(node, ["document", "documentHead"]) diff --git a/src/language-yaml/utils.js b/src/language-yaml/utils.js index fc3f8244..777568ca 100644 --- a/src/language-yaml/utils.js +++ b/src/language-yaml/utils.js @@ -1,8 +1,6 @@ "use strict"; -function getLast(array) { - return array[array.length - 1]; -} +const { getLast } = require("../common/util"); function getAncestorCount(path, filter) { let counter = 0; diff --git a/src/main/core.js b/src/main/core.js index fc4ee772..a70e41f6 100644 --- a/src/main/core.js +++ b/src/main/core.js @@ -14,6 +14,7 @@ const { const rangeUtil = require("./range-util"); const privateUtil = require("../common/util"); const { + utils: { mapDoc }, printer: { printDocToString }, debug: { printDocToDebug } } = require("../doc"); @@ -21,6 +22,11 @@ const { const UTF8BOM = 0xfeff; const CURSOR = Symbol("cursor"); +const PLACEHOLDERS = { + cursorOffset: "<<>>", + rangeStart: "<<>>", + rangeEnd: "<<>>" +}; function ensureAllCommentsPrinted(astComments) { if (!astComments) { @@ -67,8 +73,6 @@ function coreFormat(text, opts, addAlignmentSize) { const parsed = parser.parse(text, opts); const ast = parsed.ast; - - const originalText = text; text = parsed.text; if (opts.cursorOffset >= 0) { @@ -80,11 +84,18 @@ function coreFormat(text, opts, addAlignmentSize) { const astComments = attachComments(text, ast, opts); const doc = printAstToDoc(ast, opts, addAlignmentSize); - if (opts.endOfLine === "auto") { - opts.endOfLine = guessEndOfLine(originalText); - } - const result = printDocToString(doc, opts); + const eol = convertEndOfLineToChars(opts.endOfLine); + const result = printDocToString( + opts.endOfLine === "lf" + ? doc + : mapDoc(doc, currentDoc => + typeof currentDoc === "string" && currentDoc.indexOf("\n") !== -1 + ? currentDoc.replace(/\n/g, eol) + : currentDoc + ), + opts + ); ensureAllCommentsPrinted(astComments); // Remove extra leading indentation as well as the added indentation after last newline @@ -212,8 +223,8 @@ function formatRange(text, opts) { // Since the range contracts to avoid trailing whitespace, // we need to remove the newline that was inserted by the `format` call. const rangeTrimmed = rangeResult.formatted.trimRight(); - const formatted = - text.slice(0, rangeStart) + rangeTrimmed + text.slice(rangeEnd); + const rangeLeft = text.slice(0, rangeStart); + const rangeRight = text.slice(rangeEnd); let cursorOffset = opts.cursorOffset; if (opts.cursorOffset >= rangeEnd) { @@ -226,6 +237,44 @@ function formatRange(text, opts) { } // keep the cursor as it was if it was before the start of the range + let formatted; + if (opts.endOfLine === "lf") { + formatted = rangeLeft + rangeTrimmed + rangeRight; + } else { + const eol = convertEndOfLineToChars(opts.endOfLine); + if (cursorOffset >= 0) { + const parts = [rangeLeft, rangeTrimmed, rangeRight]; + let partIndex = 0; + let partOffset = cursorOffset; + while (partIndex < parts.length) { + const part = parts[partIndex]; + if (partOffset < part.length) { + parts[partIndex] = + parts[partIndex].slice(0, partOffset) + + PLACEHOLDERS.cursorOffset + + parts[partIndex].slice(partOffset); + break; + } + partIndex++; + partOffset -= part.length; + } + const [newRangeLeft, newRangeTrimmed, newRangeRight] = parts; + formatted = ( + newRangeLeft.replace(/\n/g, eol) + + newRangeTrimmed + + newRangeRight.replace(/\n/g, eol) + ).replace(PLACEHOLDERS.cursorOffset, (_, index) => { + cursorOffset = index; + return ""; + }); + } else { + formatted = + rangeLeft.replace(/\n/g, eol) + + rangeTrimmed + + rangeRight.replace(/\n/g, eol); + } + } + return { formatted, cursorOffset }; } @@ -236,23 +285,83 @@ function format(text, opts) { return { formatted: text }; } - if (opts.rangeStart > 0 || opts.rangeEnd < text.length) { - return formatRange(text, opts); + if (opts.endOfLine === "auto") { + opts.endOfLine = guessEndOfLine(text); + } + + const hasCursor = opts.cursorOffset >= 0; + const hasRangeStart = opts.rangeStart > 0; + const hasRangeEnd = opts.rangeEnd < text.length; + + // get rid of CR/CRLF parsing + if (text.indexOf("\r") !== -1) { + const offsetKeys = [ + hasCursor && "cursorOffset", + hasRangeStart && "rangeStart", + hasRangeEnd && "rangeEnd" + ] + .filter(Boolean) + .sort((aKey, bKey) => opts[aKey] - opts[bKey]); + + for (let i = offsetKeys.length - 1; i >= 0; i--) { + const key = offsetKeys[i]; + text = + text.slice(0, opts[key]) + PLACEHOLDERS[key] + text.slice(opts[key]); + } + + text = text.replace(/\r\n?/g, "\n"); + + for (let i = 0; i < offsetKeys.length; i++) { + const key = offsetKeys[i]; + text = text.replace(PLACEHOLDERS[key], (_, index) => { + opts[key] = index; + return ""; + }); + } } const hasUnicodeBOM = text.charCodeAt(0) === UTF8BOM; if (hasUnicodeBOM) { text = text.substring(1); + if (hasCursor) { + opts.cursorOffset++; + } + if (hasRangeStart) { + opts.rangeStart++; + } + if (hasRangeEnd) { + opts.rangeEnd++; + } } - if (opts.insertPragma && opts.printer.insertPragma && !hasPragma) { - text = opts.printer.insertPragma(text); + if (!hasCursor) { + opts.cursorOffset = -1; + } + if (opts.rangeStart < 0) { + opts.rangeStart = 0; + } + if (opts.rangeEnd > text.length) { + opts.rangeEnd = text.length; } - const result = coreFormat(text, opts); + const result = + hasRangeStart || hasRangeEnd + ? formatRange(text, opts) + : coreFormat( + opts.insertPragma && opts.printer.insertPragma && !hasPragma + ? opts.printer.insertPragma(text) + : text, + opts + ); + if (hasUnicodeBOM) { result.formatted = String.fromCharCode(UTF8BOM) + result.formatted; + + if (hasCursor) { + result.cursorOffset++; + } } + return result; } @@ -264,6 +373,9 @@ module.exports = { parse(text, opts, massage) { opts = normalizeOptions(opts); + if (text.indexOf("\r") !== -1) { + text = text.replace(/\r\n?/g, "\n"); + } const parsed = parser.parse(text, opts); if (massage) { parsed.ast = massageAST(parsed.ast, opts); diff --git a/tests/comments_jsx_same_line/jsx_same_line.js b/tests/comments_jsx_same_line/jsx_same_line.js index fbe43686..e0691413 100644 --- a/tests/comments_jsx_same_line/jsx_same_line.js +++ b/tests/comments_jsx_same_line/jsx_same_line.js @@ -1,28 +1,28 @@ -
- {foo} -
; - -
- {foo} -
; - -
- {foo} -
; - -
- {foo} -
; - -
; +
+ {foo} +
; + +
+ {foo} +
; + +
+ {foo} +
; + +
+ {foo} +
; + +
; diff --git a/tests/decorators/mobx.js b/tests/decorators/mobx.js index a75a70af..8a497af8 100644 --- a/tests/decorators/mobx.js +++ b/tests/decorators/mobx.js @@ -1,36 +1,36 @@ -import {observable} from "mobx"; - -@observer class OrderLine { - @observable price:number = 0; - @observable amount:number = 1; - - constructor(price) { - this.price = price; - } - - @computed get total() { - return this.price * this.amount; - } - - @action.bound setPrice(price) { - this.price = price; - } - - @computed - get total() { - return this.price * this.amount; - } - - @action.bound - setPrice(price) { - this.price = price; - } - - @computed @computed @computed @computed @computed @computed @computed get total() { - return this.price * this.amount; - } - - @action handleDecrease = (event: React.ChangeEvent) => this.count--; - - @action handleSomething = (event: React.ChangeEvent) => doSomething(); -} +import {observable} from "mobx"; + +@observer class OrderLine { + @observable price:number = 0; + @observable amount:number = 1; + + constructor(price) { + this.price = price; + } + + @computed get total() { + return this.price * this.amount; + } + + @action.bound setPrice(price) { + this.price = price; + } + + @computed + get total() { + return this.price * this.amount; + } + + @action.bound + setPrice(price) { + this.price = price; + } + + @computed @computed @computed @computed @computed @computed @computed get total() { + return this.price * this.amount; + } + + @action handleDecrease = (event: React.ChangeEvent) => this.count--; + + @action handleSomething = (event: React.ChangeEvent) => doSomething(); +} diff --git a/tests/directives/escaped.js b/tests/directives/escaped.js index 8894f70a..0d28dab8 100644 --- a/tests/directives/escaped.js +++ b/tests/directives/escaped.js @@ -29,7 +29,7 @@ 'meaningfully escaped alphabetical characters \n \r \v \t \b \f \u2713 \x61' 'escaped newline \ ' -'escaped carriage return \ +'escaped carriage return \ ' 'escaped \u2028 \
' 'escaped \u2029 \
' diff --git a/tests/end_of_line/__snapshots__/jsfmt.spec.js.snap b/tests/end_of_line/__snapshots__/jsfmt.spec.js.snap index c6b8dd28..abb1ade6 100644 --- a/tests/end_of_line/__snapshots__/jsfmt.spec.js.snap +++ b/tests/end_of_line/__snapshots__/jsfmt.spec.js.snap @@ -1,145 +1,58 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`usingCrlf.js 1`] = ` -====================================options===================================== -parsers: ["babylon"] -printWidth: 80 - | printWidth -=====================================input====================================== -function f() { - console.log("testing line endings"); -} - -=====================================output===================================== -function f() { - console.log("testing line endings"); -} - -================================================================================ -`; - -exports[`usingCrlf.js 2`] = ` +exports[`example.js 1`] = ` ====================================options===================================== endOfLine: "cr" parsers: ["babylon"] printWidth: 80 | printWidth =====================================input====================================== -function f() { - console.log("testing line endings"); -} +function f() { + console.log("testing line endings"); +} =====================================output===================================== -function f() {/*CR*/ console.log("testing line endings");/*CR*/}/*CR*/ +function f() { + console.log("testing line endings"); +} + ================================================================================ `; -exports[`usingCrlf.js 3`] = ` +exports[`example.js 2`] = ` ====================================options===================================== endOfLine: "crlf" parsers: ["babylon"] printWidth: 80 | printWidth =====================================input====================================== -function f() { - console.log("testing line endings"); -} +function f() { + console.log("testing line endings"); +} =====================================output===================================== -function f() {/*CR*/ - console.log("testing line endings");/*CR*/ -}/*CR*/ +function f() { + console.log("testing line endings"); +} ================================================================================ `; -exports[`usingCrlf.js 4`] = ` +exports[`example.js 3`] = ` ====================================options===================================== endOfLine: "lf" parsers: ["babylon"] printWidth: 80 | printWidth =====================================input====================================== -function f() { - console.log("testing line endings"); -} +function f() { + console.log("testing line endings"); +} =====================================output===================================== -function f() { - console.log("testing line endings"); -} - -================================================================================ -`; - -exports[`usingLf.js 1`] = ` -====================================options===================================== -parsers: ["babylon"] -printWidth: 80 - | printWidth -=====================================input====================================== -function f() { - console.log("testing line endings"); -} - -=====================================output===================================== -function f() { - console.log("testing line endings"); -} - -================================================================================ -`; - -exports[`usingLf.js 2`] = ` -====================================options===================================== -endOfLine: "cr" -parsers: ["babylon"] -printWidth: 80 - | printWidth -=====================================input====================================== -function f() { - console.log("testing line endings"); -} - -=====================================output===================================== -function f() {/*CR*/ console.log("testing line endings");/*CR*/}/*CR*/ -================================================================================ -`; - -exports[`usingLf.js 3`] = ` -====================================options===================================== -endOfLine: "crlf" -parsers: ["babylon"] -printWidth: 80 - | printWidth -=====================================input====================================== -function f() { - console.log("testing line endings"); -} - -=====================================output===================================== -function f() {/*CR*/ - console.log("testing line endings");/*CR*/ -}/*CR*/ - -================================================================================ -`; - -exports[`usingLf.js 4`] = ` -====================================options===================================== -endOfLine: "lf" -parsers: ["babylon"] -printWidth: 80 - | printWidth -=====================================input====================================== -function f() { - console.log("testing line endings"); -} - -=====================================output===================================== -function f() { - console.log("testing line endings"); -} +function f() { + console.log("testing line endings"); +} ================================================================================ `; diff --git a/tests/end_of_line/usingLf.js b/tests/end_of_line/example.js similarity index 100% rename from tests/end_of_line/usingLf.js rename to tests/end_of_line/example.js diff --git a/tests/end_of_line/jsfmt.spec.js b/tests/end_of_line/jsfmt.spec.js index ebf66925..e4898ce3 100644 --- a/tests/end_of_line/jsfmt.spec.js +++ b/tests/end_of_line/jsfmt.spec.js @@ -1,4 +1,3 @@ -run_spec(__dirname, ["babylon"]); run_spec(__dirname, ["babylon"], { endOfLine: "cr" }); run_spec(__dirname, ["babylon"], { endOfLine: "crlf" }); run_spec(__dirname, ["babylon"], { endOfLine: "lf" }); diff --git a/tests/end_of_line/usingCrlf.js b/tests/end_of_line/usingCrlf.js deleted file mode 100644 index d5059e10..00000000 --- a/tests/end_of_line/usingCrlf.js +++ /dev/null @@ -1,3 +0,0 @@ -function f() { - console.log("testing line endings"); -} diff --git a/tests/end_of_line_in_css/__snapshots__/jsfmt.spec.js.snap b/tests/end_of_line_in_css/__snapshots__/jsfmt.spec.js.snap deleted file mode 100644 index f9ef1722..00000000 --- a/tests/end_of_line_in_css/__snapshots__/jsfmt.spec.js.snap +++ /dev/null @@ -1,137 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`usingCrlf.css 1`] = ` -====================================options===================================== -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -.foo { - margin: 42px; -} -=====================================output===================================== -.foo { - margin: 42px; -} - -================================================================================ -`; - -exports[`usingCrlf.css 2`] = ` -====================================options===================================== -endOfLine: "cr" -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -.foo { - margin: 42px; -} -=====================================output===================================== -.foo {/*CR*/ margin: 42px;/*CR*/}/*CR*/ -================================================================================ -`; - -exports[`usingCrlf.css 3`] = ` -====================================options===================================== -endOfLine: "crlf" -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -.foo { - margin: 42px; -} -=====================================output===================================== -.foo {/*CR*/ - margin: 42px;/*CR*/ -}/*CR*/ - -================================================================================ -`; - -exports[`usingCrlf.css 4`] = ` -====================================options===================================== -endOfLine: "lf" -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -.foo { - margin: 42px; -} -=====================================output===================================== -.foo { - margin: 42px; -} - -================================================================================ -`; - -exports[`usingLf.css 1`] = ` -====================================options===================================== -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -.foo { - margin: 42px; -} -=====================================output===================================== -.foo { - margin: 42px; -} - -================================================================================ -`; - -exports[`usingLf.css 2`] = ` -====================================options===================================== -endOfLine: "cr" -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -.foo { - margin: 42px; -} -=====================================output===================================== -.foo {/*CR*/ margin: 42px;/*CR*/}/*CR*/ -================================================================================ -`; - -exports[`usingLf.css 3`] = ` -====================================options===================================== -endOfLine: "crlf" -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -.foo { - margin: 42px; -} -=====================================output===================================== -.foo {/*CR*/ - margin: 42px;/*CR*/ -}/*CR*/ - -================================================================================ -`; - -exports[`usingLf.css 4`] = ` -====================================options===================================== -endOfLine: "lf" -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -.foo { - margin: 42px; -} -=====================================output===================================== -.foo { - margin: 42px; -} - -================================================================================ -`; diff --git a/tests/end_of_line_in_css/jsfmt.spec.js b/tests/end_of_line_in_css/jsfmt.spec.js deleted file mode 100644 index 60e474dd..00000000 --- a/tests/end_of_line_in_css/jsfmt.spec.js +++ /dev/null @@ -1,4 +0,0 @@ -run_spec(__dirname, ["css"]); -run_spec(__dirname, ["css"], { endOfLine: "cr" }); -run_spec(__dirname, ["css"], { endOfLine: "crlf" }); -run_spec(__dirname, ["css"], { endOfLine: "lf" }); diff --git a/tests/end_of_line_in_css/usingCrlf.css b/tests/end_of_line_in_css/usingCrlf.css deleted file mode 100644 index f03735f1..00000000 --- a/tests/end_of_line_in_css/usingCrlf.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo { - margin: 42px; -} \ No newline at end of file diff --git a/tests/end_of_line_in_css/usingLf.css b/tests/end_of_line_in_css/usingLf.css deleted file mode 100644 index bba7583e..00000000 --- a/tests/end_of_line_in_css/usingLf.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo { - margin: 42px; -} \ No newline at end of file diff --git a/tests/end_of_line_in_markdown/__snapshots__/jsfmt.spec.js.snap b/tests/end_of_line_in_markdown/__snapshots__/jsfmt.spec.js.snap deleted file mode 100644 index 34f49b50..00000000 --- a/tests/end_of_line_in_markdown/__snapshots__/jsfmt.spec.js.snap +++ /dev/null @@ -1,137 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`usingCrlf.md 1`] = ` -====================================options===================================== -parsers: ["markdown"] -printWidth: 80 - | printWidth -=====================================input====================================== -# Markdown file - -testing line endings -=====================================output===================================== -# Markdown file - -testing line endings - -================================================================================ -`; - -exports[`usingCrlf.md 2`] = ` -====================================options===================================== -endOfLine: "cr" -parsers: ["markdown"] -printWidth: 80 - | printWidth -=====================================input====================================== -# Markdown file - -testing line endings -=====================================output===================================== -# Markdown file/*CR*//*CR*/testing line endings/*CR*/ -================================================================================ -`; - -exports[`usingCrlf.md 3`] = ` -====================================options===================================== -endOfLine: "crlf" -parsers: ["markdown"] -printWidth: 80 - | printWidth -=====================================input====================================== -# Markdown file - -testing line endings -=====================================output===================================== -# Markdown file/*CR*/ -/*CR*/ -testing line endings/*CR*/ - -================================================================================ -`; - -exports[`usingCrlf.md 4`] = ` -====================================options===================================== -endOfLine: "lf" -parsers: ["markdown"] -printWidth: 80 - | printWidth -=====================================input====================================== -# Markdown file - -testing line endings -=====================================output===================================== -# Markdown file - -testing line endings - -================================================================================ -`; - -exports[`usingLf.md 1`] = ` -====================================options===================================== -parsers: ["markdown"] -printWidth: 80 - | printWidth -=====================================input====================================== -# Markdown file - -testing line endings -=====================================output===================================== -# Markdown file - -testing line endings - -================================================================================ -`; - -exports[`usingLf.md 2`] = ` -====================================options===================================== -endOfLine: "cr" -parsers: ["markdown"] -printWidth: 80 - | printWidth -=====================================input====================================== -# Markdown file - -testing line endings -=====================================output===================================== -# Markdown file/*CR*//*CR*/testing line endings/*CR*/ -================================================================================ -`; - -exports[`usingLf.md 3`] = ` -====================================options===================================== -endOfLine: "crlf" -parsers: ["markdown"] -printWidth: 80 - | printWidth -=====================================input====================================== -# Markdown file - -testing line endings -=====================================output===================================== -# Markdown file/*CR*/ -/*CR*/ -testing line endings/*CR*/ - -================================================================================ -`; - -exports[`usingLf.md 4`] = ` -====================================options===================================== -endOfLine: "lf" -parsers: ["markdown"] -printWidth: 80 - | printWidth -=====================================input====================================== -# Markdown file - -testing line endings -=====================================output===================================== -# Markdown file - -testing line endings - -================================================================================ -`; diff --git a/tests/end_of_line_in_markdown/jsfmt.spec.js b/tests/end_of_line_in_markdown/jsfmt.spec.js deleted file mode 100644 index ed518228..00000000 --- a/tests/end_of_line_in_markdown/jsfmt.spec.js +++ /dev/null @@ -1,4 +0,0 @@ -run_spec(__dirname, ["markdown"]); -run_spec(__dirname, ["markdown"], { endOfLine: "cr" }); -run_spec(__dirname, ["markdown"], { endOfLine: "crlf" }); -run_spec(__dirname, ["markdown"], { endOfLine: "lf" }); diff --git a/tests/end_of_line_in_markdown/usingCrlf.md b/tests/end_of_line_in_markdown/usingCrlf.md deleted file mode 100644 index 96f32548..00000000 --- a/tests/end_of_line_in_markdown/usingCrlf.md +++ /dev/null @@ -1,3 +0,0 @@ -# Markdown file - -testing line endings \ No newline at end of file diff --git a/tests/end_of_line_in_markdown/usingLf.md b/tests/end_of_line_in_markdown/usingLf.md deleted file mode 100644 index f1775151..00000000 --- a/tests/end_of_line_in_markdown/usingLf.md +++ /dev/null @@ -1,3 +0,0 @@ -# Markdown file - -testing line endings \ No newline at end of file diff --git a/tests/flow/malformed_code/text.js b/tests/flow/malformed_code/text.js index 76c5bd5d..4ce5e918 100644 --- a/tests/flow/malformed_code/text.js +++ b/tests/flow/malformed_code/text.js @@ -1,6 +1,6 @@ -// @flow -// Example found at -// https://github.com/sebmarkbage/art/blob/51ffce8164a555d652843241c2fdda52e186cbbd/parsers/svg/text.js#L137 -const evil_regex_as_a_string = "/[\s�]*$/"; - -const error: string = 123; // Should be an error, but can't lex this file +// @flow +// Example found at +// https://github.com/sebmarkbage/art/blob/51ffce8164a555d652843241c2fdda52e186cbbd/parsers/svg/text.js#L137 +const evil_regex_as_a_string = "/[\s�]*$/"; + +const error: string = 123; // Should be an error, but can't lex this file diff --git a/tests/interface/break.js b/tests/interface/break.js index b41f69a3..3bf95b1d 100644 --- a/tests/interface/break.js +++ b/tests/interface/break.js @@ -1,66 +1,66 @@ -export interface Environment1 extends GenericEnvironment< - SomeType, - AnotherType, - YetAnotherType, -> { - m(): void; -}; -export class Environment2 extends GenericEnvironment< - SomeType, - AnotherType, - YetAnotherType, - DifferentType1, - DifferentType2, - DifferentType3, - DifferentType4, -> { - m() {}; -}; - -// Declare Interface Break -declare interface ExtendsOne extends ASingleInterface { - x: string; -} - -declare interface ExtendsLarge extends ASingleInterfaceWithAReallyReallyReallyReallyLongName { - x: string; -} - -declare interface ExtendsMany extends Interface1, Interface2, Interface3, Interface4, Interface5, Interface6, Interface7 { - x: string; -} - -// Interface declaration break -interface ExtendsOne extends ASingleInterface { - x: string; -} - -interface ExtendsLarge extends ASingleInterfaceWithAReallyReallyReallyReallyLongName { - x: string; -} - -interface ExtendsMany extends Interface1, Interface2, Interface3, Interface4, Interface5, Interface6, Interface7 { - s: string; -} - -// Generic Types -interface ExtendsOne extends ASingleInterface { - x: string; -} - -interface ExtendsLarge extends ASingleInterfaceWithAReallyReallyReallyReallyLongName { - x: string; -} - -interface ExtendsMany - extends ASingleGenericInterface { - x: string; -} - -interface ExtendsManyWithGenerics - extends InterfaceOne, InterfaceTwo, ASingleGenericInterface, InterfaceThree { - - x: string; - } - -export interface ExtendsLongOneWithGenerics extends Bar< SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, ToBreakLineToBreakLineToBreakLine> {} +export interface Environment1 extends GenericEnvironment< + SomeType, + AnotherType, + YetAnotherType, +> { + m(): void; +}; +export class Environment2 extends GenericEnvironment< + SomeType, + AnotherType, + YetAnotherType, + DifferentType1, + DifferentType2, + DifferentType3, + DifferentType4, +> { + m() {}; +}; + +// Declare Interface Break +declare interface ExtendsOne extends ASingleInterface { + x: string; +} + +declare interface ExtendsLarge extends ASingleInterfaceWithAReallyReallyReallyReallyLongName { + x: string; +} + +declare interface ExtendsMany extends Interface1, Interface2, Interface3, Interface4, Interface5, Interface6, Interface7 { + x: string; +} + +// Interface declaration break +interface ExtendsOne extends ASingleInterface { + x: string; +} + +interface ExtendsLarge extends ASingleInterfaceWithAReallyReallyReallyReallyLongName { + x: string; +} + +interface ExtendsMany extends Interface1, Interface2, Interface3, Interface4, Interface5, Interface6, Interface7 { + s: string; +} + +// Generic Types +interface ExtendsOne extends ASingleInterface { + x: string; +} + +interface ExtendsLarge extends ASingleInterfaceWithAReallyReallyReallyReallyLongName { + x: string; +} + +interface ExtendsMany + extends ASingleGenericInterface { + x: string; +} + +interface ExtendsManyWithGenerics + extends InterfaceOne, InterfaceTwo, ASingleGenericInterface, InterfaceThree { + + x: string; + } + +export interface ExtendsLongOneWithGenerics extends Bar< SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, ToBreakLineToBreakLineToBreakLine> {} diff --git a/tests/jsx-newlines/windows.js b/tests/jsx-newlines/windows.js index 12bf628e..d2b04f35 100644 --- a/tests/jsx-newlines/windows.js +++ b/tests/jsx-newlines/windows.js @@ -1,3 +1,3 @@ -
-Text +
+Text
diff --git a/tests/jsx/expression.js b/tests/jsx/expression.js index ec999447..0232f42f 100644 --- a/tests/jsx/expression.js +++ b/tests/jsx/expression.js @@ -1,131 +1,131 @@ -; - -; - - - {() => ( - - - - )} -; - - - {items.map(item => ( - - - - ))} -; - - - {function() { - return ( - - - - ); - }} -; - -; - - - test - -}/>; - - doLogClick("short", "short", data)} -/>; - - - doLogClick("long_name_long_name_long_name", "long_name_long_name_long_name", data) - } -/>; - - { - doLogClick("long_name_long_name_long_name", "long_name_long_name_long_name", data) - }} -/>; - -, - ) => { - this.setState({ - updatedTask: this.state.updatedTask.set(key, value) - }); - }} -/>; - - - {data => doLogClick("short", "short", data)} -; - - - {data => - doLogClick("long_name_long_name_long_name", "long_name_long_name_long_name", data) - } -; - - - {data => { - doLogClick("long_name_long_name_long_name", "long_name_long_name_long_name", data) - }} -; - - - {( - key: "possible_key_1" | "possible_key_2" | "possible_key_3", - value: string | Immutable.List, - ) => { - this.setState({ - updatedTask: this.state.updatedTask.set(key, value) - }); - }} -; - - -
- {Array(20) - .fill() - .map((_, i) => ( -

{i + 1}

- ))} -
-
; +; + +; + + + {() => ( + + + + )} +; + + + {items.map(item => ( + + + + ))} +; + + + {function() { + return ( + + + + ); + }} +; + +; + + + test + +}/>; + + doLogClick("short", "short", data)} +/>; + + + doLogClick("long_name_long_name_long_name", "long_name_long_name_long_name", data) + } +/>; + + { + doLogClick("long_name_long_name_long_name", "long_name_long_name_long_name", data) + }} +/>; + +, + ) => { + this.setState({ + updatedTask: this.state.updatedTask.set(key, value) + }); + }} +/>; + + + {data => doLogClick("short", "short", data)} +; + + + {data => + doLogClick("long_name_long_name_long_name", "long_name_long_name_long_name", data) + } +; + + + {data => { + doLogClick("long_name_long_name_long_name", "long_name_long_name_long_name", data) + }} +; + + + {( + key: "possible_key_1" | "possible_key_2" | "possible_key_3", + value: string | Immutable.List, + ) => { + this.setState({ + updatedTask: this.state.updatedTask.set(key, value) + }); + }} +; + + +
+ {Array(20) + .fill() + .map((_, i) => ( +

{i + 1}

+ ))} +
+
; diff --git a/tests/line/windows.js b/tests/line/windows.js index 3779d12d..f27f0126 100644 --- a/tests/line/windows.js +++ b/tests/line/windows.js @@ -1,5 +1,5 @@ -const vscode = require("vscode"); -const {getDir, getActiveFile, uint8arrayToString} = require("./utils"); - -let outChannel; -let _commands; +const vscode = require("vscode"); +const {getDir, getActiveFile, uint8arrayToString} = require("./utils"); + +let outChannel; +let _commands; diff --git a/tests/multiparser_vue/lang-ts.vue b/tests/multiparser_vue/lang-ts.vue index c9db0056..091b4fa2 100644 --- a/tests/multiparser_vue/lang-ts.vue +++ b/tests/multiparser_vue/lang-ts.vue @@ -1,10 +1,10 @@ - - - - + + + + diff --git a/tests/multiparser_vue/lang-tsx.vue b/tests/multiparser_vue/lang-tsx.vue index 665cd968..8c34bc87 100644 --- a/tests/multiparser_vue/lang-tsx.vue +++ b/tests/multiparser_vue/lang-tsx.vue @@ -1,7 +1,7 @@ - + diff --git a/tests/quotes/strings.js b/tests/quotes/strings.js index 34c5b921..4b35f3b6 100644 --- a/tests/quotes/strings.js +++ b/tests/quotes/strings.js @@ -58,7 +58,7 @@ 'meaningfully escaped alphabetical characters \n \r \v \t \b \f \u2713 \x61' 'escaped newline \ ' -'escaped carriage return \ +'escaped carriage return \ ' 'escaped \u2028 \
' 'escaped \u2029 \
' diff --git a/tests/typescript/compiler/ClassDeclaration22.ts b/tests/typescript/compiler/ClassDeclaration22.ts index 2579ad49..f4d70988 100644 --- a/tests/typescript/compiler/ClassDeclaration22.ts +++ b/tests/typescript/compiler/ClassDeclaration22.ts @@ -1,4 +1,4 @@ -class C { - "foo"(); - "bar"() { } -} +class C { + "foo"(); + "bar"() { } +} diff --git a/tests/typescript/compiler/castOfAwait.ts b/tests/typescript/compiler/castOfAwait.ts index fcd8f999..86e7d8ff 100644 --- a/tests/typescript/compiler/castOfAwait.ts +++ b/tests/typescript/compiler/castOfAwait.ts @@ -1,8 +1,8 @@ -// @target: es6 -async function f() { - await 0; - typeof await 0; - void await 0; - await void typeof void await 0; - await await 0; -} +// @target: es6 +async function f() { + await 0; + typeof await 0; + void await 0; + await void typeof void await 0; + await await 0; +} diff --git a/tests/typescript/compiler/castParentheses.ts b/tests/typescript/compiler/castParentheses.ts index 18c6fcdd..aefac40d 100644 --- a/tests/typescript/compiler/castParentheses.ts +++ b/tests/typescript/compiler/castParentheses.ts @@ -1,11 +1,11 @@ -class a { - static b: any; -} - -var b = (a); -var b = (a).b; -var b = (a.b).c; -var b = (a.b()).c; -var b = (new a); -var b = (new a.b); -var b = (new a).b +class a { + static b: any; +} + +var b = (a); +var b = (a).b; +var b = (a.b).c; +var b = (a.b()).c; +var b = (new a); +var b = (new a.b); +var b = (new a).b diff --git a/tests/typescript/compiler/castTest.ts b/tests/typescript/compiler/castTest.ts index 87d66daa..4488b389 100644 --- a/tests/typescript/compiler/castTest.ts +++ b/tests/typescript/compiler/castTest.ts @@ -1,30 +1,30 @@ - -var x : any = 0; -var z = x; -var y = x + z; - -var a = 0; -var b = true; -var s = ""; - -var ar = null; - -var f = <(res : number) => void>null; - -declare class Point -{ - x: number; - y: number; - add(dx: number, dy: number): Point; - mult(p: Point): Point; - constructor(x: number, y: number); -} - -var p_cast = ({ - x: 0, - y: 0, - add: function(dx, dy) { - return new Point(this.x + dx, this.y + dy); - }, - mult: function(p) { return p; } -}) + +var x : any = 0; +var z = x; +var y = x + z; + +var a = 0; +var b = true; +var s = ""; + +var ar = null; + +var f = <(res : number) => void>null; + +declare class Point +{ + x: number; + y: number; + add(dx: number, dy: number): Point; + mult(p: Point): Point; + constructor(x: number, y: number); +} + +var p_cast = ({ + x: 0, + y: 0, + add: function(dx, dy) { + return new Point(this.x + dx, this.y + dy); + }, + mult: function(p) { return p; } +}) diff --git a/tests/typescript/compiler/checkInfiniteExpansionTermination.ts b/tests/typescript/compiler/checkInfiniteExpansionTermination.ts index 8514ebce..02fb9025 100644 --- a/tests/typescript/compiler/checkInfiniteExpansionTermination.ts +++ b/tests/typescript/compiler/checkInfiniteExpansionTermination.ts @@ -1,16 +1,16 @@ -// Regression test for #1002 -// Before fix this code would cause infinite loop - -interface IObservable { - n: IObservable; // Needed, must be T[] -} - -// Needed -interface ISubject extends IObservable { } - -interface Foo { x } -interface Bar { y } - -var values: IObservable; -var values2: ISubject; -values = values2; +// Regression test for #1002 +// Before fix this code would cause infinite loop + +interface IObservable { + n: IObservable; // Needed, must be T[] +} + +// Needed +interface ISubject extends IObservable { } + +interface Foo { x } +interface Bar { y } + +var values: IObservable; +var values2: ISubject; +values = values2; diff --git a/tests/typescript/compiler/commentInNamespaceDeclarationWithIdentifierPathName.ts b/tests/typescript/compiler/commentInNamespaceDeclarationWithIdentifierPathName.ts index 5b4dbffe..668ae575 100644 --- a/tests/typescript/compiler/commentInNamespaceDeclarationWithIdentifierPathName.ts +++ b/tests/typescript/compiler/commentInNamespaceDeclarationWithIdentifierPathName.ts @@ -1,4 +1,4 @@ -namespace hello.hi.world -{ - function foo() {} -} +namespace hello.hi.world +{ + function foo() {} +} diff --git a/tests/typescript/compiler/contextualSignatureInstantiation2.ts b/tests/typescript/compiler/contextualSignatureInstantiation2.ts index b9d46af3..ff7f91c9 100644 --- a/tests/typescript/compiler/contextualSignatureInstantiation2.ts +++ b/tests/typescript/compiler/contextualSignatureInstantiation2.ts @@ -1,5 +1,5 @@ -// dot f g x = f(g(x)) -var dot: (f: (_: T) => S) => (g: (_: U) => T) => (_: U) => S; -dot = (f: (_: T) => S) => (g: (_: U) => T): (r:U) => S => (x) => f(g(x)); -var id: (x:T) => T; +// dot f g x = f(g(x)) +var dot: (f: (_: T) => S) => (g: (_: U) => T) => (_: U) => S; +dot = (f: (_: T) => S) => (g: (_: U) => T): (r:U) => S => (x) => f(g(x)); +var id: (x:T) => T; var r23 = dot(id)(id); \ No newline at end of file diff --git a/tests/typescript/compiler/declareDottedModuleName.ts b/tests/typescript/compiler/declareDottedModuleName.ts index 456e22c5..429a63ac 100644 --- a/tests/typescript/compiler/declareDottedModuleName.ts +++ b/tests/typescript/compiler/declareDottedModuleName.ts @@ -1,11 +1,11 @@ -// @declaration: true -module M { - module P.Q { } // This shouldnt be emitted -} - -module M { - export module R.S { } //This should be emitted -} - -module T.U { // This needs to be emitted +// @declaration: true +module M { + module P.Q { } // This shouldnt be emitted +} + +module M { + export module R.S { } //This should be emitted +} + +module T.U { // This needs to be emitted } \ No newline at end of file diff --git a/tests/typescript/compiler/decrementAndIncrementOperators.ts b/tests/typescript/compiler/decrementAndIncrementOperators.ts index a31e5243..c8b34b36 100644 --- a/tests/typescript/compiler/decrementAndIncrementOperators.ts +++ b/tests/typescript/compiler/decrementAndIncrementOperators.ts @@ -1,37 +1,37 @@ -var x = 0; - -// errors -1 ++; - -(1)++; -(1)--; - -++(1); ---(1); - -(1 + 2)++; -(1 + 2)--; - -++(1 + 2); ---(1 + 2); - -(x + x)++; -(x + x)--; - -++(x + x); ---(x + x); - -//OK -x++; -x--; - -++x; ---x; - -(x)++; ---(x); - -((x))++; -((x))--; - -x[x++]++; +var x = 0; + +// errors +1 ++; + +(1)++; +(1)--; + +++(1); +--(1); + +(1 + 2)++; +(1 + 2)--; + +++(1 + 2); +--(1 + 2); + +(x + x)++; +(x + x)--; + +++(x + x); +--(x + x); + +//OK +x++; +x--; + +++x; +--x; + +(x)++; +--(x); + +((x))++; +((x))--; + +x[x++]++; diff --git a/tests/typescript/compiler/errorOnInitializerInInterfaceProperty.ts b/tests/typescript/compiler/errorOnInitializerInInterfaceProperty.ts index ac600103..85413b73 100644 --- a/tests/typescript/compiler/errorOnInitializerInInterfaceProperty.ts +++ b/tests/typescript/compiler/errorOnInitializerInInterfaceProperty.ts @@ -1,3 +1,3 @@ -interface Foo { - bar: number = 5; -} +interface Foo { + bar: number = 5; +} diff --git a/tests/typescript/compiler/es5ExportDefaultClassDeclaration4.ts b/tests/typescript/compiler/es5ExportDefaultClassDeclaration4.ts index 4e8acc50..89059175 100644 --- a/tests/typescript/compiler/es5ExportDefaultClassDeclaration4.ts +++ b/tests/typescript/compiler/es5ExportDefaultClassDeclaration4.ts @@ -1,16 +1,16 @@ -// @target: es5 -// @module: commonjs -// @declaration: true - -declare module "foo" { - export var before: C; - - export default class C { - method(): C; - } - - export var after: C; - - export var t: typeof C; -} - +// @target: es5 +// @module: commonjs +// @declaration: true + +declare module "foo" { + export var before: C; + + export default class C { + method(): C; + } + + export var after: C; + + export var t: typeof C; +} + diff --git a/tests/typescript/compiler/functionOverloadsOnGenericArity1.ts b/tests/typescript/compiler/functionOverloadsOnGenericArity1.ts index 45e8021d..0aebc946 100644 --- a/tests/typescript/compiler/functionOverloadsOnGenericArity1.ts +++ b/tests/typescript/compiler/functionOverloadsOnGenericArity1.ts @@ -1,11 +1,11 @@ -// overloading on arity not allowed -interface C { - f(): string; - f(): string; - - (): string; - (): string; - - new (): string; - new (): string; -} +// overloading on arity not allowed +interface C { + f(): string; + f(): string; + + (): string; + (): string; + + new (): string; + new (): string; +} diff --git a/tests/typescript/compiler/globalIsContextualKeyword.ts b/tests/typescript/compiler/globalIsContextualKeyword.ts index ceae834a..5eeef8ee 100644 --- a/tests/typescript/compiler/globalIsContextualKeyword.ts +++ b/tests/typescript/compiler/globalIsContextualKeyword.ts @@ -1,16 +1,16 @@ -function a() { - let global = 1; -} -function b() { - class global {} -} - -namespace global { -} - -function foo(global: number) { -} - -let obj = { - global: "123" +function a() { + let global = 1; +} +function b() { + class global {} +} + +namespace global { +} + +function foo(global: number) { +} + +let obj = { + global: "123" } \ No newline at end of file diff --git a/tests/typescript/compiler/indexSignatureWithInitializer.ts b/tests/typescript/compiler/indexSignatureWithInitializer.ts index f9a4aafc..2af7a4f2 100644 --- a/tests/typescript/compiler/indexSignatureWithInitializer.ts +++ b/tests/typescript/compiler/indexSignatureWithInitializer.ts @@ -1,8 +1,8 @@ -// These used to be indexers, now they are computed properties -interface I { - [x = '']: string; -} - -class C { - [x = 0]: string +// These used to be indexers, now they are computed properties +interface I { + [x = '']: string; +} + +class C { + [x = 0]: string } \ No newline at end of file diff --git a/tests/typescript/compiler/mappedTypeWithCombinedTypeMappers.ts b/tests/typescript/compiler/mappedTypeWithCombinedTypeMappers.ts index 918edc7a..9ad4f882 100644 --- a/tests/typescript/compiler/mappedTypeWithCombinedTypeMappers.ts +++ b/tests/typescript/compiler/mappedTypeWithCombinedTypeMappers.ts @@ -1,18 +1,18 @@ -// Repro from #13351 - -type Meta = { - [P in keyof T]: { - value: T[P]; - also: A; - readonly children: Meta; - }; -} - -interface Input { - x: string; - y: number; -} - -declare const output: Meta; - -const shouldFail: { important: boolean } = output.x.children; +// Repro from #13351 + +type Meta = { + [P in keyof T]: { + value: T[P]; + also: A; + readonly children: Meta; + }; +} + +interface Input { + x: string; + y: number; +} + +declare const output: Meta; + +const shouldFail: { important: boolean } = output.x.children; diff --git a/tests/typescript/compiler/modifiersOnInterfaceIndexSignature1.ts b/tests/typescript/compiler/modifiersOnInterfaceIndexSignature1.ts index ba5eebbe..212f82bc 100644 --- a/tests/typescript/compiler/modifiersOnInterfaceIndexSignature1.ts +++ b/tests/typescript/compiler/modifiersOnInterfaceIndexSignature1.ts @@ -1,3 +1,3 @@ -interface I { - public [a: string]: number; +interface I { + public [a: string]: number; } \ No newline at end of file diff --git a/tests/typescript/compiler/privacyGloImport.ts b/tests/typescript/compiler/privacyGloImport.ts index 19bf1009..68f62e18 100644 --- a/tests/typescript/compiler/privacyGloImport.ts +++ b/tests/typescript/compiler/privacyGloImport.ts @@ -1,153 +1,153 @@ -//@declaration: true -module m1 { - export module m1_M1_public { - export class c1 { - } - export function f1() { - return new c1; - } - export var v1 = c1; - export var v2: c1; - } - - module m1_M2_private { - export class c1 { - } - export function f1() { - return new c1; - } - export var v1 = c1; - export var v2: c1; - } - - //export declare module "m1_M3_public" { - // export function f1(); - // export class c1 { - // } - // export var v1: { new (): c1; }; - // export var v2: c1; - //} - - //declare module "m1_M4_private" { - // export function f1(); - // export class c1 { - // } - // export var v1: { new (): c1; }; - // export var v2: c1; - //} - - import m1_im1_private = m1_M1_public; - export var m1_im1_private_v1_public = m1_im1_private.c1; - export var m1_im1_private_v2_public = new m1_im1_private.c1(); - export var m1_im1_private_v3_public = m1_im1_private.f1; - export var m1_im1_private_v4_public = m1_im1_private.f1(); - var m1_im1_private_v1_private = m1_im1_private.c1; - var m1_im1_private_v2_private = new m1_im1_private.c1(); - var m1_im1_private_v3_private = m1_im1_private.f1; - var m1_im1_private_v4_private = m1_im1_private.f1(); - - - import m1_im2_private = m1_M2_private; - export var m1_im2_private_v1_public = m1_im2_private.c1; - export var m1_im2_private_v2_public = new m1_im2_private.c1(); - export var m1_im2_private_v3_public = m1_im2_private.f1; - export var m1_im2_private_v4_public = m1_im2_private.f1(); - var m1_im2_private_v1_private = m1_im2_private.c1; - var m1_im2_private_v2_private = new m1_im2_private.c1(); - var m1_im2_private_v3_private = m1_im2_private.f1; - var m1_im2_private_v4_private = m1_im2_private.f1(); - - //import m1_im3_private = require("m1_M3_public"); - //export var m1_im3_private_v1_public = m1_im3_private.c1; - //export var m1_im3_private_v2_public = new m1_im3_private.c1(); - //export var m1_im3_private_v3_public = m1_im3_private.f1; - //export var m1_im3_private_v4_public = m1_im3_private.f1(); - //var m1_im3_private_v1_private = m1_im3_private.c1; - //var m1_im3_private_v2_private = new m1_im3_private.c1(); - //var m1_im3_private_v3_private = m1_im3_private.f1; - //var m1_im3_private_v4_private = m1_im3_private.f1(); - - //import m1_im4_private = require("m1_M4_private"); - //export var m1_im4_private_v1_public = m1_im4_private.c1; - //export var m1_im4_private_v2_public = new m1_im4_private.c1(); - //export var m1_im4_private_v3_public = m1_im4_private.f1; - //export var m1_im4_private_v4_public = m1_im4_private.f1(); - //var m1_im4_private_v1_private = m1_im4_private.c1; - //var m1_im4_private_v2_private = new m1_im4_private.c1(); - //var m1_im4_private_v3_private = m1_im4_private.f1; - //var m1_im4_private_v4_private = m1_im4_private.f1(); - - export import m1_im1_public = m1_M1_public; - export import m1_im2_public = m1_M2_private; - //export import m1_im3_public = require("m1_M3_public"); - //export import m1_im4_public = require("m1_M4_private"); -} - -module glo_M1_public { - export class c1 { - } - export function f1() { - return new c1; - } - export var v1 = c1; - export var v2: c1; -} - -declare module "glo_M2_public" { - export function f1(); - export class c1 { - } - export var v1: { new (): c1; }; - export var v2: c1; -} - -declare module "use_glo_M1_public" { - import use_glo_M1_public = glo_M1_public; - export var use_glo_M1_public_v1_public: { new (): use_glo_M1_public.c1; }; - export var use_glo_M1_public_v2_public: typeof use_glo_M1_public; - export var use_glo_M1_public_v3_public: ()=> use_glo_M1_public.c1; - var use_glo_M1_public_v1_private: { new (): use_glo_M1_public.c1; }; - var use_glo_M1_public_v2_private: typeof use_glo_M1_public; - var use_glo_M1_public_v3_private: () => use_glo_M1_public.c1; - - import use_glo_M2_public = require("glo_M2_public"); - export var use_glo_M2_public_v1_public: { new (): use_glo_M2_public.c1; }; - export var use_glo_M2_public_v2_public: typeof use_glo_M2_public; - export var use_glo_M2_public_v3_public: () => use_glo_M2_public.c1; - var use_glo_M2_public_v1_private: { new (): use_glo_M2_public.c1; }; - var use_glo_M2_public_v2_private: typeof use_glo_M2_public; - var use_glo_M2_public_v3_private: () => use_glo_M2_public.c1; - - module m2 { - //import errorImport = require("glo_M2_public"); - import nonerrorImport = glo_M1_public; - - module m5 { - //import m5_errorImport = require("glo_M2_public"); - import m5_nonerrorImport = glo_M1_public; - } - } -} - -declare module "anotherParseError" { - module m2 { - //declare module "abc" { - //} - } - - module m2 { - //module "abc2" { - //} - } - //module "abc3" { - //} -} - -module m2 { - //import m3 = require("use_glo_M1_public"); - module m4 { - var a = 10; - //import m2 = require("use_glo_M1_public"); - } - +//@declaration: true +module m1 { + export module m1_M1_public { + export class c1 { + } + export function f1() { + return new c1; + } + export var v1 = c1; + export var v2: c1; + } + + module m1_M2_private { + export class c1 { + } + export function f1() { + return new c1; + } + export var v1 = c1; + export var v2: c1; + } + + //export declare module "m1_M3_public" { + // export function f1(); + // export class c1 { + // } + // export var v1: { new (): c1; }; + // export var v2: c1; + //} + + //declare module "m1_M4_private" { + // export function f1(); + // export class c1 { + // } + // export var v1: { new (): c1; }; + // export var v2: c1; + //} + + import m1_im1_private = m1_M1_public; + export var m1_im1_private_v1_public = m1_im1_private.c1; + export var m1_im1_private_v2_public = new m1_im1_private.c1(); + export var m1_im1_private_v3_public = m1_im1_private.f1; + export var m1_im1_private_v4_public = m1_im1_private.f1(); + var m1_im1_private_v1_private = m1_im1_private.c1; + var m1_im1_private_v2_private = new m1_im1_private.c1(); + var m1_im1_private_v3_private = m1_im1_private.f1; + var m1_im1_private_v4_private = m1_im1_private.f1(); + + + import m1_im2_private = m1_M2_private; + export var m1_im2_private_v1_public = m1_im2_private.c1; + export var m1_im2_private_v2_public = new m1_im2_private.c1(); + export var m1_im2_private_v3_public = m1_im2_private.f1; + export var m1_im2_private_v4_public = m1_im2_private.f1(); + var m1_im2_private_v1_private = m1_im2_private.c1; + var m1_im2_private_v2_private = new m1_im2_private.c1(); + var m1_im2_private_v3_private = m1_im2_private.f1; + var m1_im2_private_v4_private = m1_im2_private.f1(); + + //import m1_im3_private = require("m1_M3_public"); + //export var m1_im3_private_v1_public = m1_im3_private.c1; + //export var m1_im3_private_v2_public = new m1_im3_private.c1(); + //export var m1_im3_private_v3_public = m1_im3_private.f1; + //export var m1_im3_private_v4_public = m1_im3_private.f1(); + //var m1_im3_private_v1_private = m1_im3_private.c1; + //var m1_im3_private_v2_private = new m1_im3_private.c1(); + //var m1_im3_private_v3_private = m1_im3_private.f1; + //var m1_im3_private_v4_private = m1_im3_private.f1(); + + //import m1_im4_private = require("m1_M4_private"); + //export var m1_im4_private_v1_public = m1_im4_private.c1; + //export var m1_im4_private_v2_public = new m1_im4_private.c1(); + //export var m1_im4_private_v3_public = m1_im4_private.f1; + //export var m1_im4_private_v4_public = m1_im4_private.f1(); + //var m1_im4_private_v1_private = m1_im4_private.c1; + //var m1_im4_private_v2_private = new m1_im4_private.c1(); + //var m1_im4_private_v3_private = m1_im4_private.f1; + //var m1_im4_private_v4_private = m1_im4_private.f1(); + + export import m1_im1_public = m1_M1_public; + export import m1_im2_public = m1_M2_private; + //export import m1_im3_public = require("m1_M3_public"); + //export import m1_im4_public = require("m1_M4_private"); +} + +module glo_M1_public { + export class c1 { + } + export function f1() { + return new c1; + } + export var v1 = c1; + export var v2: c1; +} + +declare module "glo_M2_public" { + export function f1(); + export class c1 { + } + export var v1: { new (): c1; }; + export var v2: c1; +} + +declare module "use_glo_M1_public" { + import use_glo_M1_public = glo_M1_public; + export var use_glo_M1_public_v1_public: { new (): use_glo_M1_public.c1; }; + export var use_glo_M1_public_v2_public: typeof use_glo_M1_public; + export var use_glo_M1_public_v3_public: ()=> use_glo_M1_public.c1; + var use_glo_M1_public_v1_private: { new (): use_glo_M1_public.c1; }; + var use_glo_M1_public_v2_private: typeof use_glo_M1_public; + var use_glo_M1_public_v3_private: () => use_glo_M1_public.c1; + + import use_glo_M2_public = require("glo_M2_public"); + export var use_glo_M2_public_v1_public: { new (): use_glo_M2_public.c1; }; + export var use_glo_M2_public_v2_public: typeof use_glo_M2_public; + export var use_glo_M2_public_v3_public: () => use_glo_M2_public.c1; + var use_glo_M2_public_v1_private: { new (): use_glo_M2_public.c1; }; + var use_glo_M2_public_v2_private: typeof use_glo_M2_public; + var use_glo_M2_public_v3_private: () => use_glo_M2_public.c1; + + module m2 { + //import errorImport = require("glo_M2_public"); + import nonerrorImport = glo_M1_public; + + module m5 { + //import m5_errorImport = require("glo_M2_public"); + import m5_nonerrorImport = glo_M1_public; + } + } +} + +declare module "anotherParseError" { + module m2 { + //declare module "abc" { + //} + } + + module m2 { + //module "abc2" { + //} + } + //module "abc3" { + //} +} + +module m2 { + //import m3 = require("use_glo_M1_public"); + module m4 { + var a = 10; + //import m2 = require("use_glo_M1_public"); + } + } \ No newline at end of file diff --git a/tests/typescript/conformance/ambient/ambientDeclarations.ts b/tests/typescript/conformance/ambient/ambientDeclarations.ts index 9cc2cf20..5c1d333c 100644 --- a/tests/typescript/conformance/ambient/ambientDeclarations.ts +++ b/tests/typescript/conformance/ambient/ambientDeclarations.ts @@ -1,26 +1,26 @@ -declare var n; - -declare var m: string; - -declare function fn1(); - -declare function fn2(n: string): number; - -declare function fn3(n: string): number; -declare function fn4(n: number, y: number): string; - -declare function fn5(x, y?); -declare function fn6(e?); -declare function fn7(x, y?, ...z); -declare function fn8(y?, ...z: number[]); -declare function fn9(...q: {}[]); -declare function fn10(...q: T[]); - -declare class cls { - constructor(); - method(): cls; - static static(p): number; - static q; - private fn(); - private static fns(); -} +declare var n; + +declare var m: string; + +declare function fn1(); + +declare function fn2(n: string): number; + +declare function fn3(n: string): number; +declare function fn4(n: number, y: number): string; + +declare function fn5(x, y?); +declare function fn6(e?); +declare function fn7(x, y?, ...z); +declare function fn8(y?, ...z: number[]); +declare function fn9(...q: {}[]); +declare function fn10(...q: T[]); + +declare class cls { + constructor(); + method(): cls; + static static(p): number; + static q; + private fn(); + private static fns(); +} diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAccessor.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAccessor.ts index 50accd4d..dce14fb3 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAccessor.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAccessor.ts @@ -1,7 +1,7 @@ - -abstract class A { - abstract get a(); - abstract get aa() { return 1; } - abstract set b(x: string); - abstract set bb(x: string) {} -} + +abstract class A { + abstract get a(); + abstract get aa() { return 1; } + abstract set b(x: string); + abstract set bb(x: string) {} +} diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts index 4c251a03..82e4c40c 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts @@ -1,5 +1,5 @@ -class abstract { - foo() { return 1; } -} - +class abstract { + foo() { return 1; } +} + new abstract; \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAssignabilityConstructorFunction.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAssignabilityConstructorFunction.ts index 05393a59..855f77e0 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAssignabilityConstructorFunction.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAssignabilityConstructorFunction.ts @@ -1,6 +1,6 @@ -abstract class A { } - -var AAA: new() => A; - -AAA = A; +abstract class A { } + +var AAA: new() => A; + +AAA = A; AAA = "asdf"; \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractClinterfaceAssignability.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractClinterfaceAssignability.ts index 3eeb5ec2..b134269d 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractClinterfaceAssignability.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractClinterfaceAssignability.ts @@ -1,13 +1,13 @@ - -var I: IConstructor; - -abstract class A { - x: number; - static y: number; -} - -var AA: typeof A; -AA = I; - -var AAA: typeof I; + +var I: IConstructor; + +abstract class A { + x: number; + static y: number; +} + +var AA: typeof A; +AA = I; + +var AAA: typeof I; AAA = A; \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructorAssignability.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructorAssignability.ts index ecef21cc..e0dd3839 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructorAssignability.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructorAssignability.ts @@ -1,14 +1,14 @@ - -class A {} - -abstract class B extends A {} - -class C extends B {} - -var AA : typeof A = B; -var BB : typeof B = A; -var CC : typeof C = B; - -new AA; -new BB; + +class A {} + +abstract class B extends A {} + +class C extends B {} + +var AA : typeof A = B; +var BB : typeof B = A; +var CC : typeof C = B; + +new AA; +new BB; new CC; \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts index a8a604b3..d743ab4f 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts @@ -1,9 +1,9 @@ -abstract class foo { - protected abstract test(); -} - -class bar extends foo { - test() { - } -} +abstract class foo { + protected abstract test(); +} + +class bar extends foo { + test() { + } +} var x = new bar(); \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractExtends.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractExtends.ts index 0aa57b75..9c21256e 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractExtends.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractExtends.ts @@ -1,16 +1,16 @@ - -class A { - foo() {} -} - -abstract class B extends A { - abstract bar(); -} - -class C extends B { } - -abstract class D extends B {} - -class E extends B { - bar() {} + +class A { + foo() {} +} + +abstract class B extends A { + abstract bar(); +} + +class C extends B { } + +abstract class D extends B {} + +class E extends B { + bar() {} } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractFactoryFunction.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractFactoryFunction.ts index 73d33a34..cd11a020 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractFactoryFunction.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractFactoryFunction.ts @@ -1,17 +1,17 @@ - -class A {} -abstract class B extends A {} - -function NewA(Factory: typeof A) { - return new A; -} - -function NewB(Factory: typeof B) { - return new B; -} - -NewA(A); -NewA(B); - -NewB(A); + +class A {} +abstract class B extends A {} + +function NewA(Factory: typeof A) { + return new A; +} + +function NewB(Factory: typeof B) { + return new B; +} + +NewA(A); +NewA(B); + +NewB(A); NewB(B); \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts index a6069de9..45f36153 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts @@ -1,25 +1,25 @@ -abstract class A { - t: T; - - abstract foo(): T; - abstract bar(t: T); -} - -abstract class B extends A {} - -class C extends A {} - -class D extends A {} - -class E extends A { - foo() { return this.t; } -} - -class F extends A { - bar(t : T) {} -} - -class G extends A { - foo() { return this.t; } - bar(t: T) { } +abstract class A { + t: T; + + abstract foo(): T; + abstract bar(t: T); +} + +abstract class B extends A {} + +class C extends A {} + +class D extends A {} + +class E extends A { + foo() { return this.t; } +} + +class F extends A { + bar(t : T) {} +} + +class G extends A { + foo() { return this.t; } + bar(t: T) { } } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts index a9288607..e7c76523 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts @@ -1,7 +1,7 @@ - -export abstract class A {} - -new A; - - -new myA; + +export abstract class A {} + +new A; + + +new myA; diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts index 5a93dbf7..41b0e0d6 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts @@ -1,7 +1,7 @@ - -export abstract class A {} -export class B extends A {} - - -new M.A; + +export abstract class A {} +export class B extends A {} + + +new M.A; new M.B; \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts index ced15607..47f56d79 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts @@ -1,21 +1,21 @@ -abstract class A {} - -abstract class B extends A {} - -class C extends A {} - -abstract class AA { - abstract foo(); -} - -abstract class BB extends AA {} - -class CC extends AA {} - -class DD extends BB {} - -abstract class EE extends BB {} - -class FF extends CC {} - +abstract class A {} + +abstract class B extends A {} + +class C extends A {} + +abstract class AA { + abstract foo(); +} + +abstract class BB extends AA {} + +class CC extends AA {} + +class DD extends BB {} + +abstract class EE extends BB {} + +class FF extends CC {} + abstract class GG extends CC {} \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts index 7338c514..c2d7d6c7 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts @@ -1,19 +1,19 @@ - -abstract class A {} - -class B extends A {} - -abstract class C extends B {} - -new A; -new A(1); -new B; -new C; - -var a : A; -var b : B; -var c : C; - -a = new B; -b = new B; -c = new B; + +abstract class A {} + +class B extends A {} + +abstract class C extends B {} + +new A; +new A(1); +new B; +new C; + +var a : A; +var b : B; +var c : C; + +a = new B; +b = new B; +c = new B; diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts index aeea24e8..ebb5e9eb 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts @@ -1,50 +1,50 @@ -class A { -} - -abstract class B { - foo(): number { return this.bar(); } - abstract bar() : number; -} - -new B; - -var BB: typeof B = B; -var AA: typeof A = BB; -new AA; - -function constructB(Factory : typeof B) { - new Factory; -} - -var BB = B; -new BB; - -var x : any = C; -new x; - -class C extends B { } - -abstract class D extends B { } - -class E extends B { - bar() { return 1; } -} - -abstract class F extends B { - abstract foo() : number; - bar() { return 2; } -} - -abstract class G { - abstract qux(x : number) : string; - abstract qux() : number; - y : number; - abstract quz(x : number, y : string) : boolean; - - abstract nom(): boolean; - nom(x : number): boolean; -} - -class H { - abstract baz() : number; +class A { +} + +abstract class B { + foo(): number { return this.bar(); } + abstract bar() : number; +} + +new B; + +var BB: typeof B = B; +var AA: typeof A = BB; +new AA; + +function constructB(Factory : typeof B) { + new Factory; +} + +var BB = B; +new BB; + +var x : any = C; +new x; + +class C extends B { } + +abstract class D extends B { } + +class E extends B { + bar() { return 1; } +} + +abstract class F extends B { + abstract foo() : number; + bar() { return 2; } +} + +abstract class G { + abstract qux(x : number) : string; + abstract qux() : number; + y : number; + abstract quz(x : number, y : string) : boolean; + + abstract nom(): boolean; + nom(x : number): boolean; +} + +class H { + abstract baz() : number; } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts index 98a2091b..68d0f560 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts @@ -1,7 +1,7 @@ -class A { - abstract foo(); -} - -class B { - abstract foo() {} +class A { + abstract foo(); +} + +class B { + abstract foo() {} } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts index 432613ca..8d0f6d23 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts @@ -1,3 +1,3 @@ -abstract class A { - abstract foo() {} +abstract class A { + abstract foo() {} } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts index d3c2546a..e813cabd 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts @@ -1,15 +1,15 @@ -abstract class A { - abstract foo_a(); - - public abstract foo_b(); - protected abstract foo_c(); - private abstract foo_d(); - - abstract public foo_bb(); - abstract protected foo_cc(); - abstract private foo_dd(); - - abstract static foo_d(); - - static abstract foo_e(); +abstract class A { + abstract foo_a(); + + public abstract foo_b(); + protected abstract foo_c(); + private abstract foo_d(); + + abstract public foo_bb(); + abstract protected foo_cc(); + abstract private foo_dd(); + + abstract static foo_d(); + + static abstract foo_e(); } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts index c30a03f8..91b90df8 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts @@ -1,24 +1,24 @@ -abstract class A { - abstract foo(); - abstract foo() : number; - abstract foo(); - - abstract bar(); - bar(); - abstract bar(); - - abstract baz(); - baz(); - abstract baz(); - baz() {} - - qux(); -} - -abstract class B { - abstract foo() : number; - abstract foo(); - x : number; - abstract foo(); - abstract foo(); +abstract class A { + abstract foo(); + abstract foo() : number; + abstract foo(); + + abstract bar(); + bar(); + abstract bar(); + + abstract baz(); + baz(); + abstract baz(); + baz() {} + + qux(); +} + +abstract class B { + abstract foo() : number; + abstract foo(); + x : number; + abstract foo(); + abstract foo(); } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverrideWithAbstract.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverrideWithAbstract.ts index 6c69e5df..9ddcec5c 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverrideWithAbstract.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverrideWithAbstract.ts @@ -1,23 +1,23 @@ -class A { - foo() {} -} - -abstract class B extends A { - abstract foo(); -} - -abstract class AA { - foo() {} - abstract bar(); -} - -abstract class BB extends AA { - abstract foo(); - bar () {} -} - -class CC extends BB {} - -class DD extends BB { - foo() {} +class A { + foo() {} +} + +abstract class B extends A { + abstract foo(); +} + +abstract class AA { + foo() {} + abstract bar(); +} + +abstract class BB extends AA { + abstract foo(); + bar () {} +} + +class CC extends BB {} + +class DD extends BB { + foo() {} } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts index e6dc355a..d7287189 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts @@ -1,13 +1,13 @@ -abstract class A { - abstract x : number; - public abstract y : number; - protected abstract z : number; - private abstract w : number; - - abstract m: () => void; - - abstract foo_x() : number; - public abstract foo_y() : number; - protected abstract foo_z() : number; - private abstract foo_w() : number; +abstract class A { + abstract x : number; + public abstract y : number; + protected abstract z : number; + private abstract w : number; + + abstract m: () => void; + + abstract foo_x() : number; + public abstract foo_y() : number; + protected abstract foo_z() : number; + private abstract foo_w() : number; } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSingleLineDecl.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSingleLineDecl.ts index 374a3c08..df2879a8 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSingleLineDecl.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSingleLineDecl.ts @@ -1,12 +1,12 @@ -abstract class A {} - -abstract -class B {} - -abstract - -class C {} - -new A; -new B; +abstract class A {} + +abstract +class B {} + +abstract + +class C {} + +new A; +new B; new C; \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts index 2bad576e..b5392677 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts @@ -1,25 +1,25 @@ - -class A { - foo() { return 1; } -} - -abstract class B extends A { - abstract foo(); - bar() { super.foo(); } - baz() { return this.foo; } -} - -class C extends B { - foo() { return 2; } - qux() { return super.foo() || super.foo; } - norf() { return super.bar(); } -} - -class AA { - foo() { return 1; } - bar() { return this.foo(); } -} - -abstract class BB extends AA { - abstract foo(); -} + +class A { + foo() { return 1; } +} + +abstract class B extends A { + abstract foo(); + bar() { super.foo(); } + baz() { return this.foo; } +} + +class C extends B { + foo() { return 2; } + qux() { return super.foo() || super.foo; } + norf() { return super.bar(); } +} + +class AA { + foo() { return 1; } + bar() { return this.foo(); } +} + +abstract class BB extends AA { + abstract foo(); +} diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts index 015ded7a..d8a7ca2a 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts @@ -1,17 +1,17 @@ -abstract class A { - abstract foo() : number; -} - -class B extends A { - foo() { return 1; } -} - -abstract class C extends A { - abstract foo() : number; -} - -var a = new B; -a.foo(); - -a = new C; +abstract class A { + abstract foo() : number; +} + +class B extends A { + foo() { return 1; } +} + +abstract class C extends A { + abstract foo() : number; +} + +var a = new B; +a.foo(); + +a = new C; a.foo(); \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts index e333811c..337bfe09 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts @@ -1,27 +1,27 @@ -class A { - abstract foo(); -} - -class B extends A {} - -abstract class C extends A {} - -class D extends A { - foo() {} -} - -abstract class E extends A { - foo() {} -} - -abstract class AA { - abstract foo(); -} - -class BB extends AA {} - -abstract class CC extends AA {} - -class DD extends AA { - foo() {} +class A { + abstract foo(); +} + +class B extends A {} + +abstract class C extends A {} + +class D extends A { + foo() {} +} + +abstract class E extends A { + foo() {} +} + +abstract class AA { + abstract foo(); +} + +class BB extends AA {} + +abstract class CC extends AA {} + +class DD extends AA { + foo() {} } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classHeritageSpecification/classAppearsToHaveMembersOfObject.ts b/tests/typescript/conformance/classes/classDeclarations/classHeritageSpecification/classAppearsToHaveMembersOfObject.ts index 38d3a6df..b9bd475e 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classHeritageSpecification/classAppearsToHaveMembersOfObject.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classHeritageSpecification/classAppearsToHaveMembersOfObject.ts @@ -1,7 +1,7 @@ -class C { foo: string; } - -var c: C; -var r = c.toString(); -var r2 = c.hasOwnProperty(''); -var o: Object = c; -var o2: {} = c; +class C { foo: string; } + +var c: C; +var r = c.toString(); +var r2 = c.hasOwnProperty(''); +var o: Object = c; +var o2: {} = c; diff --git a/tests/typescript/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingClass.ts b/tests/typescript/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingClass.ts index 3e3faa7e..f6057685 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingClass.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingClass.ts @@ -1,31 +1,31 @@ -class C { - foo: string; - thing() { } - static other() { } -} - -class D extends C { - bar: string; -} - -var d: D; -var r = d.foo; -var r2 = d.bar; -var r3 = d.thing(); -var r4 = D.other(); - -class C2 { - foo: T; - thing(x: T) { } - static other(x: T) { } -} - -class D2 extends C2 { - bar: string; -} - -var d2: D2; -var r5 = d2.foo; -var r6 = d2.bar; -var r7 = d2.thing(''); +class C { + foo: string; + thing() { } + static other() { } +} + +class D extends C { + bar: string; +} + +var d: D; +var r = d.foo; +var r2 = d.bar; +var r3 = d.thing(); +var r4 = D.other(); + +class C2 { + foo: T; + thing(x: T) { } + static other(x: T) { } +} + +class D2 extends C2 { + bar: string; +} + +var d2: D2; +var r5 = d2.foo; +var r6 = d2.bar; +var r7 = d2.thing(''); var r8 = D2.other(1); \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts b/tests/typescript/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts index 92b089c0..fe87fbf3 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts @@ -1,11 +1,11 @@ -class C extends E { foo: string; } // error - -class D extends C { bar: string; } - -class E extends D { baz: number; } - -class C2 extends E2 { foo: T; } // error - -class D2 extends C2 { bar: T; } - +class C extends E { foo: string; } // error + +class D extends C { bar: string; } + +class E extends D { baz: number; } + +class C2 extends E2 { foo: T; } // error + +class D2 extends C2 { bar: T; } + class E2 extends D2 { baz: T; } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts b/tests/typescript/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts index 1f88eec4..f59da9ee 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts @@ -1,7 +1,7 @@ -class Base { - foo: T; -} - -class Derived extends Base { - foo: any; -} +class Base { + foo: T; +} + +class Derived extends Base { + foo: any; +} diff --git a/tests/typescript/conformance/classes/classDeclarations/classInsideBlock.ts b/tests/typescript/conformance/classes/classDeclarations/classInsideBlock.ts index efc3ccff..c2957044 100644 --- a/tests/typescript/conformance/classes/classDeclarations/classInsideBlock.ts +++ b/tests/typescript/conformance/classes/classDeclarations/classInsideBlock.ts @@ -1,3 +1,3 @@ -function foo() { - class C { } +function foo() { + class C { } } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/classExpression.ts b/tests/typescript/conformance/classes/classExpression.ts index d10591bd..c1046d94 100644 --- a/tests/typescript/conformance/classes/classExpression.ts +++ b/tests/typescript/conformance/classes/classExpression.ts @@ -1,10 +1,10 @@ -var x = class C { -} - -var y = { - foo: class C2 { - } -} - -var z = class C4 { -} +var x = class C { +} + +var y = { + foo: class C2 { + } +} + +var z = class C4 { +} diff --git a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorDefaultValuesReferencingThis.ts b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorDefaultValuesReferencingThis.ts index 9209dcd7..bec1b484 100644 --- a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorDefaultValuesReferencingThis.ts +++ b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorDefaultValuesReferencingThis.ts @@ -1,11 +1,11 @@ -class C { - constructor(x = this) { } -} - -class D { - constructor(x = this) { } -} - -class E { - constructor(public x = this) { } +class C { + constructor(x = this) { } +} + +class D { + constructor(x = this) { } +} + +class E { + constructor(public x = this) { } } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues.ts b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues.ts index bdbcd7f9..8c812cfd 100644 --- a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues.ts +++ b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues.ts @@ -1,20 +1,20 @@ -class C { - constructor(x); - constructor(x = 1) { - var y = x; - } -} - -class D { - constructor(x); - constructor(x:T = null) { - var y = x; - } -} - -class E { - constructor(x); - constructor(x: T = null) { - var y = x; - } +class C { + constructor(x); + constructor(x = 1) { + var y = x; + } +} + +class D { + constructor(x); + constructor(x:T = null) { + var y = x; + } +} + +class E { + constructor(x); + constructor(x: T = null) { + var y = x; + } } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts index 6e717ffc..0f0d30e1 100644 --- a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts +++ b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts @@ -1,20 +1,20 @@ -class C { - constructor(x); - constructor(public x: string = 1) { - var y = x; - } -} - -class D { - constructor(x: T, y: U); - constructor(x: T = 1, public y: U = x) { - var z = x; - } -} - -class E { - constructor(x); - constructor(x: T = new Date()) { - var y = x; - } +class C { + constructor(x); + constructor(public x: string = 1) { + var y = x; + } +} + +class D { + constructor(x: T, y: U); + constructor(x: T = 1, public y: U = x) { + var z = x; + } +} + +class E { + constructor(x); + constructor(x: T = new Date()) { + var y = x; + } } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorOverloadsWithDefaultValues.ts b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorOverloadsWithDefaultValues.ts index c2c3facf..1aebfcf1 100644 --- a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorOverloadsWithDefaultValues.ts +++ b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorOverloadsWithDefaultValues.ts @@ -1,13 +1,13 @@ -class C { - foo: string; - constructor(x = 1); - constructor() { - } -} - -class D { - foo: string; - constructor(x = 1); - constructor() { - } +class C { + foo: string; + constructor(x = 1); + constructor() { + } +} + +class D { + foo: string; + constructor(x = 1); + constructor() { + } } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorOverloadsWithOptionalParameters.ts b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorOverloadsWithOptionalParameters.ts index 3ec148a9..216b9a2a 100644 --- a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorOverloadsWithOptionalParameters.ts +++ b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorOverloadsWithOptionalParameters.ts @@ -1,13 +1,13 @@ -class C { - foo: string; - constructor(x?, y?: any[]); - constructor() { - } -} - -class D { - foo: string; - constructor(x?, y?: any[]); - constructor() { - } +class C { + foo: string; + constructor(x?, y?: any[]); + constructor() { + } +} + +class D { + foo: string; + constructor(x?, y?: any[]); + constructor() { + } } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts index f4d63da1..989b0f21 100644 --- a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts +++ b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts @@ -1,20 +1,20 @@ -class C { - y: string; - constructor(private x: string, protected z: string) { } -} - -var c: C; -var r = c.y; -var r2 = c.x; // error -var r3 = c.z; // error - -class D { - y: T; - constructor(a: T, private x: T, protected z: T) { } -} - -var d: D; -var r = d.y; -var r2 = d.x; // error -var r3 = d.a; // error -var r4 = d.z; // error +class C { + y: string; + constructor(private x: string, protected z: string) { } +} + +var c: C; +var r = c.y; +var r2 = c.x; // error +var r3 = c.z; // error + +class D { + y: T; + constructor(a: T, private x: T, protected z: T) { } +} + +var d: D; +var r = d.y; +var r2 = d.x; // error +var r3 = d.a; // error +var r4 = d.z; // error diff --git a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts index 687b47b8..4339f48a 100644 --- a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts +++ b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts @@ -1,31 +1,31 @@ -class C { - y: number; - constructor(y: number) { } // ok -} - -var c: C; -var r = c.y; - -class D { - y: number; - constructor(public y: number) { } -} - -var d: D; -var r2 = d.y; - -class E { - y: number; - constructor(private y: number) { } -} - -var e: E; -var r3 = e.y; // error - -class F { - y: number; - constructor(protected y: number) { } -} - -var f: F; -var r4 = f.y; // error +class C { + y: number; + constructor(y: number) { } // ok +} + +var c: C; +var r = c.y; + +class D { + y: number; + constructor(public y: number) { } +} + +var d: D; +var r2 = d.y; + +class E { + y: number; + constructor(private y: number) { } +} + +var e: E; +var r3 = e.y; // error + +class F { + y: number; + constructor(protected y: number) { } +} + +var f: F; +var r4 = f.y; // error diff --git a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/declarationEmitReadonly.ts b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/declarationEmitReadonly.ts index 76b41eab..8f056447 100644 --- a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/declarationEmitReadonly.ts +++ b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/declarationEmitReadonly.ts @@ -1,5 +1,5 @@ -// @declaration: true - -class C { - constructor(readonly x: number) {} +// @declaration: true + +class C { + constructor(readonly x: number) {} } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/readonlyConstructorAssignment.ts b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/readonlyConstructorAssignment.ts index aeecf085..93cc7121 100644 --- a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/readonlyConstructorAssignment.ts +++ b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/readonlyConstructorAssignment.ts @@ -1,38 +1,38 @@ -// Tests that readonly parameter properties behave like regular readonly properties - -class A { - constructor(readonly x: number) { - this.x = 0; - } -} - -class B extends A { - constructor(x: number) { - super(x); - // Fails, x is readonly - this.x = 1; - } -} - -class C extends A { - // This is the usual behavior of readonly properties: - // if one is redeclared in a base class, then it can be assigned to. - constructor(readonly x: number) { - super(x); - this.x = 1; - } -} - -class D { - constructor(private readonly x: number) { - this.x = 0; - } -} - -// Fails, can't redeclare readonly property -class E extends D { - constructor(readonly x: number) { - super(x); - this.x = 1; - } -} +// Tests that readonly parameter properties behave like regular readonly properties + +class A { + constructor(readonly x: number) { + this.x = 0; + } +} + +class B extends A { + constructor(x: number) { + super(x); + // Fails, x is readonly + this.x = 1; + } +} + +class C extends A { + // This is the usual behavior of readonly properties: + // if one is redeclared in a base class, then it can be assigned to. + constructor(readonly x: number) { + super(x); + this.x = 1; + } +} + +class D { + constructor(private readonly x: number) { + this.x = 0; + } +} + +// Fails, can't redeclare readonly property +class E extends D { + constructor(readonly x: number) { + super(x); + this.x = 1; + } +} diff --git a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/readonlyInConstructorParameters.ts b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/readonlyInConstructorParameters.ts index dbcdff7a..d625d14a 100644 --- a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/readonlyInConstructorParameters.ts +++ b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/readonlyInConstructorParameters.ts @@ -1,13 +1,13 @@ -class C { - constructor(readonly x: number) {} -} -new C(1).x = 2; - -class E { - constructor(readonly public x: number) {} -} - -class F { - constructor(private readonly x: number) {} -} +class C { + constructor(readonly x: number) {} +} +new C(1).x = 2; + +class E { + constructor(readonly public x: number) {} +} + +class F { + constructor(private readonly x: number) {} +} new F(1).x; \ No newline at end of file diff --git a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/readonlyReadonly.ts b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/readonlyReadonly.ts index 8fb611a0..727754f0 100644 --- a/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/readonlyReadonly.ts +++ b/tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/readonlyReadonly.ts @@ -1,4 +1,4 @@ -class C { - readonly readonly x: number; - constructor(readonly readonly y: number) {} +class C { + readonly readonly x: number; + constructor(readonly readonly y: number) {} } \ No newline at end of file diff --git a/tests/typescript/conformance/classes/nestedClassDeclaration.ts b/tests/typescript/conformance/classes/nestedClassDeclaration.ts index a6907f84..8537e77a 100644 --- a/tests/typescript/conformance/classes/nestedClassDeclaration.ts +++ b/tests/typescript/conformance/classes/nestedClassDeclaration.ts @@ -1,10 +1,10 @@ -// nested classes are not allowed - -class C { - x: string; -} - -function foo() { - class C3 { - } -} +// nested classes are not allowed + +class C { + x: string; +} + +function foo() { + class C3 { + } +} diff --git a/tests/typescript/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName01.ts b/tests/typescript/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName01.ts index 461c7d17..5a211fae 100644 --- a/tests/typescript/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName01.ts +++ b/tests/typescript/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName01.ts @@ -1,11 +1,11 @@ -// @declaration: true -// @module: commonjs - -export class C { - m(): this is D { - return this instanceof D; - } -} - -class D extends C { +// @declaration: true +// @module: commonjs + +export class C { + m(): this is D { + return this instanceof D; + } +} + +class D extends C { } \ No newline at end of file diff --git a/tests/typescript/conformance/es6/Symbols/symbolProperty15.ts b/tests/typescript/conformance/es6/Symbols/symbolProperty15.ts index 3ec6c6ec..3c226c1a 100644 --- a/tests/typescript/conformance/es6/Symbols/symbolProperty15.ts +++ b/tests/typescript/conformance/es6/Symbols/symbolProperty15.ts @@ -1,15 +1,15 @@ -//@target: ES6 -class C { } -interface I { - [Symbol.iterator]?: { x }; -} - -declare function foo(i: I): I; -declare function foo(a: any): any; - -declare function bar(i: C): C; -declare function bar(a: any): any; - -foo(new C); -var i: I; +//@target: ES6 +class C { } +interface I { + [Symbol.iterator]?: { x }; +} + +declare function foo(i: I): I; +declare function foo(a: any): any; + +declare function bar(i: C): C; +declare function bar(a: any): any; + +foo(new C); +var i: I; bar(i); \ No newline at end of file diff --git a/tests/typescript/conformance/es6/templates/templateStringWithEmbeddedTypeAssertionOnAdditionES6.ts b/tests/typescript/conformance/es6/templates/templateStringWithEmbeddedTypeAssertionOnAdditionES6.ts index 2a6d8446..4ac0ca5f 100644 --- a/tests/typescript/conformance/es6/templates/templateStringWithEmbeddedTypeAssertionOnAdditionES6.ts +++ b/tests/typescript/conformance/es6/templates/templateStringWithEmbeddedTypeAssertionOnAdditionES6.ts @@ -1,2 +1,2 @@ -// @target: ES6 -var x = `abc${ (10 + 10) }def`; +// @target: ES6 +var x = `abc${ (10 + 10) }def`; diff --git a/tests/typescript/conformance/expressions/asOperator/asOperatorContextualType.ts b/tests/typescript/conformance/expressions/asOperator/asOperatorContextualType.ts index 9c30f2b7..6a632e30 100644 --- a/tests/typescript/conformance/expressions/asOperator/asOperatorContextualType.ts +++ b/tests/typescript/conformance/expressions/asOperator/asOperatorContextualType.ts @@ -1,2 +1,2 @@ -// should error -var x = (v => v) as (x: number) => string; +// should error +var x = (v => v) as (x: number) => string; diff --git a/tests/typescript/conformance/expressions/functionCalls/callWithSpreadES6.ts b/tests/typescript/conformance/expressions/functionCalls/callWithSpreadES6.ts index accb6df1..5449c58b 100644 --- a/tests/typescript/conformance/expressions/functionCalls/callWithSpreadES6.ts +++ b/tests/typescript/conformance/expressions/functionCalls/callWithSpreadES6.ts @@ -1,51 +1,51 @@ -// @target: ES6 - -interface X { - foo(x: number, y: number, ...z: string[]); -} - -function foo(x: number, y: number, ...z: string[]) { -} - -var a: string[]; -var z: number[]; -var obj: X; -var xa: X[]; - -foo(1, 2, "abc"); -foo(1, 2, ...a); -foo(1, 2, ...a, "abc"); - -obj.foo(1, 2, "abc"); -obj.foo(1, 2, ...a); -obj.foo(1, 2, ...a, "abc"); - -(obj.foo)(1, 2, "abc"); -(obj.foo)(1, 2, ...a); -(obj.foo)(1, 2, ...a, "abc"); - -xa[1].foo(1, 2, "abc"); -xa[1].foo(1, 2, ...a); -xa[1].foo(1, 2, ...a, "abc"); - -(xa[1].foo)(...[1, 2, "abc"]); - -class C { - constructor(x: number, y: number, ...z: string[]) { - this.foo(x, y); - this.foo(x, y, ...z); - } - foo(x: number, y: number, ...z: string[]) { - } -} - -class D extends C { - constructor() { - super(1, 2); - super(1, 2, ...a); - } - foo() { - super.foo(1, 2); - super.foo(1, 2, ...a); - } -} +// @target: ES6 + +interface X { + foo(x: number, y: number, ...z: string[]); +} + +function foo(x: number, y: number, ...z: string[]) { +} + +var a: string[]; +var z: number[]; +var obj: X; +var xa: X[]; + +foo(1, 2, "abc"); +foo(1, 2, ...a); +foo(1, 2, ...a, "abc"); + +obj.foo(1, 2, "abc"); +obj.foo(1, 2, ...a); +obj.foo(1, 2, ...a, "abc"); + +(obj.foo)(1, 2, "abc"); +(obj.foo)(1, 2, ...a); +(obj.foo)(1, 2, ...a, "abc"); + +xa[1].foo(1, 2, "abc"); +xa[1].foo(1, 2, ...a); +xa[1].foo(1, 2, ...a, "abc"); + +(xa[1].foo)(...[1, 2, "abc"]); + +class C { + constructor(x: number, y: number, ...z: string[]) { + this.foo(x, y); + this.foo(x, y, ...z); + } + foo(x: number, y: number, ...z: string[]) { + } +} + +class D extends C { + constructor() { + super(1, 2); + super(1, 2, ...a); + } + foo() { + super.foo(1, 2); + super.foo(1, 2, ...a); + } +} diff --git a/tests/typescript/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes2.ts b/tests/typescript/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes2.ts index 4e44c20c..bb5220ba 100644 --- a/tests/typescript/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes2.ts +++ b/tests/typescript/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes2.ts @@ -1,23 +1,23 @@ -interface Base { - x: { - a?: string; b: string; - } -} - -interface Base2 { - x: { - b: string; c?: number; - } -} - -interface Derived extends Base, Base2 { - x: { b: string } -} - -interface Derived2 extends Base, Base2 { - x: { a: number; b: string } -} - -interface Derived3 extends Base, Base2 { - x: { a: string; b: string } -} +interface Base { + x: { + a?: string; b: string; + } +} + +interface Base2 { + x: { + b: string; c?: number; + } +} + +interface Derived extends Base, Base2 { + x: { b: string } +} + +interface Derived2 extends Base, Base2 { + x: { a: number; b: string } +} + +interface Derived3 extends Base, Base2 { + x: { a: string; b: string } +} diff --git a/tests/typescript/conformance/internalModules/importDeclarations/circularImportAlias.ts b/tests/typescript/conformance/internalModules/importDeclarations/circularImportAlias.ts index 0c748c6d..7372952c 100644 --- a/tests/typescript/conformance/internalModules/importDeclarations/circularImportAlias.ts +++ b/tests/typescript/conformance/internalModules/importDeclarations/circularImportAlias.ts @@ -1,18 +1,18 @@ -// expected no error - -module B { - export import a = A; - export class D extends a.C { - id: number; - } -} - -module A { - export class C { name: string } - export import b = B; -} - -var c: { name: string }; -var c = new B.a.C(); - - +// expected no error + +module B { + export import a = A; + export class D extends a.C { + id: number; + } +} + +module A { + export class C { name: string } + export import b = B; +} + +var c: { name: string }; +var c = new B.a.C(); + + diff --git a/tests/typescript/conformance/internalModules/importDeclarations/exportImportAlias.ts b/tests/typescript/conformance/internalModules/importDeclarations/exportImportAlias.ts index f9d64dee..74007ff3 100644 --- a/tests/typescript/conformance/internalModules/importDeclarations/exportImportAlias.ts +++ b/tests/typescript/conformance/internalModules/importDeclarations/exportImportAlias.ts @@ -1,68 +1,68 @@ -// expect no errors here - -module A { - - export var x = 'hello world' - export class Point { - constructor(public x: number, public y: number) { } - } - export module B { - export interface Id { - name: string; - } - } -} - -module C { - export import a = A; -} - -var a: string = C.a.x; -var b: { x: number; y: number; } = new C.a.Point(0, 0); -var c: { name: string }; -var c: C.a.B.Id; - -module X { - export function Y() { - return 42; - } - - export module Y { - export class Point { - constructor(public x: number, public y: number) { } - } - } -} - -module Z { - - // 'y' should be a fundule here - export import y = X.Y; -} - -var m: number = Z.y(); -var n: { x: number; y: number; } = new Z.y.Point(0, 0); - -module K { - export class L { - constructor(public name: string) { } - } - - export module L { - export var y = 12; - export interface Point { - x: number; - y: number; - } - } -} - -module M { - export import D = K.L; -} - -var o: { name: string }; -var o = new M.D('Hello'); - -var p: { x: number; y: number; } +// expect no errors here + +module A { + + export var x = 'hello world' + export class Point { + constructor(public x: number, public y: number) { } + } + export module B { + export interface Id { + name: string; + } + } +} + +module C { + export import a = A; +} + +var a: string = C.a.x; +var b: { x: number; y: number; } = new C.a.Point(0, 0); +var c: { name: string }; +var c: C.a.B.Id; + +module X { + export function Y() { + return 42; + } + + export module Y { + export class Point { + constructor(public x: number, public y: number) { } + } + } +} + +module Z { + + // 'y' should be a fundule here + export import y = X.Y; +} + +var m: number = Z.y(); +var n: { x: number; y: number; } = new Z.y.Point(0, 0); + +module K { + export class L { + constructor(public name: string) { } + } + + export module L { + export var y = 12; + export interface Point { + x: number; + y: number; + } + } +} + +module M { + export import D = K.L; +} + +var o: { name: string }; +var o = new M.D('Hello'); + +var p: { x: number; y: number; } var p: M.D.Point; \ No newline at end of file diff --git a/tests/typescript/conformance/internalModules/importDeclarations/importAliasIdentifiers.ts b/tests/typescript/conformance/internalModules/importDeclarations/importAliasIdentifiers.ts index 6d5723c1..fd0a4025 100644 --- a/tests/typescript/conformance/internalModules/importDeclarations/importAliasIdentifiers.ts +++ b/tests/typescript/conformance/internalModules/importDeclarations/importAliasIdentifiers.ts @@ -1,46 +1,46 @@ -module moduleA { - export class Point { - constructor(public x: number, public y: number) { } - } -} - -import alias = moduleA; - -var p: alias.Point; -var p: moduleA.Point; -var p: { x: number; y: number; }; - -class clodule { - name: string; -} - -module clodule { - export interface Point { - x: number; y: number; - } - var Point: Point = { x: 0, y: 0 }; -} - -import clolias = clodule; - -var p: clolias.Point; -var p: clodule.Point; -var p: { x: number; y: number; }; - - -function fundule() { - return { x: 0, y: 0 }; -} - -module fundule { - export interface Point { - x: number; y: number; - } - var Point: Point = { x: 0, y: 0 }; -} - -import funlias = fundule; - -var p: funlias.Point; -var p: fundule.Point; +module moduleA { + export class Point { + constructor(public x: number, public y: number) { } + } +} + +import alias = moduleA; + +var p: alias.Point; +var p: moduleA.Point; +var p: { x: number; y: number; }; + +class clodule { + name: string; +} + +module clodule { + export interface Point { + x: number; y: number; + } + var Point: Point = { x: 0, y: 0 }; +} + +import clolias = clodule; + +var p: clolias.Point; +var p: clodule.Point; +var p: { x: number; y: number; }; + + +function fundule() { + return { x: 0, y: 0 }; +} + +module fundule { + export interface Point { + x: number; y: number; + } + var Point: Point = { x: 0, y: 0 }; +} + +import funlias = fundule; + +var p: funlias.Point; +var p: fundule.Point; var p: { x: number; y: number; }; \ No newline at end of file diff --git a/tests/typescript/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts b/tests/typescript/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts index ebd13c54..b4005b4f 100644 --- a/tests/typescript/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts +++ b/tests/typescript/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts @@ -1,23 +1,23 @@ -// none of these should work, since non are actually modules - -var V = 12; - -import v = V; - -class C { - name: string; -} - -import c = C; - -enum E { - Red, Blue -} - -import e = E; - -interface I { - id: number; -} - -import i = I; +// none of these should work, since non are actually modules + +var V = 12; + +import v = V; + +class C { + name: string; +} + +import c = C; + +enum E { + Red, Blue +} + +import e = E; + +interface I { + id: number; +} + +import i = I; diff --git a/tests/typescript/conformance/internalModules/importDeclarations/shadowedInternalModule.ts b/tests/typescript/conformance/internalModules/importDeclarations/shadowedInternalModule.ts index dcdcdbd1..2bc170f9 100644 --- a/tests/typescript/conformance/internalModules/importDeclarations/shadowedInternalModule.ts +++ b/tests/typescript/conformance/internalModules/importDeclarations/shadowedInternalModule.ts @@ -1,33 +1,33 @@ -// all errors imported modules conflict with local variables - -module A { - export var Point = { x: 0, y: 0 } - export interface Point { - x: number; - y: number; - } -} - -module B { - var A = { x: 0, y: 0 }; - import Point = A; -} - -module X { - export module Y { - export interface Point{ - x: number; - y: number - } - } - - export class Y { - name: string; - } -} - -module Z { - import Y = X.Y; - - var Y = 12; +// all errors imported modules conflict with local variables + +module A { + export var Point = { x: 0, y: 0 } + export interface Point { + x: number; + y: number; + } +} + +module B { + var A = { x: 0, y: 0 }; + import Point = A; +} + +module X { + export module Y { + export interface Point{ + x: number; + y: number + } + } + + export class Y { + name: string; + } +} + +module Z { + import Y = X.Y; + + var Y = 12; } \ No newline at end of file diff --git a/tests/typescript/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement2.ts b/tests/typescript/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement2.ts index d67611bd..3c2941e3 100644 --- a/tests/typescript/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement2.ts +++ b/tests/typescript/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement2.ts @@ -1,3 +1,3 @@ -//@target: ES5 -for (var of X) { -} +//@target: ES5 +for (var of X) { +} diff --git a/tests/typescript/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement21.ts b/tests/typescript/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement21.ts index 6d28e4c0..4ea9e326 100644 --- a/tests/typescript/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement21.ts +++ b/tests/typescript/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement21.ts @@ -1,2 +1,2 @@ -//@target: ES5 -for (var of of) { } +//@target: ES5 +for (var of of) { } diff --git a/tests/typescript/conformance/parser/ecmascript5/Statements/parserForInStatement2.ts b/tests/typescript/conformance/parser/ecmascript5/Statements/parserForInStatement2.ts index 3bf9bc29..e6cf42d7 100644 --- a/tests/typescript/conformance/parser/ecmascript5/Statements/parserForInStatement2.ts +++ b/tests/typescript/conformance/parser/ecmascript5/Statements/parserForInStatement2.ts @@ -1,2 +1,2 @@ -for (var in X) { -} +for (var in X) { +} diff --git a/tests/typescript/conformance/types/constKeyword/constKeyword.ts b/tests/typescript/conformance/types/constKeyword/constKeyword.ts index 704e52a0..289f2c47 100644 --- a/tests/typescript/conformance/types/constKeyword/constKeyword.ts +++ b/tests/typescript/conformance/types/constKeyword/constKeyword.ts @@ -1 +1 @@ -const enum E { A, B, C } +const enum E { A, B, C } diff --git a/tests/typescript/conformance/types/enumDeclaration/enumDeclaration.ts b/tests/typescript/conformance/types/enumDeclaration/enumDeclaration.ts index f00df588..08cc3a0f 100644 --- a/tests/typescript/conformance/types/enumDeclaration/enumDeclaration.ts +++ b/tests/typescript/conformance/types/enumDeclaration/enumDeclaration.ts @@ -1 +1 @@ -enum E { A, B, C } +enum E { A, B, C } diff --git a/tests/typescript/conformance/types/importEqualsDeclaration/importEqualsDeclaration.ts b/tests/typescript/conformance/types/importEqualsDeclaration/importEqualsDeclaration.ts index 071edd02..5a261816 100644 --- a/tests/typescript/conformance/types/importEqualsDeclaration/importEqualsDeclaration.ts +++ b/tests/typescript/conformance/types/importEqualsDeclaration/importEqualsDeclaration.ts @@ -1 +1 @@ -import glo_m4 = require("glo_m4"); +import glo_m4 = require("glo_m4"); diff --git a/tests/typescript/conformance/types/mappedType/mappedType.ts b/tests/typescript/conformance/types/mappedType/mappedType.ts index 4c9cda4e..8cf6074d 100644 --- a/tests/typescript/conformance/types/mappedType/mappedType.ts +++ b/tests/typescript/conformance/types/mappedType/mappedType.ts @@ -1,3 +1,3 @@ -type Keys = 'option1' | 'option2'; -type Flags = { [K in Keys]: boolean }; - +type Keys = 'option1' | 'option2'; +type Flags = { [K in Keys]: boolean }; + diff --git a/tests/typescript/conformance/types/methodSignature/methodSignature.ts b/tests/typescript/conformance/types/methodSignature/methodSignature.ts index 6132f73c..607f5248 100644 --- a/tests/typescript/conformance/types/methodSignature/methodSignature.ts +++ b/tests/typescript/conformance/types/methodSignature/methodSignature.ts @@ -1,4 +1,4 @@ -var logger: { - log(val: any, val2: any), - error(val: any) -}; +var logger: { + log(val: any, val2: any), + error(val: any) +}; diff --git a/tests/typescript/conformance/types/moduleDeclaration/moduleDeclaration.ts b/tests/typescript/conformance/types/moduleDeclaration/moduleDeclaration.ts index bca9ee2c..6912fdeb 100644 --- a/tests/typescript/conformance/types/moduleDeclaration/moduleDeclaration.ts +++ b/tests/typescript/conformance/types/moduleDeclaration/moduleDeclaration.ts @@ -1,9 +1,9 @@ -module A { - export class A { - } -} - -declare module "B" { - export class B { - } -} +module A { + export class A { + } +} + +declare module "B" { + export class B { + } +} diff --git a/tests/typescript/conformance/types/parameterProperty/parameterProperty.ts b/tests/typescript/conformance/types/parameterProperty/parameterProperty.ts index 0064cb75..7928eb4c 100644 --- a/tests/typescript/conformance/types/parameterProperty/parameterProperty.ts +++ b/tests/typescript/conformance/types/parameterProperty/parameterProperty.ts @@ -1,5 +1,5 @@ -class c3 { - constructor(public arg: number = 10) { - // fails because of comment - } -} +class c3 { + constructor(public arg: number = 10) { + // fails because of comment + } +} diff --git a/tests/typescript/conformance/types/typeOperator/typeOperator.ts b/tests/typescript/conformance/types/typeOperator/typeOperator.ts index 36813dc2..7934259d 100644 --- a/tests/typescript/conformance/types/typeOperator/typeOperator.ts +++ b/tests/typescript/conformance/types/typeOperator/typeOperator.ts @@ -1 +1 @@ -let a: (keyof T)[] = ["a", "b"]; +let a: (keyof T)[] = ["a", "b"]; diff --git a/tests/typescript/conformance/types/typeParameter/typeParameter.ts b/tests/typescript/conformance/types/typeParameter/typeParameter.ts index 5a74f8f3..fe339ae7 100644 --- a/tests/typescript/conformance/types/typeParameter/typeParameter.ts +++ b/tests/typescript/conformance/types/typeParameter/typeParameter.ts @@ -1,3 +1,3 @@ -interface IObservable { - n: IObservable // fails because of comment -} +interface IObservable { + n: IObservable // fails because of comment +} diff --git a/tests/typescript/webhost/webtsc.ts b/tests/typescript/webhost/webtsc.ts index 3c682df6..5ab4f0f4 100644 --- a/tests/typescript/webhost/webtsc.ts +++ b/tests/typescript/webhost/webtsc.ts @@ -1,104 +1,104 @@ -/// - -namespace TypeScript.WebTsc { - - declare var RealActiveXObject: { new (s: string): any }; - - function getWScriptSystem() { - const fso = new RealActiveXObject("Scripting.FileSystemObject"); - - const fileStream = new ActiveXObject("ADODB.Stream"); - fileStream.Type = 2 /*text*/; - - const args: string[] = []; - for (let i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - return { - args: args, - newLine: "\r\n", - write(s: string): void { - WScript.StdOut.Write(s); - }, - writeErr(s: string): void { - WScript.StdErr.Write(s); - }, - readFile(fileName: string, encoding?: string): string { - if (!fso.FileExists(fileName)) { - return undefined; - } - fileStream.Open(); - try { - if (encoding) { - fileStream.Charset = encoding; - fileStream.LoadFromFile(fileName); - } - else { - // Load file and read the first two bytes into a string with no interpretation - fileStream.Charset = "x-ansi"; - fileStream.LoadFromFile(fileName); - const bom = fileStream.ReadText(2) || ""; - // Position must be at 0 before encoding can be changed - fileStream.Position = 0; - // [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8 - fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; - } - // ReadText method always strips byte order mark from resulting string - return fileStream.ReadText(); - } - catch (e) { - throw e; - } - finally { - fileStream.Close(); - } - }, - writeFile(fileName: string, data: string): boolean { - const f = fso.CreateTextFile(fileName, true); - f.Write(data); - f.Close(); - return true; - }, - resolvePath(path: string): string { - return fso.GetAbsolutePathName(path); - }, - fileExists(path: string): boolean { - return fso.FileExists(path); - }, - directoryExists(path: string) { - return fso.FolderExists(path); - }, - createDirectory(directoryName: string) { - if (!this.directoryExists(directoryName)) { - fso.CreateFolder(directoryName); - } - }, - getExecutingFilePath() { - return WScript.ScriptFullName; - }, - getCurrentDirectory() { - return ""; - }, - getMemoryUsage() { - return 0; - }, - exit(exitCode?: number): void { - WScript.Quit(exitCode); - }, - useCaseSensitiveFileNames: false - }; - } - - export function prepareCompiler(currentDir: string, stdOut: ITextWriter, stdErr: ITextWriter) { - const shell = new RealActiveXObject("WScript.Shell"); - shell.CurrentDirectory = currentDir; - WScript.ScriptFullName = currentDir + "\\tc.js"; - WScript.StdOut = stdOut; - WScript.StdErr = stdErr; - sys = getWScriptSystem(); - - return (commandLine: string) => { - ts.executeCommandLine(commandLine.split(" ")); - }; - } -} +/// + +namespace TypeScript.WebTsc { + + declare var RealActiveXObject: { new (s: string): any }; + + function getWScriptSystem() { + const fso = new RealActiveXObject("Scripting.FileSystemObject"); + + const fileStream = new ActiveXObject("ADODB.Stream"); + fileStream.Type = 2 /*text*/; + + const args: string[] = []; + for (let i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + return { + args: args, + newLine: "\r\n", + write(s: string): void { + WScript.StdOut.Write(s); + }, + writeErr(s: string): void { + WScript.StdErr.Write(s); + }, + readFile(fileName: string, encoding?: string): string { + if (!fso.FileExists(fileName)) { + return undefined; + } + fileStream.Open(); + try { + if (encoding) { + fileStream.Charset = encoding; + fileStream.LoadFromFile(fileName); + } + else { + // Load file and read the first two bytes into a string with no interpretation + fileStream.Charset = "x-ansi"; + fileStream.LoadFromFile(fileName); + const bom = fileStream.ReadText(2) || ""; + // Position must be at 0 before encoding can be changed + fileStream.Position = 0; + // [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8 + fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; + } + // ReadText method always strips byte order mark from resulting string + return fileStream.ReadText(); + } + catch (e) { + throw e; + } + finally { + fileStream.Close(); + } + }, + writeFile(fileName: string, data: string): boolean { + const f = fso.CreateTextFile(fileName, true); + f.Write(data); + f.Close(); + return true; + }, + resolvePath(path: string): string { + return fso.GetAbsolutePathName(path); + }, + fileExists(path: string): boolean { + return fso.FileExists(path); + }, + directoryExists(path: string) { + return fso.FolderExists(path); + }, + createDirectory(directoryName: string) { + if (!this.directoryExists(directoryName)) { + fso.CreateFolder(directoryName); + } + }, + getExecutingFilePath() { + return WScript.ScriptFullName; + }, + getCurrentDirectory() { + return ""; + }, + getMemoryUsage() { + return 0; + }, + exit(exitCode?: number): void { + WScript.Quit(exitCode); + }, + useCaseSensitiveFileNames: false + }; + } + + export function prepareCompiler(currentDir: string, stdOut: ITextWriter, stdErr: ITextWriter) { + const shell = new RealActiveXObject("WScript.Shell"); + shell.CurrentDirectory = currentDir; + WScript.ScriptFullName = currentDir + "\\tc.js"; + WScript.StdOut = stdOut; + WScript.StdErr = stdErr; + sys = getWScriptSystem(); + + return (commandLine: string) => { + ts.executeCommandLine(commandLine.split(" ")); + }; + } +} diff --git a/tests_config/run_spec.js b/tests_config/run_spec.js index de498dbc..ae61b7bb 100644 --- a/tests_config/run_spec.js +++ b/tests_config/run_spec.js @@ -1,157 +1,163 @@ "use strict"; const fs = require("fs"); -const extname = require("path").extname; +const path = require("path"); const raw = require("jest-snapshot-serializer-raw").wrap; const AST_COMPARE = process.env["AST_COMPARE"]; const TEST_STANDALONE = process.env["TEST_STANDALONE"]; +const TEST_CRLF = process.env["TEST_CRLF"]; + +const CURSOR_PLACEHOLDER = "<|>"; +const RANGE_START_PLACEHOLDER = "<<>>"; +const RANGE_END_PLACEHOLDER = "<<>>"; const prettier = !TEST_STANDALONE ? require("prettier/local") : require("prettier/standalone"); -function run_spec(dirname, parsers, options) { - /* instabul ignore if */ +global.run_spec = (dirname, parsers, options) => { + // istanbul ignore next if (!parsers || !parsers.length) { throw new Error(`No parsers were specified for ${dirname}`); } - fs.readdirSync(dirname).forEach(filename => { - // We need to have a skipped test with the same name of the snapshots, - // so Jest doesn't mark them as obsolete. - if (TEST_STANDALONE && parsers.some(skipStandalone)) { - parsers.forEach(parser => - test.skip(`${filename} - ${parser}-verify`, () => {}) - ); + fs.readdirSync(dirname).forEach(basename => { + const filename = path.join(dirname, basename); + + if ( + path.extname(basename) === ".snap" || + !fs.lstatSync(filename).isFile() || + basename[0] === "." || + basename === "jsfmt.spec.js" + ) { return; } - const path = dirname + "/" + filename; - if ( - extname(filename) !== ".snap" && - fs.lstatSync(path).isFile() && - filename[0] !== "." && - filename !== "jsfmt.spec.js" - ) { - let rangeStart; - let rangeEnd; - let cursorOffset; - const source = read(path) - .replace(/\r\n/g, "\n") - .replace("<<>>", (match, offset) => { - rangeStart = offset; - return ""; - }) - .replace("<<>>", (match, offset) => { - rangeEnd = offset; - return ""; - }); + let rangeStart; + let rangeEnd; + let cursorOffset; - const input = source.replace("<|>", (match, offset) => { - cursorOffset = offset; + const text = fs.readFileSync(filename, "utf8"); + + const source = (TEST_CRLF ? text.replace(/\n/g, "\r\n") : text) + .replace(RANGE_START_PLACEHOLDER, (match, offset) => { + rangeStart = offset; + return ""; + }) + .replace(RANGE_END_PLACEHOLDER, (match, offset) => { + rangeEnd = offset; return ""; }); - const baseOptions = Object.assign(mergeDefaultOptions(options || {}), { - rangeStart, - rangeEnd, - cursorOffset - }); - const mainOptions = Object.assign({}, baseOptions, { - parser: parsers[0] - }); - const output = prettyprint(input, path, mainOptions); - test(filename, () => { - expect( - raw( - createSnapshot( - source, - output, - Object.assign({}, baseOptions, { parsers }) - ) + const input = source.replace(CURSOR_PLACEHOLDER, (match, offset) => { + cursorOffset = offset; + return ""; + }); + + const baseOptions = Object.assign({ printWidth: 80 }, options, { + rangeStart, + rangeEnd, + cursorOffset + }); + const mainOptions = Object.assign({}, baseOptions, { + parser: parsers[0] + }); + + const hasEndOfLine = "endOfLine" in mainOptions; + + const output = format(input, filename, mainOptions); + const visualizedOutput = visualizeEndOfLine(output); + + test(basename, () => { + expect(visualizedOutput).toEqual( + visualizeEndOfLine(consistentEndOfLine(output)) + ); + expect( + raw( + createSnapshot( + hasEndOfLine + ? visualizeEndOfLine( + text + .replace(RANGE_START_PLACEHOLDER, "") + .replace(RANGE_END_PLACEHOLDER, "") + ) + : source, + hasEndOfLine ? visualizedOutput : output, + Object.assign({}, baseOptions, { parsers }) ) - ).toMatchSnapshot(); + ) + ).toMatchSnapshot(); + }); + + for (const parser of parsers.slice(1)) { + const verifyOptions = Object.assign({}, baseOptions, { parser }); + test(`${basename} - ${parser}-verify`, () => { + const verifyOutput = format(input, filename, verifyOptions); + expect(visualizedOutput).toEqual(visualizeEndOfLine(verifyOutput)); }); - - parsers.slice(1).forEach(parser => { - const verifyOptions = Object.assign({}, mainOptions, { parser }); - test(`${filename} - ${parser}-verify`, () => { - const verifyOutput = prettyprint(input, path, verifyOptions); - expect(output).toEqual(verifyOutput); - }); - }); - - if (AST_COMPARE) { - test(`${path} parse`, () => { - const compareOptions = Object.assign({}, mainOptions); - delete compareOptions.cursorOffset; - const astMassaged = parse(input, compareOptions); - let ppastMassaged = undefined; - - expect(() => { - ppastMassaged = parse( - prettyprint(input, path, compareOptions) - // \r has been replaced with /*CR*/ to test presence of CR in jest snapshots; - // reverting this to get the right AST - .replace(/\/\*CR\*\//g, "\r"), - compareOptions - ); - }).not.toThrow(); - - expect(ppastMassaged).toBeDefined(); - if (!astMassaged.errors || astMassaged.errors.length === 0) { - expect(astMassaged).toEqual(ppastMassaged); - } - }); - } } + + if (AST_COMPARE) { + test(`${filename} parse`, () => { + const parseOptions = Object.assign({}, mainOptions); + delete parseOptions.cursorOffset; + + const originalAst = parse(input, parseOptions); + let formattedAst; + + expect(() => { + formattedAst = parse( + output.replace(CURSOR_PLACEHOLDER, ""), + parseOptions + ); + }).not.toThrow(); + expect(originalAst).toEqual(formattedAst); + }); + } + }); +}; + +function parse(source, options) { + return prettier.__debug.parse(source, options, /* massage */ true).ast; +} + +function format(source, filename, options) { + const result = prettier.formatWithCursor( + source, + Object.assign({ filepath: filename }, options) + ); + + return options.cursorOffset >= 0 + ? result.formatted.slice(0, result.cursorOffset) + + CURSOR_PLACEHOLDER + + result.formatted.slice(result.cursorOffset) + : result.formatted; +} + +function consistentEndOfLine(text) { + let firstEndOfLine; + return text.replace(/\r\n?|\n/g, endOfLine => { + if (!firstEndOfLine) { + firstEndOfLine = endOfLine; + } + return firstEndOfLine; }); } -global.run_spec = run_spec; - -function parse(string, opts) { - return prettier.__debug.parse(string, opts, /* massage */ true).ast; -} - -function prettyprint(src, filename, options) { - const result = prettier.formatWithCursor( - src, - Object.assign( - { - filepath: filename - }, - options - ) - ); - if (options.cursorOffset >= 0) { - result.formatted = - result.formatted.slice(0, result.cursorOffset) + - "<|>" + - result.formatted.slice(result.cursorOffset); - } - - // \r is trimmed from jest snapshots by default; - // manually replacing this character with /*CR*/ to test its true presence - return result.formatted.replace(/\r/g, "/*CR*/"); -} - -function read(filename) { - return fs.readFileSync(filename, "utf8"); -} - -function skipStandalone(/* parser */) { - return false; -} - -function mergeDefaultOptions(parserConfig) { - return Object.assign( - { - printWidth: 80 - }, - parserConfig - ); +function visualizeEndOfLine(text) { + return text.replace(/\r\n?|\n/g, endOfLine => { + switch (endOfLine) { + case "\n": + return "\n"; + case "\r\n": + return "\n"; + case "\r": + return "\n"; + default: + throw new Error(`Unexpected end of line ${JSON.stringify(endOfLine)}`); + } + }); } function createSnapshot(input, output, options) { diff --git a/tests_integration/__tests__/__snapshots__/eol-crlf.js.snap b/tests_integration/__tests__/__snapshots__/eol-crlf.js.snap deleted file mode 100644 index 07511e61..00000000 --- a/tests_integration/__tests__/__snapshots__/eol-crlf.js.snap +++ /dev/null @@ -1,62 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Has correct default Windows line endings (stderr) 1`] = `""`; - -exports[`Has correct default Windows line endings (stdout) 1`] = ` -"function f() { - console.log(\\"should have tab width 8\\") -} -function f() { - console.log(\\"should have space width 2\\") -} -function f() { - console.log(\\"should have space width 8\\") -} -function f() { - console.log( - \\"should have space width 2 despite ../.editorconfig specifying 8, because ./.hg is present\\" - ) -} -console.log(\\"jest/__best-tests__/file.js should have semi\\");/*CR*/ -console.log(\\"jest/Component.js should not have semi\\")/*CR*/ -console.log(\\"jest/Component.test.js should have semi\\");/*CR*/ -function js() { - console.log(\\"js/file.js should have tab width 8 (1 if CLI)\\"); -} -\\"use strict\\"; - -module.exports = { - endOfLine: \\"lf\\", - tabWidth: 8 -}; -function noConfigJs() { - console.log(\\"no-config/file.js should have no semicolons\\") -} -function packageJs() {/*CR*/ - console.log(\\"package/file.js should have tab width 3\\");/*CR*/ -}/*CR*/ -function rcJson() {/*CR*/ - console.log.apply(null, [/*CR*/ - 'rc-json/file.js',/*CR*/ - 'should have trailing comma',/*CR*/ - 'and single quotes',/*CR*/ - ]);/*CR*/ -}/*CR*/ -function rcToml() {/*CR*/ - console.log.apply(null, [/*CR*/ - 'rc-toml/file.js',/*CR*/ - 'should have trailing comma',/*CR*/ - 'and single quotes',/*CR*/ - ]);/*CR*/ -}/*CR*/ -function rcYaml() {/*CR*/ - console.log.apply(null, [/*CR*/ - 'rc-yaml/file.js',/*CR*/ - 'should have trailing comma',/*CR*/ - 'and single quotes',/*CR*/ - ]);/*CR*/ -}/*CR*/ -" -`; - -exports[`Has correct default Windows line endings (write) 1`] = `Array []`; diff --git a/tests_integration/__tests__/__snapshots__/eol-lf.js.snap b/tests_integration/__tests__/__snapshots__/eol-lf.js.snap deleted file mode 100644 index 02ef9a4f..00000000 --- a/tests_integration/__tests__/__snapshots__/eol-lf.js.snap +++ /dev/null @@ -1,62 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Has correct default Unix line endings (stderr) 1`] = `""`; - -exports[`Has correct default Unix line endings (stdout) 1`] = ` -"function f() { - console.log(\\"should have tab width 8\\") -} -function f() { - console.log(\\"should have space width 2\\") -} -function f() { - console.log(\\"should have space width 8\\") -} -function f() { - console.log( - \\"should have space width 2 despite ../.editorconfig specifying 8, because ./.hg is present\\" - ) -} -console.log(\\"jest/__best-tests__/file.js should have semi\\"); -console.log(\\"jest/Component.js should not have semi\\") -console.log(\\"jest/Component.test.js should have semi\\"); -function js() { - console.log(\\"js/file.js should have tab width 8 (1 if CLI)\\"); -} -\\"use strict\\"; - -module.exports = { - endOfLine: \\"lf\\", - tabWidth: 8 -}; -function noConfigJs() { - console.log(\\"no-config/file.js should have no semicolons\\") -} -function packageJs() { - console.log(\\"package/file.js should have tab width 3\\"); -} -function rcJson() { - console.log.apply(null, [ - 'rc-json/file.js', - 'should have trailing comma', - 'and single quotes', - ]); -} -function rcToml() { - console.log.apply(null, [ - 'rc-toml/file.js', - 'should have trailing comma', - 'and single quotes', - ]); -} -function rcYaml() { - console.log.apply(null, [ - 'rc-yaml/file.js', - 'should have trailing comma', - 'and single quotes', - ]); -} -" -`; - -exports[`Has correct default Unix line endings (write) 1`] = `Array []`; diff --git a/tests_integration/__tests__/eol-crlf.js b/tests_integration/__tests__/eol-crlf.js deleted file mode 100644 index 622cc915..00000000 --- a/tests_integration/__tests__/eol-crlf.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -const runPrettier = require("../runPrettier"); - -expect.addSnapshotSerializer(require("../path-serializer")); - -describe("Has correct default Windows line endings", () => { - runPrettier("cli/config/", ["**/*.js"]).test({ - status: 0 - }); -}); diff --git a/tests_integration/__tests__/eol-lf.js b/tests_integration/__tests__/eol-lf.js deleted file mode 100644 index e8730e65..00000000 --- a/tests_integration/__tests__/eol-lf.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -const runPrettier = require("../runPrettier"); - -expect.addSnapshotSerializer(require("../path-serializer")); - -describe("Has correct default Unix line endings", () => { - runPrettier("cli/config/", ["**/*.js"]).test({ - status: 0 - }); -}); diff --git a/yarn.lock b/yarn.lock index f36ba7ba..340c46a8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6132,16 +6132,16 @@ yallist@^3.0.0, yallist@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.2.tgz#8452b4bb7e83c7c188d8041c1a837c773d6d8bb9" -yaml-unist-parser@1.0.0-rc.4: - version "1.0.0-rc.4" - resolved "https://registry.yarnpkg.com/yaml-unist-parser/-/yaml-unist-parser-1.0.0-rc.4.tgz#d8fb9c673d59a4f7d532840b120abd6400237014" +yaml-unist-parser@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/yaml-unist-parser/-/yaml-unist-parser-1.0.0.tgz#060def481d2319a8def3b6a06cb8ae3848b0aed3" dependencies: lines-and-columns "^1.1.6" tslib "^1.9.1" -yaml@1.0.0-rc.8: - version "1.0.0-rc.8" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.0.0-rc.8.tgz#e5604c52b7b07b16e469bcf875ab0dfe08c50d42" +yaml@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.0.2.tgz#77941a457090e17b8ca65b53322e68a050e090d4" yargs-parser@^7.0.0: version "7.0.0"