-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tests] Factor out common language injection test code to avoid code …
…duplication #SCL-23251
- Loading branch information
Showing
4 changed files
with
63 additions
and
66 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
...tion/intellilang/test/org/jetbrains/plugins/scala/injection/InjectionInBodyTestBase.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.jetbrains.plugins.scala.injection | ||
|
||
abstract class InjectionInBodyTestBase extends ScalaLanguageInjectionTestBase { | ||
|
||
protected val Quotes: String = "\"\"\"" | ||
protected lazy val LanguageAnnotationDef: String = scalaInjectionTestFixture.LanguageAnnotationDef | ||
|
||
protected def doTestInBody(languageId: String, classBody: String, injectedFileExpectedText: String): Unit = { | ||
val classBodyWithIndent = classBody.replaceAll("\n", "\n ") | ||
val text = | ||
s"""class A { | ||
| $classBodyWithIndent | ||
|} | ||
|""".stripMargin | ||
scalaInjectionTestFixture.doTest(languageId, text, injectedFileExpectedText) | ||
} | ||
|
||
protected def doAnnotationTestInBody(languageId: String, classBody: String, injectedFileExpectedText: String): Unit = { | ||
val classBodyWithIndent = classBody.replaceAll("\n", "\n ") | ||
val text = | ||
s"""$LanguageAnnotationDef | ||
|class A { | ||
| $classBodyWithIndent | ||
|} | ||
|""".stripMargin | ||
scalaInjectionTestFixture.doTest(languageId, text, injectedFileExpectedText) | ||
} | ||
|
||
protected def doAnnotationTest(languageId: String, text: String, injectedFileExpectedText: String): Unit = { | ||
val textFinal = | ||
s"""$LanguageAnnotationDef | ||
|$text | ||
|""".stripMargin | ||
scalaInjectionTestFixture.doTest(languageId, textFinal, injectedFileExpectedText) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
.../intellilang/test/org/jetbrains/plugins/scala/injection/InjectionViaCommentTestBase.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.jetbrains.plugins.scala.injection | ||
|
||
import org.jetbrains.plugins.scala.extensions.StringExt | ||
import org.jetbrains.plugins.scala.injection.ScalaInjectionTestFixture.{ExpectedInjection, ShredInfo} | ||
|
||
abstract class InjectionViaCommentTestBase extends ScalaLanguageInjectionTestBase { | ||
protected def doInjectedViaCommentTest( | ||
languageId: String, | ||
text: String, | ||
expectedText: String, | ||
expectedShreds: Seq[ShredInfo] = null | ||
): Unit = { | ||
val textWithComment = | ||
s"""//language=$languageId | ||
|$text | ||
|""".stripMargin.replace("'''", "\"\"\"") | ||
val expectedInjection = ExpectedInjection( | ||
expectedText.withNormalizedSeparator, | ||
languageId, | ||
Option(expectedShreds) | ||
) | ||
scalaInjectionTestFixture.doTest(textWithComment, expectedInjection) | ||
} | ||
} |
24 changes: 2 additions & 22 deletions
24
...org/jetbrains/plugins/scala/injection/InterpolatedStringWithInjectionsMultilineTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 1 addition & 44 deletions
45
...on/intellilang/test/org/jetbrains/plugins/scala/injection/ScalaLanguageInjectorTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters