@@ -2,17 +2,21 @@ package com.intellij.plugin.powershell.lang
2
2
3
3
import com.intellij.openapi.command.WriteCommandAction
4
4
import com.intellij.plugin.powershell.psi.PowerShellStringLiteralExpression
5
+ import com.intellij.plugin.powershell.testFramework.PowerShellCodeInsightTestBase
5
6
import com.intellij.psi.util.PsiTreeUtil
6
- import com.intellij.testFramework.fixtures.BasePlatformTestCase
7
+ import com.intellij.testFramework.junit5.TestApplication
8
+ import org.junit.jupiter.api.Test
7
9
import java.io.File
8
10
9
- class PowerShellCodeInsightTest : BasePlatformTestCase () {
11
+ @TestApplication
12
+ class PowerShellCodeInsightTest : PowerShellCodeInsightTestBase () {
10
13
11
14
private val TEST_DATA_PATH = " src" + File .separatorChar + " test" + File .separatorChar + " resources" + File .separatorChar +
12
15
" testData"
13
16
14
17
override fun getTestDataPath () = TEST_DATA_PATH
15
18
19
+ @Test
16
20
fun testDecodeExpandableString () {
17
21
// quotes
18
22
checkStringDecode(" This is sample host \"\" double quoted\"\" string" ,
@@ -44,6 +48,7 @@ class PowerShellCodeInsightTest : BasePlatformTestCase() {
44
48
" $(dsdkkdkd) $(ddd) \" $(sss)sasa $(wqwq) \$ eee $(" )
45
49
}
46
50
51
+ @Test
47
52
fun testDecodeExpandableHereString () {
48
53
// quotes
49
54
decodeExpandableHereString(" This is sample host \" string\" content" ,
@@ -83,6 +88,7 @@ class PowerShellCodeInsightTest : BasePlatformTestCase() {
83
88
" text1 `` \$ foo `` \" `'text2" )
84
89
}
85
90
91
+ @Test
86
92
fun testDecodeVerbatimString () {
87
93
// quotes
88
94
decodeVerbatimString(" This is sample host \" string\" content" ,
@@ -105,14 +111,15 @@ class PowerShellCodeInsightTest : BasePlatformTestCase() {
105
111
private fun decodeVerbatimHereString (stringContent : String , expectedOutText : String ) = checkStringDecode(stringContent, expectedOutText, false , true )
106
112
private fun decodeExpandableHereString (stringContent : String , expectedOutText : String ) = checkStringDecode(stringContent, expectedOutText, true , true )
107
113
114
+ @Test
108
115
fun testDecodeVerbatimHereString () {
109
116
decodeVerbatimHereString(" This is sample host \" string\" content" ,
110
117
" This is sample host \" string\" content" )
111
118
decodeVerbatimHereString(" This is sample host 'string' content" ,
112
119
" This is sample host 'string' content" )
113
120
}
114
121
115
-
122
+ @Test
116
123
fun testContentChangeExpandableString () {
117
124
// quotes
118
125
checkInjectedText(" var foo = \" text\" ;" ,
@@ -147,7 +154,7 @@ class PowerShellCodeInsightTest : BasePlatformTestCase() {
147
154
" `$(ddd) `\" `$(sss)sasa `$(wqwq) `\$ eee `$(" )
148
155
}
149
156
150
-
157
+ @Test
151
158
fun testContentChangeExpandableHereString () {
152
159
// quotes
153
160
updateExpandableHereString(" var foo = \" text\" ;" ,
@@ -163,6 +170,7 @@ class PowerShellCodeInsightTest : BasePlatformTestCase() {
163
170
" text1 `\$ newVar text2" )
164
171
}
165
172
173
+ @Test
166
174
fun testContentChangeVerbatimString () {
167
175
// quotes
168
176
updateVerbatimString(" var foo = \" text\" ;" ,
@@ -183,6 +191,7 @@ class PowerShellCodeInsightTest : BasePlatformTestCase() {
183
191
" test `\$ foo escape" )
184
192
}
185
193
194
+ @Test
186
195
fun testContentChangeVerbatimHereString () {
187
196
// quotes
188
197
updateVerbatimHereString(" var foo = \" text\" ;" ,
@@ -203,8 +212,9 @@ class PowerShellCodeInsightTest : BasePlatformTestCase() {
203
212
" test escape \$ foo chars" )
204
213
}
205
214
215
+ @Test
206
216
fun testFolding () {
207
- myFixture .testFolding(" $testDataPath /codeinsight/folding.ps1" )
217
+ codeInsightTestFixture .testFolding(" ${getTestDataPath()} /codeinsight/folding.ps1" )
208
218
}
209
219
210
220
private fun updateExpandableHereString (newInjectedText : String , expectedStringContent : String ) = checkInjectedText(newInjectedText, expectedStringContent, true , true )
@@ -214,9 +224,9 @@ class PowerShellCodeInsightTest : BasePlatformTestCase() {
214
224
// external editor -> PowerShell string
215
225
private fun checkInjectedText (newInjectedText : String , expectedStringContent : String , isExpandable : Boolean = true, isHere : Boolean = false, defaultText : String = "var foo = 1") {
216
226
val string = createStringExpression(isHere, isExpandable, defaultText)
217
- WriteCommandAction .writeCommandAction(project, myFixture .file).withName(" Test checkInjectedText. New Text='$newInjectedText '" ).run<Throwable > {
227
+ WriteCommandAction .writeCommandAction(project, codeInsightTestFixture .file).withName(" Test checkInjectedText. New Text='$newInjectedText '" ).run<Throwable > {
218
228
string.updateText(newInjectedText)
219
- val newString = PsiTreeUtil .findChildOfType(myFixture .file, PowerShellStringLiteralExpression ::class .java) ? : error(" file text='${myFixture .file} '" )
229
+ val newString = PsiTreeUtil .findChildOfType(codeInsightTestFixture .file, PowerShellStringLiteralExpression ::class .java) ? : error(" file text='${codeInsightTestFixture .file} '" )
220
230
assert (newString.getStringContent() == expectedStringContent) { " expected=\t '$expectedStringContent '\n actual=\t\t '${newString.getStringContent()} '" }
221
231
}
222
232
}
@@ -245,7 +255,7 @@ class PowerShellCodeInsightTest : BasePlatformTestCase() {
245
255
}
246
256
247
257
private fun createStringExpression (nodeText : String ): PowerShellStringLiteralExpression {
248
- val file = myFixture .configureByText(" foo.ps1" , nodeText)
258
+ val file = codeInsightTestFixture .configureByText(" foo.ps1" , nodeText)
249
259
return PsiTreeUtil .findChildOfType(file, PowerShellStringLiteralExpression ::class .java) ? : error(" text='$nodeText '" )
250
260
}
251
261
0 commit comments