Skip to content

Commit

Permalink
adjust test case
Browse files Browse the repository at this point in the history
  • Loading branch information
mmews committed Aug 14, 2024
1 parent 7b61a85 commit fdeb72f
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ public void testStableCycleNoRebuild() {
Pair.of(CFG_DEPENDENCIES, "P2"))),
Pair.of("P2", List.of(
Pair.of("M2",
"import {C1} from 'M1'; \n" +
"const x: C1 = null;\n" +
"x;"),
"export public class C2 {}"),
Pair.of(CFG_DEPENDENCIES, "P1"))));

startAndWaitForLspServer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ export public class C1 {
"""),
"P2", Map.of(
"M2", """
import {C1} from "M1";
const x: C1 = null;
x;
export public class C2 {}
""",
CFG_DEPENDENCIES, """
P1
Expand All @@ -58,10 +56,45 @@ export public class C1 {
"""),
"P2", Map.of(
"M2", """
import {C1} from "M1";
export public class C2 {}
""",
CFG_DEPENDENCIES, """
P1
"""));

private static Map<String, Map<String, String>> testData3 = Map.of(
"P1", Map.of(
"M1", """
export public class C1 {
}
""",
"I1A", """
import {C2} from "M2"; // expect error
const x: C2 = null;
x;
""",
"I1B", """
import {C1} from "M1"; // expect no error
const x: C1 = null;
x;
""",
CFG_DEPENDENCIES, """
P2
"""),
"P2", Map.of(
"M2", """
export public class C2 {}
""",
"I2A", """
import {C1} from "M1"; // expect error
const x: C1 = null;
x;
""",
"I2B", """
import {C2} from "M2"; // expect no error
const x: C2 = null;
x;
""",
CFG_DEPENDENCIES, """
P1
"""));
Expand Down Expand Up @@ -169,7 +202,8 @@ public void testOnlyDirtyStateBuildInsideCycle() {
"P1/package.json", List.of(
"(Error, [14:18 - 14:22], Dependency cycle of the projects: yarn-test-project/packages/P1, yarn-test-project/packages/P2.)"),
"P2/package.json", List.of(
"(Error, [14:18 - 14:22], Dependency cycle of the projects: yarn-test-project/packages/P1, yarn-test-project/packages/P2.)")));
"(Error, [14:18 - 14:22], Dependency cycle of the projects: yarn-test-project/packages/P1, yarn-test-project/packages/P2.)"),
"M1", List.of("(Error, [0:25 - 1:0], extraneous input '#\\n' expecting '}')")));
}

@Test
Expand Down Expand Up @@ -210,7 +244,8 @@ public void testBuildDirtyAfterRemoveCycle1() {
"P1/package.json", List.of(
"(Error, [14:18 - 14:22], Dependency cycle of the projects: yarn-test-project/packages/P1, yarn-test-project/packages/P2.)"),
"P2/package.json", List.of(
"(Error, [14:18 - 14:22], Dependency cycle of the projects: yarn-test-project/packages/P1, yarn-test-project/packages/P2.)")));
"(Error, [14:18 - 14:22], Dependency cycle of the projects: yarn-test-project/packages/P1, yarn-test-project/packages/P2.)"),
"M1", List.of("(Error, [0:25 - 1:0], extraneous input '#\\n' expecting '}')")));

// remove cycle
openFile("P1/package.json");
Expand Down Expand Up @@ -261,4 +296,25 @@ public void testBuildDirtyAfterRemoveCycle2() {
assertIssues2(Map.of(
"M1", List.of("(Error, [0:25 - 1:0], extraneous input '#\\n' expecting '}')")));
}

@Test
public void testCycleImportErrors() {
testWorkspaceManager.createTestOnDisk(testData3);

startAndWaitForLspServer();

assertIssues2(Map.of(
"P1/package.json", List.of(
"(Error, [14:18 - 14:22], Dependency cycle of the projects: yarn-test-project/packages/P1, yarn-test-project/packages/P2.)"),
"P2/package.json", List.of(
"(Error, [14:18 - 14:22], Dependency cycle of the projects: yarn-test-project/packages/P1, yarn-test-project/packages/P2.)"),

"I1A",
List.of("(Error, [0:17 - 0:21], Couldn't resolve reference to TModule 'M2'.)",
"(Error, [1:9 - 1:11], Couldn't resolve reference to Type 'C2'.)"),
"I2A",
List.of("(Error, [0:17 - 0:21], Cannot resolve plain module specifier (without project name as first segment): no matching module found.)",
"(Error, [1:9 - 1:11], Couldn't resolve reference to Type 'C1'.)")));

}
}

0 comments on commit fdeb72f

Please sign in to comment.