diff options
Diffstat (limited to 'tests/testdata/fmt')
46 files changed, 556 insertions, 0 deletions
diff --git a/tests/testdata/fmt/badly_formatted.ipynb b/tests/testdata/fmt/badly_formatted.ipynb new file mode 100644 index 000000000..c8600564f --- /dev/null +++ b/tests/testdata/fmt/badly_formatted.ipynb @@ -0,0 +1,105 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Hello Markdown\n", + "this isn't formatted properly" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hello World\n" + ] + } + ], + "source": [ + "console.log(\"Hello World\"\n", + "\n", + ");" + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "raw text\n", + " here too\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "alice\n" + ] + } + ], + "source": [ + "function hello(name: string ) {\n", + " console.log(name);\n", + "};\n", + "\n", + "hello( \"alice\");\n" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "function foo(): number {\n", + " return 2;\n", + "}\n" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\n" + ] + } + ], + "source": [ + "console.log(\"loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\");" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Deno", + "language": "typescript", + "name": "deno" + }, + "language_info": { + "file_extension": ".ts", + "mimetype": "text/x.typescript", + "name": "typescript", + "nb_converter": "script", + "pygments_lexer": "typescript", + "version": "5.2.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/tests/testdata/fmt/badly_formatted.json b/tests/testdata/fmt/badly_formatted.json new file mode 100644 index 000000000..f2bacf73d --- /dev/null +++ b/tests/testdata/fmt/badly_formatted.json @@ -0,0 +1,12 @@ +{ + + + "key1": "value1", + "key2": true, + "key3": ["value2", "value3", false], + "keys": { + "more": "values" + } + + +}
\ No newline at end of file diff --git a/tests/testdata/fmt/badly_formatted.md b/tests/testdata/fmt/badly_formatted.md new file mode 100644 index 000000000..26afe483b --- /dev/null +++ b/tests/testdata/fmt/badly_formatted.md @@ -0,0 +1,46 @@ +# Hello Markdown + +```js +console.log("Hello World" + +) +``` + +```javascript +console.log("Hello World2" + +) +``` + +```ts + +function hello(name: string ) { + console.log(name); +}; + +hello( "alice"); +``` + +```typescript +function foo(): number { + return 2; +} +``` + +```jsonc + +{ + // Comment in JSON + "key": "value", + "key2": + "value2", +} + +``` + +```json +{ + "numbers": + ["1", "2"] +} +```
\ No newline at end of file diff --git a/tests/testdata/fmt/badly_formatted.mjs b/tests/testdata/fmt/badly_formatted.mjs new file mode 100644 index 000000000..bc515a330 --- /dev/null +++ b/tests/testdata/fmt/badly_formatted.mjs @@ -0,0 +1,4 @@ +// Deliberately using .mjs to avoid triggering dprint +console.log("Hello World" + +) diff --git a/tests/testdata/fmt/badly_formatted_fixed.ipynb b/tests/testdata/fmt/badly_formatted_fixed.ipynb new file mode 100644 index 000000000..a26a95e24 --- /dev/null +++ b/tests/testdata/fmt/badly_formatted_fixed.ipynb @@ -0,0 +1,106 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Hello Markdown\n", + "\n", + "this isn't formatted properly" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hello World\n" + ] + } + ], + "source": [ + "console.log(\"Hello World\");" + ] + }, + { + "cell_type": "raw", + "metadata": {}, + "source": [ + "raw text\n", + " here too\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "alice\n" + ] + } + ], + "source": [ + "function hello(name: string) {\n", + " console.log(name);\n", + "}\n", + "\n", + "hello(\"alice\");" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "function foo(): number {\n", + " return 2;\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\n" + ] + } + ], + "source": [ + "console.log(\n", + " \"loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\",\n", + ");" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Deno", + "language": "typescript", + "name": "deno" + }, + "language_info": { + "file_extension": ".ts", + "mimetype": "text/x.typescript", + "name": "typescript", + "nb_converter": "script", + "pygments_lexer": "typescript", + "version": "5.2.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/tests/testdata/fmt/badly_formatted_fixed.js b/tests/testdata/fmt/badly_formatted_fixed.js new file mode 100644 index 000000000..e9062ba85 --- /dev/null +++ b/tests/testdata/fmt/badly_formatted_fixed.js @@ -0,0 +1,2 @@ +// Deliberately using .mjs to avoid triggering dprint +console.log("Hello World"); diff --git a/tests/testdata/fmt/badly_formatted_fixed.json b/tests/testdata/fmt/badly_formatted_fixed.json new file mode 100644 index 000000000..0d697a2c6 --- /dev/null +++ b/tests/testdata/fmt/badly_formatted_fixed.json @@ -0,0 +1,8 @@ +{ + "key1": "value1", + "key2": true, + "key3": ["value2", "value3", false], + "keys": { + "more": "values" + } +} diff --git a/tests/testdata/fmt/badly_formatted_fixed.md b/tests/testdata/fmt/badly_formatted_fixed.md new file mode 100644 index 000000000..8ba74cac3 --- /dev/null +++ b/tests/testdata/fmt/badly_formatted_fixed.md @@ -0,0 +1,37 @@ +# Hello Markdown + +```js +console.log("Hello World"); +``` + +```javascript +console.log("Hello World2"); +``` + +```ts +function hello(name: string) { + console.log(name); +} + +hello("alice"); +``` + +```typescript +function foo(): number { + return 2; +} +``` + +```jsonc +{ + // Comment in JSON + "key": "value", + "key2": "value2" +} +``` + +```json +{ + "numbers": ["1", "2"] +} +``` diff --git a/tests/testdata/fmt/deno.glob.json b/tests/testdata/fmt/deno.glob.json new file mode 100644 index 000000000..ff74e9d2b --- /dev/null +++ b/tests/testdata/fmt/deno.glob.json @@ -0,0 +1,11 @@ +{ + "fmt": { + "include": [ + "glob/data/test1.?s", + "glob/nested/foo/*.ts", + "glob/nested/fizz/*.ts", + "glob/pages/[id].ts" + ], + "exclude": ["glob/nested/**/*bazz.ts"] + } +} diff --git a/tests/testdata/fmt/deno.malformed.jsonc b/tests/testdata/fmt/deno.malformed.jsonc new file mode 100644 index 000000000..e326edb1f --- /dev/null +++ b/tests/testdata/fmt/deno.malformed.jsonc @@ -0,0 +1,10 @@ +{ + "fmt": { + "include": ["fmt_with_config/"], + "exclude": ["fmt_with_config/b.ts"], + "dont_know_this_field": {}, + "options": { + "useTabs": true + } + } +} diff --git a/tests/testdata/fmt/deno.malformed2.jsonc b/tests/testdata/fmt/deno.malformed2.jsonc new file mode 100644 index 000000000..e326edb1f --- /dev/null +++ b/tests/testdata/fmt/deno.malformed2.jsonc @@ -0,0 +1,10 @@ +{ + "fmt": { + "include": ["fmt_with_config/"], + "exclude": ["fmt_with_config/b.ts"], + "dont_know_this_field": {}, + "options": { + "useTabs": true + } + } +} diff --git a/tests/testdata/fmt/expected_fmt_check_formatted_files.out b/tests/testdata/fmt/expected_fmt_check_formatted_files.out new file mode 100644 index 000000000..5a4833dd4 --- /dev/null +++ b/tests/testdata/fmt/expected_fmt_check_formatted_files.out @@ -0,0 +1 @@ +Checked 4 files diff --git a/tests/testdata/fmt/expected_fmt_check_ignore.out b/tests/testdata/fmt/expected_fmt_check_ignore.out new file mode 100644 index 000000000..7c1e471b9 --- /dev/null +++ b/tests/testdata/fmt/expected_fmt_check_ignore.out @@ -0,0 +1 @@ +Checked 3 files diff --git a/tests/testdata/fmt/expected_fmt_check_verbose_formatted_files.out b/tests/testdata/fmt/expected_fmt_check_verbose_formatted_files.out new file mode 100644 index 000000000..158c556c2 --- /dev/null +++ b/tests/testdata/fmt/expected_fmt_check_verbose_formatted_files.out @@ -0,0 +1 @@ +Checked 2 files diff --git a/tests/testdata/fmt/fmt_check_parse_error.out b/tests/testdata/fmt/fmt_check_parse_error.out new file mode 100644 index 000000000..9854b6c97 --- /dev/null +++ b/tests/testdata/fmt/fmt_check_parse_error.out @@ -0,0 +1,6 @@ +Error checking: [WILDCARD]parse_error.ts + Expected '{', got '<eof>' at [WILDCARD]parse_error.ts:2:7 + + class Test + ~~~~ +error: Found 1 not formatted file in 1 file diff --git a/tests/testdata/fmt/fmt_with_config.out b/tests/testdata/fmt/fmt_with_config.out new file mode 100644 index 000000000..158c556c2 --- /dev/null +++ b/tests/testdata/fmt/fmt_with_config.out @@ -0,0 +1 @@ +Checked 2 files diff --git a/tests/testdata/fmt/fmt_with_config_and_flags.out b/tests/testdata/fmt/fmt_with_config_and_flags.out new file mode 100644 index 000000000..c05ac45a1 --- /dev/null +++ b/tests/testdata/fmt/fmt_with_config_and_flags.out @@ -0,0 +1 @@ +Checked 1 file diff --git a/tests/testdata/fmt/fmt_with_config_default.out b/tests/testdata/fmt/fmt_with_config_default.out new file mode 100644 index 000000000..faad9352b --- /dev/null +++ b/tests/testdata/fmt/fmt_with_config_default.out @@ -0,0 +1,2 @@ +Config file found at '[WILDCARD]deno.jsonc' +Checked 2 files diff --git a/tests/testdata/fmt/fmt_with_deprecated_config.out b/tests/testdata/fmt/fmt_with_deprecated_config.out new file mode 100644 index 000000000..793fac1bc --- /dev/null +++ b/tests/testdata/fmt/fmt_with_deprecated_config.out @@ -0,0 +1,3 @@ +Warning: "options" configuration is deprecated. Please use "flat" options instead. +Warning: "files" configuration is deprecated. Please use "include" and "exclude" instead. +Checked 2 files diff --git a/tests/testdata/fmt/fmt_with_malformed_config.out b/tests/testdata/fmt/fmt_with_malformed_config.out new file mode 100644 index 000000000..c269053a6 --- /dev/null +++ b/tests/testdata/fmt/fmt_with_malformed_config.out @@ -0,0 +1,4 @@ +error: Failed to parse "fmt" configuration + +Caused by: + unknown field `dont_know_this_field`, expected one of `useTabs`, `lineWidth`, `indentWidth`, `singleQuote`, `proseWrap`, `semiColons`, `options`, `include`, `exclude`, `files` diff --git a/tests/testdata/fmt/fmt_with_malformed_config2.out b/tests/testdata/fmt/fmt_with_malformed_config2.out new file mode 100644 index 000000000..c269053a6 --- /dev/null +++ b/tests/testdata/fmt/fmt_with_malformed_config2.out @@ -0,0 +1,4 @@ +error: Failed to parse "fmt" configuration + +Caused by: + unknown field `dont_know_this_field`, expected one of `useTabs`, `lineWidth`, `indentWidth`, `singleQuote`, `proseWrap`, `semiColons`, `options`, `include`, `exclude`, `files` diff --git a/tests/testdata/fmt/glob/data/tes.ts b/tests/testdata/fmt/glob/data/tes.ts new file mode 100644 index 000000000..0127c4af3 --- /dev/null +++ b/tests/testdata/fmt/glob/data/tes.ts @@ -0,0 +1,3 @@ + function foo() { + +}
\ No newline at end of file diff --git a/tests/testdata/fmt/glob/data/test1.js b/tests/testdata/fmt/glob/data/test1.js new file mode 100644 index 000000000..e939e4595 --- /dev/null +++ b/tests/testdata/fmt/glob/data/test1.js @@ -0,0 +1,2 @@ + function foo() { +} diff --git a/tests/testdata/fmt/glob/data/test1.ts b/tests/testdata/fmt/glob/data/test1.ts new file mode 100644 index 000000000..e939e4595 --- /dev/null +++ b/tests/testdata/fmt/glob/data/test1.ts @@ -0,0 +1,2 @@ + function foo() { +} diff --git a/tests/testdata/fmt/glob/data/test12.ts b/tests/testdata/fmt/glob/data/test12.ts new file mode 100644 index 000000000..0127c4af3 --- /dev/null +++ b/tests/testdata/fmt/glob/data/test12.ts @@ -0,0 +1,3 @@ + function foo() { + +}
\ No newline at end of file diff --git a/tests/testdata/fmt/glob/nested/fizz/bar.ts b/tests/testdata/fmt/glob/nested/fizz/bar.ts new file mode 100644 index 000000000..e939e4595 --- /dev/null +++ b/tests/testdata/fmt/glob/nested/fizz/bar.ts @@ -0,0 +1,2 @@ + function foo() { +} diff --git a/tests/testdata/fmt/glob/nested/fizz/bazz.ts b/tests/testdata/fmt/glob/nested/fizz/bazz.ts new file mode 100644 index 000000000..0127c4af3 --- /dev/null +++ b/tests/testdata/fmt/glob/nested/fizz/bazz.ts @@ -0,0 +1,3 @@ + function foo() { + +}
\ No newline at end of file diff --git a/tests/testdata/fmt/glob/nested/fizz/fizz.ts b/tests/testdata/fmt/glob/nested/fizz/fizz.ts new file mode 100644 index 000000000..e939e4595 --- /dev/null +++ b/tests/testdata/fmt/glob/nested/fizz/fizz.ts @@ -0,0 +1,2 @@ + function foo() { +} diff --git a/tests/testdata/fmt/glob/nested/fizz/foo.ts b/tests/testdata/fmt/glob/nested/fizz/foo.ts new file mode 100644 index 000000000..e939e4595 --- /dev/null +++ b/tests/testdata/fmt/glob/nested/fizz/foo.ts @@ -0,0 +1,2 @@ + function foo() { +} diff --git a/tests/testdata/fmt/glob/nested/foo/bar.ts b/tests/testdata/fmt/glob/nested/foo/bar.ts new file mode 100644 index 000000000..e939e4595 --- /dev/null +++ b/tests/testdata/fmt/glob/nested/foo/bar.ts @@ -0,0 +1,2 @@ + function foo() { +} diff --git a/tests/testdata/fmt/glob/nested/foo/bazz.ts b/tests/testdata/fmt/glob/nested/foo/bazz.ts new file mode 100644 index 000000000..0127c4af3 --- /dev/null +++ b/tests/testdata/fmt/glob/nested/foo/bazz.ts @@ -0,0 +1,3 @@ + function foo() { + +}
\ No newline at end of file diff --git a/tests/testdata/fmt/glob/nested/foo/fizz.ts b/tests/testdata/fmt/glob/nested/foo/fizz.ts new file mode 100644 index 000000000..e939e4595 --- /dev/null +++ b/tests/testdata/fmt/glob/nested/foo/fizz.ts @@ -0,0 +1,2 @@ + function foo() { +} diff --git a/tests/testdata/fmt/glob/nested/foo/foo.ts b/tests/testdata/fmt/glob/nested/foo/foo.ts new file mode 100644 index 000000000..e939e4595 --- /dev/null +++ b/tests/testdata/fmt/glob/nested/foo/foo.ts @@ -0,0 +1,2 @@ + function foo() { +} diff --git a/tests/testdata/fmt/glob/pages/[id].ts b/tests/testdata/fmt/glob/pages/[id].ts new file mode 100644 index 000000000..e939e4595 --- /dev/null +++ b/tests/testdata/fmt/glob/pages/[id].ts @@ -0,0 +1,2 @@ + function foo() { +} diff --git a/tests/testdata/fmt/invalid_data.json b/tests/testdata/fmt/invalid_data.json Binary files differnew file mode 100644 index 000000000..fb9bec94f --- /dev/null +++ b/tests/testdata/fmt/invalid_data.json diff --git a/tests/testdata/fmt/invalid_data.out b/tests/testdata/fmt/invalid_data.out new file mode 100644 index 000000000..dee00fcc5 --- /dev/null +++ b/tests/testdata/fmt/invalid_data.out @@ -0,0 +1,4 @@ +error: [WILDCARD] is not a valid UTF-8 file + +Caused by: + invalid data diff --git a/tests/testdata/fmt/parse_error/parse_error.ts b/tests/testdata/fmt/parse_error/parse_error.ts new file mode 100644 index 000000000..136d16508 --- /dev/null +++ b/tests/testdata/fmt/parse_error/parse_error.ts @@ -0,0 +1,2 @@ +// a file that purposefully will cause an error +class Test diff --git a/tests/testdata/fmt/regular/formatted1.js b/tests/testdata/fmt/regular/formatted1.js new file mode 100644 index 000000000..587aa5b96 --- /dev/null +++ b/tests/testdata/fmt/regular/formatted1.js @@ -0,0 +1,5 @@ +function foo() { + return 42; +} + +foo(); diff --git a/tests/testdata/fmt/regular/formatted2.ts b/tests/testdata/fmt/regular/formatted2.ts new file mode 100644 index 000000000..4a8036806 --- /dev/null +++ b/tests/testdata/fmt/regular/formatted2.ts @@ -0,0 +1,5 @@ +function bar(): number { + return 42; +} + +bar(); diff --git a/tests/testdata/fmt/regular/formatted3.markdown b/tests/testdata/fmt/regular/formatted3.markdown new file mode 100644 index 000000000..e6e616584 --- /dev/null +++ b/tests/testdata/fmt/regular/formatted3.markdown @@ -0,0 +1,17 @@ +# Hello + +```js +function foo() { + return 42; +} + +foo(); +``` + +```ts +function bar(): number { + return 42; +} + +bar(); +``` diff --git a/tests/testdata/fmt/regular/formatted4.jsonc b/tests/testdata/fmt/regular/formatted4.jsonc new file mode 100644 index 000000000..f0f72a6ed --- /dev/null +++ b/tests/testdata/fmt/regular/formatted4.jsonc @@ -0,0 +1,4 @@ +{ + // Comment + "key": "value" +} diff --git a/tests/testdata/fmt/with_config/deno.deprecated.jsonc b/tests/testdata/fmt/with_config/deno.deprecated.jsonc new file mode 100644 index 000000000..e053233fd --- /dev/null +++ b/tests/testdata/fmt/with_config/deno.deprecated.jsonc @@ -0,0 +1,20 @@ +{ + "fmt": { + "files": { + "include": [ + "./subdir/" + ], + "exclude": [ + "./subdir/b.ts" + ] + }, + "options": { + "useTabs": true, + "lineWidth": 40, + "indentWidth": 8, + "singleQuote": true, + "proseWrap": "always", + "semiColons": false + } + } +} diff --git a/tests/testdata/fmt/with_config/deno.jsonc b/tests/testdata/fmt/with_config/deno.jsonc new file mode 100644 index 000000000..ffd265dcd --- /dev/null +++ b/tests/testdata/fmt/with_config/deno.jsonc @@ -0,0 +1,16 @@ +{ + "fmt": { + "include": [ + "./subdir/" + ], + "exclude": [ + "./subdir/b.ts" + ], + "useTabs": true, + "lineWidth": 40, + "indentWidth": 8, + "singleQuote": true, + "proseWrap": "always", + "semiColons": false + } +} diff --git a/tests/testdata/fmt/with_config/subdir/a.ts b/tests/testdata/fmt/with_config/subdir/a.ts new file mode 100644 index 000000000..5474b3aa3 --- /dev/null +++ b/tests/testdata/fmt/with_config/subdir/a.ts @@ -0,0 +1,46 @@ +Deno.test( + { perms: { net: true } }, + async function responseClone() { + const response = + await fetch( + 'http://localhost:4545/assets/fixture.json', + ) + const response1 = + response.clone() + assert( + response !== + response1, + ) + assertEquals( + response.status, + response1 + .status, + ) + assertEquals( + response.statusText, + response1 + .statusText, + ) + const u8a = + new Uint8Array( + await response + .arrayBuffer(), + ) + const u8a1 = + new Uint8Array( + await response1 + .arrayBuffer(), + ) + for ( + let i = 0; + i < + u8a.byteLength; + i++ + ) { + assertEquals( + u8a[i], + u8a1[i], + ) + } + }, +) diff --git a/tests/testdata/fmt/with_config/subdir/b.ts b/tests/testdata/fmt/with_config/subdir/b.ts new file mode 100644 index 000000000..d7eb08b09 --- /dev/null +++ b/tests/testdata/fmt/with_config/subdir/b.ts @@ -0,0 +1,15 @@ +// This file should be excluded from formatting +Deno.test( + { perms: { net: true } }, + async function fetchBodyUsedCancelStream() { + const response = await fetch( + "http://localhost:4545/assets/fixture.json", + ); + assert(response.body !== null); + + assertEquals(response.bodyUsed, false); + const promise = response.body.cancel(); + assertEquals(response.bodyUsed, true); + await promise; + }, +);
\ No newline at end of file diff --git a/tests/testdata/fmt/with_config/subdir/c.md b/tests/testdata/fmt/with_config/subdir/c.md new file mode 100644 index 000000000..012f7e3d4 --- /dev/null +++ b/tests/testdata/fmt/with_config/subdir/c.md @@ -0,0 +1,17 @@ +## Permissions + +Deno is secure by default. Therefore, +unless you specifically enable it, a +program run with Deno has no file, +network, or environment access. Access +to security sensitive functionality +requires that permisisons have been +granted to an executing script through +command line flags, or a runtime +permission prompt. + +For the following example `mod.ts` has +been granted read-only access to the +file system. It cannot write to the file +system, or perform any other security +sensitive functions. |
