Protection against "<caret>" missing in test data
Many incorrect tests fixed
This commit is contained in:
+1
@@ -38,6 +38,7 @@ abstract class KotlinFixtureCompletionBaseTestCase : KotlinLightCodeInsightFixtu
|
||||
|
||||
try {
|
||||
val fileText = FileUtil.loadFile(File(testPath), true)
|
||||
assertTrue("\"<caret>\" is missing in file \"$testPath\"", fileText.contains("<caret>"));
|
||||
|
||||
if (ExpectedCompletionUtils.shouldRunHighlightingBeforeCompletion(fileText)) {
|
||||
myFixture.doHighlighting()
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (foo == null) {
|
||||
<caret>if (foo == null) {
|
||||
null
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
fun foo(y: Int, z: Int) = y - z
|
||||
|
||||
val x = { second: Int, first: Int -> foo(first, second) }
|
||||
val x = { second: Int, first: Int -> <caret>foo(first, second) }
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun foo(a: Boolean): Boolean {
|
||||
return !a
|
||||
return <caret>!a
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
fun foo(p: Boolean): String {
|
||||
return bar() ?: return "a"
|
||||
<caret>return bar() ?: return "a"
|
||||
}
|
||||
|
||||
fun bar(): String? = null
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
data class XY(val x: Int, val y: Int)
|
||||
fun test(xys: Array<XY>) {
|
||||
for (xy in xys) {
|
||||
for (<caret>xy in xys) {
|
||||
val x = xy.x
|
||||
println(x)
|
||||
val y = xy.y + x
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.*
|
||||
|
||||
fun foo(list: List<String>): String? {
|
||||
val random = Random()
|
||||
for (s in list) {
|
||||
<caret>for (s in list) {
|
||||
if (random.nextBoolean()) {
|
||||
return s
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
class Foo {
|
||||
lateinit var bar: String
|
||||
<caret>lateinit var bar: String
|
||||
|
||||
fun init() {
|
||||
bar = ""
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
fun foo(a: Float) {
|
||||
1f..a - 1
|
||||
1f<caret>..a - 1
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
fun <T> doSomething(a: T) {}
|
||||
|
||||
fun main(x: Int) {
|
||||
if (x !in 5..6) {
|
||||
if (x <caret>!in 5..6) {
|
||||
doSomething("test")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
fun <T> doSomething(a: T) {}
|
||||
|
||||
fun main(x: Int) {
|
||||
if (x !is Int) {
|
||||
if (x <caret>!is Int) {
|
||||
doSomething("test")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,5 +2,5 @@
|
||||
// ERROR: Unresolved reference: TTT
|
||||
|
||||
class {
|
||||
val t: TTT = null
|
||||
val t: <caret>TTT = null
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,5 +3,5 @@
|
||||
// ERROR: Function declaration must have a name
|
||||
|
||||
fun () {
|
||||
val tttt : TTTTT = null
|
||||
val tttt : <caret>TTTTT = null
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,5 +2,5 @@
|
||||
// ERROR: Unresolved reference: TTT
|
||||
|
||||
object {
|
||||
val t : TTT = null
|
||||
val t : <caret>TTT = null
|
||||
}
|
||||
+1
-1
@@ -2,5 +2,5 @@
|
||||
// ERROR: Unresolved reference: TTT
|
||||
|
||||
fun f(: Int) {
|
||||
val t: TTT = null
|
||||
val t: <caret>TTT = null
|
||||
}
|
||||
+1
-1
@@ -3,6 +3,6 @@
|
||||
|
||||
val : Int
|
||||
get() {
|
||||
val t : TTT = null
|
||||
val t : <caret>TTT = null
|
||||
return 1
|
||||
}
|
||||
@@ -1,4 +1,12 @@
|
||||
// "Create function" "false"
|
||||
// ACTION: Create extension function 'Collection<List<String>>.firstOrNull'
|
||||
// ACTION: Create extension function 'Unit.equals'
|
||||
// ACTION: Create local variable 'maximumSizeOfGroup'
|
||||
// ACTION: Create object 'maximumSizeOfGroup'
|
||||
// ACTION: Create parameter 'maximumSizeOfGroup'
|
||||
// ACTION: Create property 'maximumSizeOfGroup'
|
||||
// ACTION: Introduce local variable
|
||||
// ACTION: Rename reference
|
||||
// ERROR: A 'return' expression required in a function with a block body ('{...}')
|
||||
// ERROR: The expression cannot be a selector (occur after a dot)
|
||||
// ERROR: Type inference failed: inline fun <T> Iterable<T>.firstOrNull(predicate: (T) -> Boolean): T?<br>cannot be applied to<br>receiver: Collection<List<String>> arguments: ((List<String>) -> () -> Boolean)<br>
|
||||
@@ -9,5 +17,5 @@ fun doSomethingStrangeWithCollection(collection: Collection<String>): Collection
|
||||
val groupsByLength = collection.groupBy { s -> { s.length } }
|
||||
|
||||
val maximumSizeOfGroup = groupsByLength.values.maxBy { it.size }.
|
||||
return groupsByLength.values.firstOrNull { group -> {group.size == maximumSizeOfGroup} }
|
||||
return groupsByLength.values.firstOrNull { group -> {group.size == <caret>maximumSizeOfGroup} }
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
// "Create subclass" "false"
|
||||
// ACTION: Create test
|
||||
|
||||
class Base
|
||||
class <caret>Base
|
||||
@@ -1,3 +1,4 @@
|
||||
// "class org.jetbrains.kotlin.idea.intentions.CreateKotlinSubClassIntention" "false"
|
||||
// ACTION: Create test
|
||||
|
||||
abstract class Base(val x: Int)
|
||||
abstract class <caret>Base(val x: Int)
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
// "class org.jetbrains.kotlin.idea.intentions.CreateKotlinSubClassIntention" "false"
|
||||
// ACTION: Create test
|
||||
|
||||
abstract class Base private constructor
|
||||
abstract class <caret>Base private constructor
|
||||
Vendored
+1
-1
@@ -9,5 +9,5 @@ interface B {
|
||||
}
|
||||
|
||||
interface C : A, B {
|
||||
override fun foo(): Long
|
||||
override fun foo(): <caret>Long
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
enum class E {
|
||||
A {
|
||||
fun foo(): String?? = null
|
||||
fun foo(): String??<caret> = null
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
fun foo() {
|
||||
val a = 1
|
||||
a
|
||||
<caret>a
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
// "Specify type explicitly" "false"
|
||||
// ERROR: This property must either have a type annotation, be initialized or be delegated
|
||||
// ACTION: Convert member to extension
|
||||
// ACTION: Convert property to function
|
||||
// ACTION: Move to companion object
|
||||
|
||||
class A {
|
||||
val a
|
||||
val a<caret>
|
||||
get() = a
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
// "Cast expression 'Foo<Number>()' to 'Foo<Int>'" "false"
|
||||
// ACTION: Create test
|
||||
// ACTION: Change 'foo' function return type to 'Foo<Number>'
|
||||
// ACTION: Convert to expression body
|
||||
// ERROR: Type mismatch: inferred type is Foo<Number> but Foo<Int> was expected
|
||||
class Foo<T>
|
||||
|
||||
fun foo(): Foo<Int> {
|
||||
return Foo<Number>()
|
||||
return <caret>Foo<Number>()
|
||||
}
|
||||
@@ -1,12 +1,16 @@
|
||||
// "???" "false"
|
||||
//ERROR: Type mismatch: inferred type is Array<out Int> but Array<out String> was expected
|
||||
// ERROR: Type mismatch: inferred type is Array<out Int> but Array<out String> was expected
|
||||
// ACTION: Change parameter 't' type of function 'join' to 'Array<out Int>'
|
||||
// ACTION: Create function 'join'
|
||||
// ACTION: Flip ','
|
||||
// ACTION: Introduce local variable
|
||||
|
||||
//this test checks that there is no ArrayIndexOutOfBoundsException when there are more arguments than parameters
|
||||
fun <T> array1(vararg a : T) = a
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
val b = array1(1, 1)
|
||||
join(1, "4", *b, "3")
|
||||
join(1, "4", *b<caret>, "3")
|
||||
}
|
||||
|
||||
fun join(x : Int, vararg t : String) : String = "$x$t"
|
||||
|
||||
@@ -136,6 +136,8 @@ public abstract class AbstractIntentionTest extends KotlinCodeInsightTestCase {
|
||||
|
||||
String fileText = FileUtil.loadFile(mainFile, true);
|
||||
|
||||
assertTrue("\"<caret>\" is missing in file \"" + mainFile + "\"", fileText.contains("<caret>"));
|
||||
|
||||
String minJavaVersion = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// MIN_JAVA_VERSION: ");
|
||||
if (minJavaVersion != null && !SystemInfo.isJavaVersionAtLeast(minJavaVersion)) return;
|
||||
|
||||
|
||||
@@ -220,6 +220,8 @@ public abstract class AbstractQuickFixMultiFileTest extends KotlinDaemonAnalyzer
|
||||
|
||||
configureByExistingFile(virtualFiles.get(beforeFile));
|
||||
assertEquals(guessFileType(beforeFile), myFile.getVirtualFile().getFileType());
|
||||
|
||||
assertTrue("\"<caret>\" is probably missing in file \"" + beforeFile.path + "\"", myEditor.getCaretModel().getOffset() != 0);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -141,6 +141,7 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase {
|
||||
List<String> fixtureClasses = Collections.emptyList();
|
||||
try {
|
||||
fileText = FileUtil.loadFile(testFile, CharsetToolkit.UTF8_CHARSET);
|
||||
assertTrue("\"<caret>\" is missing in file \"" + testName + "\"", fileText.contains("<caret>"));
|
||||
|
||||
fixtureClasses = InTextDirectivesUtils.findListWithPrefixes(fileText, "// FIXTURE_CLASS: ");
|
||||
for (String fixtureClass : fixtureClasses) {
|
||||
|
||||
Reference in New Issue
Block a user