Support destructuring declarations in scratch files

#KT-25038 fixed
This commit is contained in:
Ilya Chernikov
2020-12-17 19:25:41 +01:00
parent 9ee17cd610
commit 0671fd9aaa
5 changed files with 50 additions and 0 deletions
@@ -31,6 +31,11 @@ public class ScratchRunActionTestGenerated extends AbstractScratchRunActionTest
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/scripting-support/testData/scratch"), Pattern.compile("^(.+)\\.kts$"), null, false);
}
@TestMetadata("destructuringDecls.kts")
public void testDestructuringDecls() throws Exception {
runTest("idea/scripting-support/testData/scratch/destructuringDecls.kts");
}
@TestMetadata("for.kts")
public void testFor() throws Exception {
runTest("idea/scripting-support/testData/scratch/for.kts");
@@ -119,6 +124,11 @@ public class ScratchRunActionTestGenerated extends AbstractScratchRunActionTest
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/scripting-support/testData/scratch"), Pattern.compile("^(.+)\\.kts$"), null, false);
}
@TestMetadata("destructuringDecls.kts")
public void testDestructuringDecls() throws Exception {
runTest("idea/scripting-support/testData/scratch/destructuringDecls.kts");
}
@TestMetadata("for.kts")
public void testFor() throws Exception {
runTest("idea/scripting-support/testData/scratch/for.kts");
@@ -0,0 +1,7 @@
// REPL_MODE: false
val (foo, bar) = 1 to "2" // RESULT: val foo: Int; val bar: String
foo // RESULT: 1
bar // RESULT: 2
val (_, baz) = 3 to "4" // RESULT: val baz: String
baz // RESULT: 4
@@ -0,0 +1,7 @@
// REPL_MODE: ~REPL_MODE~
val (foo, bar) = 1 to "2"
foo
bar
val (_, baz) = 3 to "4"
baz
@@ -0,0 +1,7 @@
// REPL_MODE: true
val (foo, bar) = 1 to "2"
foo // RESULT: res1: kotlin.Int = 1
bar // RESULT: res2: kotlin.String = 2
val (_, baz) = 3 to "4"
baz // RESULT: res4: kotlin.String = 4