Permalink
Browse files

Make tests tolerant to differing fresh name suffixes

Makes these tests work with scala/scala#7203
  • Loading branch information...
retronym committed Oct 24, 2018
1 parent f82bf38 commit f5b91d8e44ae2b045ebf5382c7ec690cfd1df12e
@@ -266,7 +266,7 @@ class ExtractExtractorTest extends TestHelper with TestRefactoring {
}
}
"""
}.performRefactoring(extract(0)).assertEqualTree
}.performRefactoring(extract(0)).assertEqualTreeIgnoringFreshNames
@Test
def avoidNameCollisions() = new FileSet{
@@ -343,7 +343,7 @@ class ExtractValueTest extends TestHelper with TestRefactoring {
}
}
"""
}.performRefactoring(extract(0)).assertEqualTree
}.performRefactoring(extract(0)).assertEqualTreeIgnoringFreshNames
@Test
def dontExtractWildcardPatterns() = new FileSet(expectCompilingCode = false) {
@@ -364,7 +364,7 @@ class ExtractValueTest extends TestHelper with TestRefactoring {
}
}
"""
}.performRefactoring(extract(0)).assertEqualTree
}.performRefactoring(extract(0)).assertEqualTreeIgnoringFreshNames
@Test
def extractIntoNewValBlock() = new FileSet{
@@ -281,6 +281,14 @@ trait TestHelper extends TestRules with Refactoring with CompilerProvider with c
}
assertEquals(expected, actual)
}
def assertEqualTreeIgnoringFreshNames() = withResultTree { actualTree =>
val expectedTree = treeFrom(srcs.head._2.code)
def clean(s: String) = s.replaceAll("""\$\d+""", """\$""")
val (expected, actual) = global.ask { () =>
(clean(expectedTree.toString()), clean(actualTree.toString()))
}
assertEquals(expected, actual)
}
}
}

0 comments on commit f5b91d8

Please sign in to comment.