@@ -7,27 +7,109 @@ import scala.tools.refactoring.tests.util.{TestHelper, TestRefactoring}
77class ImplementMethodsTest extends TestHelper with TestRefactoring {
88 outer =>
99
10- val fromSource =
10+ def implementMethods (pro : FileSet ) = new TestRefactoringImpl (pro) {
11+ override val refactoring = new ImplementMethods with TestProjectIndex
12+ val changes = performRefactoring(())
13+ }.changes
14+
15+ @ Test
16+ def implementMethodFromFirstMixing () = new FileSet () {
1117 """
1218 |package implementMethods
1319 |
1420 |trait T {
1521 | def f(x: Int): String
1622 |}
1723 |
18- |object Obj extends /*(*/T/*)*/ {
24+ |trait S {
25+ | def g(x: Int): Int
26+ |}
1927 |
20- | def g(x: Int): Int = 1
28+ |object Obj extends /*(*/T/*)*/ with S {
29+ | val x: Int = ???
30+ |}
31+ """ .stripMargin becomes
32+ """
33+ |package implementMethods
34+ |
35+ |trait T {
36+ | def f(x: Int): String
37+ |}
38+ |
39+ |trait S {
40+ | def g(x: Int): Int
41+ |}
42+ |
43+ |object Obj extends /*(*/T/*)*/ with S {
44+ | val x: Int = ???
45+ |
46+ | def f(x: Int): String = {
47+ | ???
48+ | }
49+ |}
50+ """ .stripMargin
51+ } applyRefactoring implementMethods
52+
53+ @ Test
54+ def implementMethodFromSecondMixing () = new FileSet () {
55+ """
56+ |package implementMethods
57+ |
58+ |trait T {
59+ | def f(x: Int): String
60+ |}
61+ |
62+ |trait S {
63+ | def g(x: Int): Int
64+ |}
65+ |
66+ |object Obj extends T with /*(*/S/*)*/ {
67+ | val x: Int = ???
68+ |}
69+ """ .stripMargin becomes
70+ """
71+ |package implementMethods
72+ |
73+ |trait T {
74+ | def f(x: Int): String
75+ |}
2176 |
77+ |trait S {
78+ | def g(x: Int): Int
79+ |}
80+ |
81+ |object Obj extends T with /*(*/S/*)*/ {
82+ | val x: Int = ???
83+ |
84+ | def g(x: Int): Int = {
85+ | ???
86+ | }
2287 |}
2388 """ .stripMargin
89+ } applyRefactoring implementMethods
2490
25- val toSource =
91+ @ Test
92+ def implementMethodsNotImplemented () = new FileSet () {
2693 """
2794 |package implementMethods
2895 |
2996 |trait T {
3097 | def f(x: Int): String
98+ | def g(x: Int): Int
99+ |}
100+ |
101+ |object Obj extends /*(*/T/*)*/ {
102+ |
103+ | def g(x: Int): Int = 1
104+ |
105+ |}
106+ """ .stripMargin becomes
107+ """
108+ |package implementMethods
109+ |
110+ |trait T {
111+ | def f(x: Int): String
112+ | def g(x: Int): Int
31113 |}
32114 |
33115 |object Obj extends /*(*/T/*)*/ {
@@ -40,15 +122,6 @@ class ImplementMethodsTest extends TestHelper with TestRefactoring {
40122 |
41123 |}
42124 """ .stripMargin
43-
44- def implementMethods (pro : FileSet ) = new TestRefactoringImpl (pro) {
45- override val refactoring = new ImplementMethods with TestProjectIndex
46- val changes = performRefactoring(())
47- }.changes
48-
49- @ Test
50- def doRefactor () = new FileSet () {
51- fromSource becomes toSource
52125 } applyRefactoring implementMethods
53126
54127}
0 commit comments