Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update some tests #13176

Merged
merged 2 commits into from Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions tests/config/format-test.js
Expand Up @@ -52,8 +52,6 @@ const espreeDisabledTests = new Set(
[
// These tests only work for `babel`
"comments-closure-typecast",
// Unknown reason https://github.com/babel/babel/pull/14779#discussion_r928137651
"strings",
].map((directory) => path.join(__dirname, "../format/js", directory))
);
const acornDisabledTests = espreeDisabledTests;
Expand Down
44 changes: 44 additions & 0 deletions tests/format/js/strings/__snapshots__/jsfmt.spec.js.snap
@@ -1,5 +1,49 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`non-octal-eight-and-nine.js [acorn] format 1`] = `
"Invalid escape sequence (3:3)
1 | // https://github.com/babel/babel/pull/11852
2 |
> 3 | "\\8","\\9";
| ^
4 | () => {
5 | "use strict";
6 | "\\8", "\\9";"
`;

exports[`non-octal-eight-and-nine.js [espree] format 1`] = `
"Invalid escape sequence (3:3)
1 | // https://github.com/babel/babel/pull/11852
2 |
> 3 | "\\8","\\9";
| ^
4 | () => {
5 | "use strict";
6 | "\\8", "\\9";"
`;

exports[`non-octal-eight-and-nine.js - {"trailingComma":"all"} [acorn] format 1`] = `
"Invalid escape sequence (3:3)
1 | // https://github.com/babel/babel/pull/11852
2 |
> 3 | "\\8","\\9";
| ^
4 | () => {
5 | "use strict";
6 | "\\8", "\\9";"
`;

exports[`non-octal-eight-and-nine.js - {"trailingComma":"all"} [espree] format 1`] = `
"Invalid escape sequence (3:3)
1 | // https://github.com/babel/babel/pull/11852
2 |
> 3 | "\\8","\\9";
| ^
4 | () => {
5 | "use strict";
6 | "\\8", "\\9";"
`;

exports[`non-octal-eight-and-nine.js - {"trailingComma":"all"} format 1`] = `
====================================options=====================================
parsers: ["babel", "flow"]
Expand Down
15 changes: 13 additions & 2 deletions tests/format/js/strings/jsfmt.spec.js
@@ -1,2 +1,13 @@
run_spec(import.meta, ["babel", "flow"]);
run_spec(import.meta, ["babel", "flow"], { trailingComma: "all" });
run_spec(import.meta, ["babel", "flow"], {
errors: {
acorn: ["non-octal-eight-and-nine.js"],
espree: ["non-octal-eight-and-nine.js"],
},
});
run_spec(import.meta, ["babel", "flow"], {
trailingComma: "all",
errors: {
acorn: ["non-octal-eight-and-nine.js"],
espree: ["non-octal-eight-and-nine.js"],
},
});
Expand Up @@ -140,9 +140,6 @@ parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
// valid JSX
<in T>() => {}</in>;

type Covariant<out T> = {
x: T;
}
Expand Down Expand Up @@ -206,9 +203,6 @@ declare class StateNode<TContext, in out TEvent extends { type: string }> {
}

=====================================output=====================================
// valid JSX
<in T>() => {}</in>;

type Covariant<out T> = {
x: T;
};
Expand Down Expand Up @@ -283,3 +277,137 @@ exports[`with-jsx.tsx [typescript] format 1`] = `
4 | type Covariant<out T> = {
5 | x: T;"
`;

exports[`with-jsx.tsx format 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
type Covariant<out T> = {
x: T;
}
type Contravariant<in T> = {
f: (x: T) => void;
}
type Invariant<in out T> = {
f: (x: T) => T;
}
type T10<out T> = T;
type T11<in T> = keyof T;
type T12<out T, out K extends keyof T> = T[K];
type T13<in out T> = T[keyof T];

type Covariant1<in T> = {
x: T;
}

type Contravariant1<out T> = keyof T;

type Contravariant2<out T> = {
f: (x: T) => void;
}

type Invariant1<in T> = {
f: (x: T) => T;
}

type Invariant2<out T> = {
f: (x: T) => T;
}
type Foo1<in T> = {
x: T;
f: FooFn1<T>;
}

type Foo2<out T> = {
x: T;
f: FooFn2<T>;
}

type Foo3<in out T> = {
x: T;
f: FooFn3<T>;
}

type T21<in out T> = T;

interface Baz<out T> {}
interface Baz<in T> {}

interface Parent<out A> {
child: Child<A> | null;
parent: Parent<A> | null;
}

declare class StateNode<TContext, in out TEvent extends { type: string }> {
_storedEvent: TEvent;
_action: ActionObject<TEvent>;
_state: StateNode<TContext, any>;
}

=====================================output=====================================
type Covariant<out T> = {
x: T;
};
type Contravariant<in T> = {
f: (x: T) => void;
};
type Invariant<in out T> = {
f: (x: T) => T;
};
type T10<out T> = T;
type T11<in T> = keyof T;
type T12<out T, out K extends keyof T> = T[K];
type T13<in out T> = T[keyof T];

type Covariant1<in T> = {
x: T;
};

type Contravariant1<out T> = keyof T;

type Contravariant2<out T> = {
f: (x: T) => void;
};

type Invariant1<in T> = {
f: (x: T) => T;
};

type Invariant2<out T> = {
f: (x: T) => T;
};
type Foo1<in T> = {
x: T;
f: FooFn1<T>;
};

type Foo2<out T> = {
x: T;
f: FooFn2<T>;
};

type Foo3<in out T> = {
x: T;
f: FooFn3<T>;
};

type T21<in out T> = T;

interface Baz<out T> {}
interface Baz<in T> {}

interface Parent<out A> {
child: Child<A> | null;
parent: Parent<A> | null;
}

declare class StateNode<TContext, in out TEvent extends { type: string }> {
_storedEvent: TEvent;
_action: ActionObject<TEvent>;
_state: StateNode<TContext, any>;
}

================================================================================
`;
4 changes: 1 addition & 3 deletions tests/format/typescript/optional-variance/jsfmt.spec.js
@@ -1,3 +1 @@
run_spec(import.meta, ["typescript"], {
errors: { typescript: ["with-jsx.tsx"] },
});
run_spec(import.meta, ["typescript"]);
3 changes: 0 additions & 3 deletions tests/format/typescript/optional-variance/with-jsx.tsx
@@ -1,6 +1,3 @@
// valid JSX
<in T>() => {}</in>;

type Covariant<out T> = {
x: T;
}
Expand Down