diff --git a/libraries/examples/browser-example-with-library/src/test/kotlin/sample/SampleTest.kt b/libraries/examples/browser-example-with-library/src/test/kotlin/sample/SampleTest.kt index 756573911a2..9d86cfa69e4 100644 --- a/libraries/examples/browser-example-with-library/src/test/kotlin/sample/SampleTest.kt +++ b/libraries/examples/browser-example-with-library/src/test/kotlin/sample/SampleTest.kt @@ -10,7 +10,7 @@ import kotlin.test.* open class SampleTest { open val driver: WebDriver = HtmlUnitDriver(true) - test fun homePage(): Unit { + @test fun homePage(): Unit { driver.get("file://" + File("sample.html").getCanonicalPath()) Thread.sleep(1000) diff --git a/libraries/examples/browser-example/src/test/kotlin/sample/SampleTest.kt b/libraries/examples/browser-example/src/test/kotlin/sample/SampleTest.kt index ea896fb8bd6..97ff7b20da5 100644 --- a/libraries/examples/browser-example/src/test/kotlin/sample/SampleTest.kt +++ b/libraries/examples/browser-example/src/test/kotlin/sample/SampleTest.kt @@ -10,7 +10,7 @@ import kotlin.test.* open class SampleTest { open val driver: WebDriver = HtmlUnitDriver(true) - test fun homePage(): Unit { + @test fun homePage(): Unit { driver.get("file://" + File("sample.html").getCanonicalPath()) Thread.sleep(1000) diff --git a/libraries/examples/js-example/src/test/kotlin/sample/SampleTest.kt b/libraries/examples/js-example/src/test/kotlin/sample/SampleTest.kt index 188cf872975..07a3a7f604e 100644 --- a/libraries/examples/js-example/src/test/kotlin/sample/SampleTest.kt +++ b/libraries/examples/js-example/src/test/kotlin/sample/SampleTest.kt @@ -5,7 +5,8 @@ import sample.Hello import org.junit.Test class SampleTest { - Test fun dummy(): Unit { + @Test + fun dummy(): Unit { Hello().doSomething() } } diff --git a/libraries/kotlin-jdbc/src/main/kotlin/kotlin/template/Templates.kt b/libraries/kotlin-jdbc/src/main/kotlin/kotlin/template/Templates.kt index 4565e2a524b..bd72d30258d 100644 --- a/libraries/kotlin-jdbc/src/main/kotlin/kotlin/template/Templates.kt +++ b/libraries/kotlin-jdbc/src/main/kotlin/kotlin/template/Templates.kt @@ -7,7 +7,7 @@ import java.text.NumberFormat import java.text.DateFormat import java.util.Date -deprecated("This class is part of an experimental implementation of string templates and is going to be removed") +@Deprecated("This class is part of an experimental implementation of string templates and is going to be removed") public class StringTemplate(private val values: Array) { /** @@ -36,7 +36,7 @@ public class StringTemplate(private val values: Array) { * * See [[HtmlFormatter] and [[LocaleFormatter] respectively. */ -deprecated("This function is part of an experimental implementation of string templates and is going to be removed") +@Deprecated("This function is part of an experimental implementation of string templates and is going to be removed") public fun StringTemplate.toString(formatter: Formatter): String { val buffer = StringBuilder() append(buffer, formatter) @@ -47,7 +47,7 @@ public fun StringTemplate.toString(formatter: Formatter): String { * Appends the text representation of this string template to the given output * using the supplied formatter */ -deprecated("This function is part of an experimental implementation of string templates and is going to be removed") +@Deprecated("This function is part of an experimental implementation of string templates and is going to be removed") public fun StringTemplate.append(out: Appendable, formatter: Formatter): Unit { var constantText = true this.forEach { @@ -69,13 +69,13 @@ public fun StringTemplate.append(out: Appendable, formatter: Formatter): Unit { * Converts this string template to internationalised text using the supplied * [[LocaleFormatter]] */ -deprecated("This function is part of an experimental implementation of string templates and is going to be removed") +@Deprecated("This function is part of an experimental implementation of string templates and is going to be removed") public fun StringTemplate.toLocale(formatter: LocaleFormatter = LocaleFormatter()): String = toString(formatter) /** * Converts this string template to HTML text */ -deprecated("This function is part of an experimental implementation of string templates and is going to be removed") +@Deprecated("This function is part of an experimental implementation of string templates and is going to be removed") public fun StringTemplate.toHtml(formatter: HtmlFormatter = HtmlFormatter()): String = toString(formatter) /** @@ -83,7 +83,7 @@ public fun StringTemplate.toHtml(formatter: HtmlFormatter = HtmlFormatter()): St * how to format values for a particular [[Locale]] such as with the [[LocaleFormatter]] or * to escape particular characters in different output formats such as [[HtmlFormatter] */ -deprecated("This interface is part of an experimental implementation of string templates and is going to be removed") +@Deprecated("This interface is part of an experimental implementation of string templates and is going to be removed") public interface Formatter { public fun format(buffer: Appendable, value: Any?): Unit } @@ -92,7 +92,7 @@ public interface Formatter { * Formats strings with no special encoding other than allowing the null text to be * configured */ -deprecated("This class is part of an experimental implementation of string templates and is going to be removed") +@Deprecated("This class is part of an experimental implementation of string templates and is going to be removed") public open class ToStringFormatter : Formatter { private val nullString: String = "null" @@ -118,13 +118,13 @@ public open class ToStringFormatter : Formatter { } } -deprecated("This property is part of an experimental implementation of string templates and is going to be removed") +@Deprecated("This property is part of an experimental implementation of string templates and is going to be removed") public val defaultLocale: Locale = Locale.getDefault() /** * Formats values using a given [[Locale]] for internationalisation */ -deprecated("This class is part of an experimental implementation of string templates and is going to be removed") +@Deprecated("This class is part of an experimental implementation of string templates and is going to be removed") public open class LocaleFormatter(protected val locale: Locale = defaultLocale) : ToStringFormatter() { override fun toString(): String = "LocaleFormatter{$locale}" @@ -155,7 +155,7 @@ public open class LocaleFormatter(protected val locale: Locale = defaultLocale) /** * Formats values for HTML encoding, escaping special characters in HTML. */ -deprecated("This class is part of an experimental implementation of string templates and is going to be removed") +@Deprecated("This class is part of an experimental implementation of string templates and is going to be removed") public class HtmlFormatter(locale: Locale = defaultLocale) : LocaleFormatter(locale) { override fun toString(): String = "HtmlFormatter{$locale}" diff --git a/libraries/kotlin-jdbc/src/test/kotlin/test/kotlin/jdbc/JdbcTemplateTest.kt b/libraries/kotlin-jdbc/src/test/kotlin/test/kotlin/jdbc/JdbcTemplateTest.kt index 96f58db39da..ce211eca092 100644 --- a/libraries/kotlin-jdbc/src/test/kotlin/test/kotlin/jdbc/JdbcTemplateTest.kt +++ b/libraries/kotlin-jdbc/src/test/kotlin/test/kotlin/jdbc/JdbcTemplateTest.kt @@ -9,7 +9,7 @@ import test.kotlin.jdbc.* class JdbcTemplateTest { //val dataSource = createDataSource() - test fun templateInsert() { + @test fun templateInsert() { val id = 3 val name = "Stepan" diff --git a/libraries/kotlin-jdbc/src/test/kotlin/test/kotlin/jdbc/JdbcTest.kt b/libraries/kotlin-jdbc/src/test/kotlin/test/kotlin/jdbc/JdbcTest.kt index 2371469dd97..883260b0b7f 100644 --- a/libraries/kotlin-jdbc/src/test/kotlin/test/kotlin/jdbc/JdbcTest.kt +++ b/libraries/kotlin-jdbc/src/test/kotlin/test/kotlin/jdbc/JdbcTest.kt @@ -23,7 +23,7 @@ fun createDataSource() : DataSource { } class JdbcTest { - test fun queryWithIndexColumnAccess() { + @test fun queryWithIndexColumnAccess() { dataSource.query("select * from foo") { for (row in it) { println("id ${row[1]} and name: ${row[2]}") @@ -31,7 +31,7 @@ class JdbcTest { } } - test fun queryWithNamedColumnAccess() { + @test fun queryWithNamedColumnAccess() { // query using names dataSource.query("select * from foo") { for (row in it) { @@ -40,7 +40,7 @@ class JdbcTest { } } - test fun getValuesAsMap() { + @test fun getValuesAsMap() { dataSource.query("select * from foo") { for (row in it) { println(row.getValuesAsMap()) @@ -48,7 +48,7 @@ class JdbcTest { } } - test fun stringFormat() { + @test fun stringFormat() { dataSource.query(kotlin.template.StringTemplate(arrayOf("select * from foo where id = ", 1))) { for (row in it) { println(row.getValuesAsMap()) @@ -56,7 +56,7 @@ class JdbcTest { } } - test fun mapIterator() { + @test fun mapIterator() { val mapper = { rs: ResultSet -> "id: ${rs["id"]}" } @@ -68,7 +68,7 @@ class JdbcTest { } } - test fun map() { + @test fun map() { dataSource.query("select * from foo") { val rows = it.map { "id: ${it["id"]}" } for (row in rows) { @@ -77,13 +77,13 @@ class JdbcTest { } } - test fun count() { + @test fun count() { dataSource.query("select count(*) from foo") { println("count: ${it.singleInt()}") } } - test fun formatCursor() { + @test fun formatCursor() { dataSource.query("select * from foo") { println(it.getColumnNames().toList().joinToString("\t")) diff --git a/libraries/stdlib/src/generated/_SpecialJVM.kt b/libraries/stdlib/src/generated/_SpecialJVM.kt index abff977be2b..b546d0dc1ea 100644 --- a/libraries/stdlib/src/generated/_SpecialJVM.kt +++ b/libraries/stdlib/src/generated/_SpecialJVM.kt @@ -266,7 +266,7 @@ public fun ShortArray.copyOf(): ShortArray { /** * Returns new array which is a copy of the original array. */ -platformName("mutableCopyOf") +@JvmName("mutableCopyOf") public fun Array.copyOf(): Array { return Arrays.copyOf(this, size()) } @@ -408,7 +408,7 @@ public fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray { /** * Returns new array which is a copy of range of original array. */ -platformName("mutableCopyOfRange") +@JvmName("mutableCopyOfRange") public fun Array.copyOfRange(fromIndex: Int, toIndex: Int): Array { return Arrays.copyOfRange(this, fromIndex, toIndex) } diff --git a/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt b/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt index 28cca186d3c..cde22984078 100644 --- a/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt +++ b/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt @@ -56,7 +56,7 @@ import kotlin.jvm.internal.Intrinsic /** * Creates an input stream for reading data from this byte array. */ -deprecated("Use inputStream() method instead.", ReplaceWith("this.inputStream()")) +@Deprecated("Use inputStream() method instead.", ReplaceWith("this.inputStream()")) public val ByteArray.inputStream : ByteArrayInputStream get() = inputStream() diff --git a/libraries/stdlib/src/kotlin/collections/Exceptions.kt b/libraries/stdlib/src/kotlin/collections/Exceptions.kt index d730fdda6a0..a725b43f040 100644 --- a/libraries/stdlib/src/kotlin/collections/Exceptions.kt +++ b/libraries/stdlib/src/kotlin/collections/Exceptions.kt @@ -1,7 +1,7 @@ package kotlin -deprecated("This exception is no longer thrown by any standard library classes and is going to be removed") +@Deprecated("This exception is no longer thrown by any standard library classes and is going to be removed") public class EmptyIterableException(private val it: Iterable<*>) : RuntimeException("$it is empty") -deprecated("This exception is no longer thrown by any standard library classes and is going to be removed") +@Deprecated("This exception is no longer thrown by any standard library classes and is going to be removed") public class DuplicateKeyException(message : String = "Duplicate keys detected") : RuntimeException(message) \ No newline at end of file diff --git a/libraries/stdlib/src/kotlin/collections/JUtil.kt b/libraries/stdlib/src/kotlin/collections/JUtil.kt index 44889141cf7..18bf9149a3f 100644 --- a/libraries/stdlib/src/kotlin/collections/JUtil.kt +++ b/libraries/stdlib/src/kotlin/collections/JUtil.kt @@ -100,7 +100,7 @@ public val Collection<*>.indices: IntRange /** * Returns an [IntRange] that starts with zero and ends at the value of this number but does not include it. */ -deprecated("Use 0..n-1 range instead.", ReplaceWith("0..this - 1")) +@Deprecated("Use 0..n-1 range instead.", ReplaceWith("0..this - 1")) public val Int.indices: IntRange get() = 0..this - 1 @@ -217,7 +217,7 @@ public fun List.binarySearch(element: T, comparator: Comparator, fr * * If the list contains multiple elements with the specified [key], there is no guarantee which one will be found. */ -public inline fun > List.binarySearchBy(key: K?, fromIndex: Int = 0, toIndex: Int = size(), inlineOptions(InlineOption.ONLY_LOCAL_RETURN) selector: (T) -> K?): Int = +public inline fun > List.binarySearchBy(key: K?, fromIndex: Int = 0, toIndex: Int = size(), crossinline selector: (T) -> K?): Int = binarySearch(fromIndex, toIndex) { compareValues(selector(it), key) } // do not introduce this overload --- too rare diff --git a/libraries/stdlib/src/kotlin/collections/MapWithDefault.kt b/libraries/stdlib/src/kotlin/collections/MapWithDefault.kt index 2e994be36d4..3f46505ea5e 100644 --- a/libraries/stdlib/src/kotlin/collections/MapWithDefault.kt +++ b/libraries/stdlib/src/kotlin/collections/MapWithDefault.kt @@ -37,7 +37,7 @@ public fun Map.withDefault(default: (key: K) -> V): Map = * * When this map already have an implicit default value provided with a former call to [withDefault], it is being replaced by this call. */ -platformName("withDefaultMutable") +@platformName("withDefaultMutable") public fun MutableMap.withDefault(default: (key: K) -> V): MutableMap = when (this) { is MutableMapWithDefault -> this.map.withDefault(default) diff --git a/libraries/stdlib/src/kotlin/collections/MapsJVM.kt b/libraries/stdlib/src/kotlin/collections/MapsJVM.kt index fca47c8e757..5c3c1b9ad6d 100644 --- a/libraries/stdlib/src/kotlin/collections/MapsJVM.kt +++ b/libraries/stdlib/src/kotlin/collections/MapsJVM.kt @@ -17,7 +17,7 @@ public fun MutableMap.set(key: K, value: V): V? = put(key, value) * getOrPut is not supported on [ConcurrentMap] since it cannot be implemented correctly in terms of concurrency. * Use [concurrentGetOrPut] instead, or cast this to a [MutableMap] if you want to sacrifice the concurrent-safety. */ -deprecated("Use concurrentGetOrPut instead or cast this map to MutableMap.") +@Deprecated("Use concurrentGetOrPut instead or cast this map to MutableMap.") public inline fun ConcurrentMap.getOrPut(key: K, defaultValue: () -> V): Nothing = throw UnsupportedOperationException("getOrPut is not supported on ConcurrentMap.") diff --git a/libraries/stdlib/src/kotlin/collections/Operations.kt b/libraries/stdlib/src/kotlin/collections/Operations.kt index bbb32f03eb6..49000f3eadb 100644 --- a/libraries/stdlib/src/kotlin/collections/Operations.kt +++ b/libraries/stdlib/src/kotlin/collections/Operations.kt @@ -1,7 +1,6 @@ package kotlin import java.util.ArrayList -import kotlin.platform.platformName /** * Returns a single list of all elements from all collections in the given collection. diff --git a/libraries/stdlib/src/kotlin/collections/ReversedViews.kt b/libraries/stdlib/src/kotlin/collections/ReversedViews.kt index b0a5036116f..e5e32ae9279 100644 --- a/libraries/stdlib/src/kotlin/collections/ReversedViews.kt +++ b/libraries/stdlib/src/kotlin/collections/ReversedViews.kt @@ -47,6 +47,6 @@ public fun List.asReversed(): List = ReversedListReadOnly(this) * Returns a reversed mutable view of the original mutable List. * All changes made in the original list will be reflected in the reversed one and vice versa. */ -platformName("asReversedMutable") +@platformName("asReversedMutable") public fun MutableList.asReversed(): MutableList = ReversedList(this) diff --git a/libraries/stdlib/src/kotlin/collections/Sequence.kt b/libraries/stdlib/src/kotlin/collections/Sequence.kt index 935169b342e..f7043a3978a 100644 --- a/libraries/stdlib/src/kotlin/collections/Sequence.kt +++ b/libraries/stdlib/src/kotlin/collections/Sequence.kt @@ -26,7 +26,7 @@ public fun Iterator.asSequence(): Sequence { return iteratorSequence.constrainOnce() } -deprecated("Use asSequence() instead.", ReplaceWith("asSequence()")) +@Deprecated("Use asSequence() instead.", ReplaceWith("asSequence()")) public fun Iterator.sequence(): Sequence = asSequence() diff --git a/libraries/stdlib/src/kotlin/concurrent/Locks.kt b/libraries/stdlib/src/kotlin/concurrent/Locks.kt index d6f3e2c42cb..bad1dc2f9da 100644 --- a/libraries/stdlib/src/kotlin/concurrent/Locks.kt +++ b/libraries/stdlib/src/kotlin/concurrent/Locks.kt @@ -58,7 +58,7 @@ public inline fun ReentrantReadWriteLock.write(action: () -> T): T { * * @return the return value of the action. */ -deprecated("Use CountDownLatch(Int) instead and await it manually.") +@Deprecated("Use CountDownLatch(Int) instead and await it manually.") public fun Int.latch(operation: CountDownLatch.() -> T): T { val latch = CountDownLatch(this) val result = latch.operation() diff --git a/libraries/stdlib/src/kotlin/concurrent/Thread.kt b/libraries/stdlib/src/kotlin/concurrent/Thread.kt index 6161a4acb0d..4a0afa08c06 100644 --- a/libraries/stdlib/src/kotlin/concurrent/Thread.kt +++ b/libraries/stdlib/src/kotlin/concurrent/Thread.kt @@ -12,7 +12,7 @@ public val currentThread: Thread * Exposes the name of this thread as a property. */ @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("name")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("name")) public var Thread.name: String get() = getName() set(value) { @@ -23,7 +23,7 @@ public var Thread.name: String * Exposes the daemon flag of this thread as a property. * The Java Virtual Machine exits when the only threads running are all daemon threads. */ -deprecated("Use synthetic extension property isDaemon instead.", ReplaceWith("this.isDaemon")) +@Deprecated("Use synthetic extension property isDaemon instead.", ReplaceWith("this.isDaemon")) public var Thread.daemon: Boolean get() = isDaemon() set(value) { @@ -33,7 +33,7 @@ public var Thread.daemon: Boolean /** * Exposes the alive state of this thread as a property. */ -deprecated("Use synthetic extension property isAlive instead.", ReplaceWith("this.isAlive")) +@Deprecated("Use synthetic extension property isAlive instead.", ReplaceWith("this.isAlive")) public val Thread.alive: Boolean get() = isAlive() @@ -41,7 +41,7 @@ public val Thread.alive: Boolean * Exposes the priority of this thread as a property. */ @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("priority")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("priority")) public var Thread.priority: Int get() = getPriority() set(value) { @@ -52,7 +52,7 @@ public var Thread.priority: Int * Exposes the context class loader of this thread as a property. */ @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("contextClassLoader")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("contextClassLoader")) public var Thread.contextClassLoader: ClassLoader? get() = getContextClassLoader() set(value) { @@ -108,7 +108,7 @@ public inline fun ThreadLocal.getOrSet(default: () -> T): T { * Allows you to use the executor as a function to * execute the given block on the [Executor]. */ -deprecated("Use Executor.execute(Runnable) instead.") // do not specify ReplaceWith("execute(action)") due to KT-8597 +@Deprecated("Use Executor.execute(Runnable) instead.") // do not specify ReplaceWith("execute(action)") due to KT-8597 public fun Executor.invoke(action: () -> Unit) { execute(action) } @@ -117,7 +117,7 @@ public fun Executor.invoke(action: () -> Unit) { * Allows you to use the executor service as a function to * execute the given block on the [ExecutorService]. */ -deprecated("Use ExecutorService.submit(Callable) instead.") // do not specify ReplaceWith("submit(action)") due to KT-8597 +@Deprecated("Use ExecutorService.submit(Callable) instead.") // do not specify ReplaceWith("submit(action)") due to KT-8597 public fun ExecutorService.invoke(action: () -> T): Future { return submit(action) } diff --git a/libraries/stdlib/src/kotlin/deprecated/Deprecated.kt b/libraries/stdlib/src/kotlin/deprecated/Deprecated.kt index abc5dabbf6f..b4c1bed2c89 100644 --- a/libraries/stdlib/src/kotlin/deprecated/Deprecated.kt +++ b/libraries/stdlib/src/kotlin/deprecated/Deprecated.kt @@ -2,105 +2,105 @@ package kotlin import java.util.* -deprecated("Use listOf(...) or arrayListOf(...) instead", ReplaceWith("arrayListOf(*values)")) +@Deprecated("Use listOf(...) or arrayListOf(...) instead", ReplaceWith("arrayListOf(*values)")) public fun arrayList(vararg values: T): ArrayList = arrayListOf(*values) -deprecated("Use setOf(...) or hashSetOf(...) instead", ReplaceWith("hashSetOf(*values)")) +@Deprecated("Use setOf(...) or hashSetOf(...) instead", ReplaceWith("hashSetOf(*values)")) public fun hashSet(vararg values: T): HashSet = hashSetOf(*values) -deprecated("Use mapOf(...) or hashMapOf(...) instead", ReplaceWith("hashMapOf(*values)")) +@Deprecated("Use mapOf(...) or hashMapOf(...) instead", ReplaceWith("hashMapOf(*values)")) public fun hashMap(vararg values: Pair): HashMap = hashMapOf(*values) -deprecated("Use listOf(...) or linkedListOf(...) instead", ReplaceWith("linkedListOf(*values)")) +@Deprecated("Use listOf(...) or linkedListOf(...) instead", ReplaceWith("linkedListOf(*values)")) public fun linkedList(vararg values: T): LinkedList = linkedListOf(*values) -deprecated("Use linkedMapOf(...) instead", ReplaceWith("linkedMapOf(*values)")) +@Deprecated("Use linkedMapOf(...) instead", ReplaceWith("linkedMapOf(*values)")) public fun linkedMap(vararg values: Pair): LinkedHashMap = linkedMapOf(*values) /** Copies all characters into a [[Collection] */ -deprecated("Use toList() instead.", ReplaceWith("toList()")) +@Deprecated("Use toList() instead.", ReplaceWith("toList()")) public fun String.toCollection(): Collection = toCollection(ArrayList(this.length())) /** * A helper method for creating a [[Runnable]] from a function */ -deprecated("Use SAM constructor: Runnable(...)", ReplaceWith("Runnable(action)")) +@Deprecated("Use SAM constructor: Runnable(...)", ReplaceWith("Runnable(action)")) public /*inline*/ fun runnable(action: () -> Unit): Runnable = Runnable(action) -deprecated("Use forEachIndexed instead.", ReplaceWith("forEachIndexed(operation)")) +@Deprecated("Use forEachIndexed instead.", ReplaceWith("forEachIndexed(operation)")) public inline fun List.forEachWithIndex(operation: (Int, T) -> Unit): Unit = forEachIndexed(operation) -deprecated("Function with undefined semantic") +@Deprecated("Function with undefined semantic") public fun countTo(n: Int): (T) -> Boolean { var count = 0 return { ++count; count <= n } } -deprecated("Use contains() function instead", ReplaceWith("contains(item)")) +@Deprecated("Use contains() function instead", ReplaceWith("contains(item)")) public fun Iterable.containsItem(item : T) : Boolean = contains(item) -deprecated("Use sortBy() instead", ReplaceWith("sortedWith(comparator)")) +@Deprecated("Use sortBy() instead", ReplaceWith("sortedWith(comparator)")) public fun Iterable.sort(comparator: java.util.Comparator) : List = sortedWith(comparator) -deprecated("Use size() instead", ReplaceWith("size()")) +@Deprecated("Use size() instead", ReplaceWith("size()")) public val Array<*>.size: Int get() = size() -deprecated("Use size() instead", ReplaceWith("size()")) +@Deprecated("Use size() instead", ReplaceWith("size()")) public val ByteArray.size: Int get() = size() -deprecated("Use size() instead", ReplaceWith("size()")) +@Deprecated("Use size() instead", ReplaceWith("size()")) public val CharArray.size: Int get() = size() -deprecated("Use size() instead", ReplaceWith("size()")) +@Deprecated("Use size() instead", ReplaceWith("size()")) public val ShortArray.size: Int get() = size() -deprecated("Use size() instead", ReplaceWith("size()")) +@Deprecated("Use size() instead", ReplaceWith("size()")) public val IntArray.size: Int get() = size() -deprecated("Use size() instead", ReplaceWith("size()")) +@Deprecated("Use size() instead", ReplaceWith("size()")) public val LongArray.size: Int get() = size() -deprecated("Use size() instead", ReplaceWith("size()")) +@Deprecated("Use size() instead", ReplaceWith("size()")) public val FloatArray.size: Int get() = size() -deprecated("Use size() instead", ReplaceWith("size()")) +@Deprecated("Use size() instead", ReplaceWith("size()")) public val DoubleArray.size: Int get() = size() -deprecated("Use size() instead", ReplaceWith("size()")) +@Deprecated("Use size() instead", ReplaceWith("size()")) public val BooleanArray.size: Int get() = size() -deprecated("Use compareValuesBy() instead", ReplaceWith("compareValuesBy(a, b, *functions)")) +@Deprecated("Use compareValuesBy() instead", ReplaceWith("compareValuesBy(a, b, *functions)")) public fun compareBy(a: T?, b: T?, vararg functions: (T) -> Comparable<*>?): Int = compareValuesBy(a, b, *functions) /** Returns true if this collection is empty */ -deprecated("Use isEmpty() function call instead", ReplaceWith("isEmpty()")) +@Deprecated("Use isEmpty() function call instead", ReplaceWith("isEmpty()")) public val Collection<*>.empty: Boolean get() = isEmpty() /** Returns the size of the collection */ -deprecated("Use size() function call instead", ReplaceWith("size()")) +@Deprecated("Use size() function call instead", ReplaceWith("size()")) public val Collection<*>.size: Int get() = size() /** Returns the size of the map */ -deprecated("Use size() function call instead", ReplaceWith("size()")) +@Deprecated("Use size() function call instead", ReplaceWith("size()")) public val Map<*, *>.size: Int get() = size() /** Returns true if this map is empty */ -deprecated("Use isEmpty() function call instead", ReplaceWith("isEmpty()")) +@Deprecated("Use isEmpty() function call instead", ReplaceWith("isEmpty()")) public val Map<*, *>.empty: Boolean get() = isEmpty() /** Returns true if this collection is not empty */ -deprecated("Use isNotEmpty() function call instead", ReplaceWith("isNotEmpty()")) +@Deprecated("Use isNotEmpty() function call instead", ReplaceWith("isNotEmpty()")) public val Collection<*>.notEmpty: Boolean get() = isNotEmpty() -deprecated("Use length() instead", ReplaceWith("length()")) +@Deprecated("Use length() instead", ReplaceWith("length()")) public val CharSequence.length: Int get() = length() diff --git a/libraries/stdlib/src/kotlin/deprecated/DeprecatedArrays.kt b/libraries/stdlib/src/kotlin/deprecated/DeprecatedArrays.kt index cf4b82eadb6..4470410f274 100644 --- a/libraries/stdlib/src/kotlin/deprecated/DeprecatedArrays.kt +++ b/libraries/stdlib/src/kotlin/deprecated/DeprecatedArrays.kt @@ -2,40 +2,40 @@ package kotlin // deprecated to be removed after M12 -deprecated("Use arrayOf() instead.", ReplaceWith("arrayOf(*t)")) +@Deprecated("Use arrayOf() instead.", ReplaceWith("arrayOf(*t)")) inline public fun array(vararg t : T) : Array = arrayOf(*t) -suppress("NOTHING_TO_INLINE") -deprecated("Use doubleArrayOf() instead.", ReplaceWith("doubleArrayOf(*content)")) +@Suppress("NOTHING_TO_INLINE") +@Deprecated("Use doubleArrayOf() instead.", ReplaceWith("doubleArrayOf(*content)")) inline public fun doubleArray(vararg content : Double) : DoubleArray = doubleArrayOf(*content) -suppress("NOTHING_TO_INLINE") -deprecated("Use floatArrayOf() instead.", ReplaceWith("floatArrayOf(*content)")) +@Suppress("NOTHING_TO_INLINE") +@Deprecated("Use floatArrayOf() instead.", ReplaceWith("floatArrayOf(*content)")) inline public fun floatArray(vararg content : Float) : FloatArray = floatArrayOf(*content) -suppress("NOTHING_TO_INLINE") -deprecated("Use longArrayOf() instead.", ReplaceWith("longArrayOf(*content)")) +@Suppress("NOTHING_TO_INLINE") +@Deprecated("Use longArrayOf() instead.", ReplaceWith("longArrayOf(*content)")) inline public fun longArray(vararg content : Long) : LongArray = longArrayOf(*content) -suppress("NOTHING_TO_INLINE") -deprecated("Use intArrayOf() instead.", ReplaceWith("intArrayOf(*content)")) +@Suppress("NOTHING_TO_INLINE") +@Deprecated("Use intArrayOf() instead.", ReplaceWith("intArrayOf(*content)")) inline public fun intArray(vararg content : Int) : IntArray = intArrayOf(*content) -suppress("NOTHING_TO_INLINE") -deprecated("Use charArrayOf() instead.", ReplaceWith("charArrayOf(*content)")) +@Suppress("NOTHING_TO_INLINE") +@Deprecated("Use charArrayOf() instead.", ReplaceWith("charArrayOf(*content)")) inline public fun charArray(vararg content : Char) : CharArray = charArrayOf(*content) -suppress("NOTHING_TO_INLINE") -deprecated("Use shortArrayOf() instead.", ReplaceWith("shortArrayOf(*content)")) +@Suppress("NOTHING_TO_INLINE") +@Deprecated("Use shortArrayOf() instead.", ReplaceWith("shortArrayOf(*content)")) inline public fun shortArray(vararg content : Short) : ShortArray = shortArrayOf(*content) -suppress("NOTHING_TO_INLINE") -deprecated("Use byteArrayOf() instead.", ReplaceWith("byteArrayOf(*content)")) +@Suppress("NOTHING_TO_INLINE") +@Deprecated("Use byteArrayOf() instead.", ReplaceWith("byteArrayOf(*content)")) inline public fun byteArray(vararg content : Byte) : ByteArray = byteArrayOf(*content) -suppress("NOTHING_TO_INLINE") -deprecated("Use booleanArrayOf() instead.", ReplaceWith("booleanArrayOf(*content)")) +@Suppress("NOTHING_TO_INLINE") +@Deprecated("Use booleanArrayOf() instead.", ReplaceWith("booleanArrayOf(*content)")) inline public fun booleanArray(vararg content : Boolean) : BooleanArray = booleanArrayOf(*content) -deprecated("Use toTypedArray() instead.", ReplaceWith("toTypedArray()")) +@Deprecated("Use toTypedArray() instead.", ReplaceWith("toTypedArray()")) inline public fun Collection.copyToArray(): Array = toTypedArray() \ No newline at end of file diff --git a/libraries/stdlib/src/kotlin/deprecated/DeprecatedJVM.kt b/libraries/stdlib/src/kotlin/deprecated/DeprecatedJVM.kt index f02f4bcee3f..b954df3c89b 100644 --- a/libraries/stdlib/src/kotlin/deprecated/DeprecatedJVM.kt +++ b/libraries/stdlib/src/kotlin/deprecated/DeprecatedJVM.kt @@ -19,26 +19,26 @@ package kotlin import java.util.* import java.util.concurrent.Callable -deprecated("Use sortedSetOf(...) instead", ReplaceWith("sortedSetOf(*values)")) +@Deprecated("Use sortedSetOf(...) instead", ReplaceWith("sortedSetOf(*values)")) public fun sortedSet(vararg values: T): TreeSet = sortedSetOf(*values) -deprecated("Use sortedSetOf(...) instead", ReplaceWith("sortedSetOf(comparator, *values)")) +@Deprecated("Use sortedSetOf(...) instead", ReplaceWith("sortedSetOf(comparator, *values)")) public fun sortedSet(comparator: Comparator, vararg values: T): TreeSet = sortedSetOf(comparator, *values) -deprecated("Use sortedMapOf(...) instead", ReplaceWith("sortedMapOf(*values)")) +@Deprecated("Use sortedMapOf(...) instead", ReplaceWith("sortedMapOf(*values)")) public fun sortedMap(vararg values: Pair): SortedMap = sortedMapOf(*values) /** * A helper method for creating a [[Callable]] from a function */ -deprecated("Use SAM constructor: Callable(...)", ReplaceWith("Callable(action)", "java.util.concurrent.Callable")) +@Deprecated("Use SAM constructor: Callable(...)", ReplaceWith("Callable(action)", "java.util.concurrent.Callable")) public /*inline*/ fun callable(action: () -> T): Callable = Callable(action) -deprecated("Use length() instead", ReplaceWith("length()")) +@Deprecated("Use length() instead", ReplaceWith("length()")) public val String.size: Int get() = length() -deprecated("Use length() instead", ReplaceWith("length()")) +@Deprecated("Use length() instead", ReplaceWith("length()")) public val CharSequence.size: Int get() = length() diff --git a/libraries/stdlib/src/kotlin/deprecated/DeprecatedStrings.kt b/libraries/stdlib/src/kotlin/deprecated/DeprecatedStrings.kt index e2fde0fbc87..aa5adb09de4 100644 --- a/libraries/stdlib/src/kotlin/deprecated/DeprecatedStrings.kt +++ b/libraries/stdlib/src/kotlin/deprecated/DeprecatedStrings.kt @@ -1,113 +1,113 @@ package kotlin -deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) public fun Array.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { return joinToString(separator, prefix, postfix, limit, truncated) } -deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) public fun BooleanArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { return joinToString(separator, prefix, postfix, limit, truncated) } -deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) public fun ByteArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { return joinToString(separator, prefix, postfix, limit, truncated) } -deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) public fun CharArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { return joinToString(separator, prefix, postfix, limit, truncated) } -deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) public fun DoubleArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { return joinToString(separator, prefix, postfix, limit, truncated) } -deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) public fun FloatArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { return joinToString(separator, prefix, postfix, limit, truncated) } -deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) public fun IntArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { return joinToString(separator, prefix, postfix, limit, truncated) } -deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) public fun LongArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { return joinToString(separator, prefix, postfix, limit, truncated) } -deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) public fun ShortArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { return joinToString(separator, prefix, postfix, limit, truncated) } -deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) public fun Iterable.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { return joinToString(separator, prefix, postfix, limit, truncated) } -deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinToString() instead", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)")) public fun Sequence.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { return joinToString(separator, prefix, postfix, limit, truncated) } -deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) public fun Array.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { joinTo(buffer, separator, prefix, postfix, limit, truncated) } -deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) public fun BooleanArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { joinTo(buffer, separator, prefix, postfix, limit, truncated) } -deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) public fun ByteArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { joinTo(buffer, separator, prefix, postfix, limit, truncated) } -deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) public fun CharArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { joinTo(buffer, separator, prefix, postfix, limit, truncated) } -deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) public fun DoubleArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { joinTo(buffer, separator, prefix, postfix, limit, truncated) } -deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) public fun FloatArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { joinTo(buffer, separator, prefix, postfix, limit, truncated) } -deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) public fun IntArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { joinTo(buffer, separator, prefix, postfix, limit, truncated) } -deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) public fun LongArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { joinTo(buffer, separator, prefix, postfix, limit, truncated) } -deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) public fun ShortArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { joinTo(buffer, separator, prefix, postfix, limit, truncated) } -deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) public fun Iterable.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { joinTo(buffer, separator, prefix, postfix, limit, truncated) } -deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) +@Deprecated("Use joinTo() instead", ReplaceWith("joinTo(buffer, separator, prefix, postfix, limit, truncated)")) public fun Sequence.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { joinTo(buffer, separator, prefix, postfix, limit, truncated) } diff --git a/libraries/stdlib/src/kotlin/dom/Dom.kt b/libraries/stdlib/src/kotlin/dom/Dom.kt index 5503ee8f511..0e7055f4371 100644 --- a/libraries/stdlib/src/kotlin/dom/Dom.kt +++ b/libraries/stdlib/src/kotlin/dom/Dom.kt @@ -10,14 +10,14 @@ import java.lang.IndexOutOfBoundsException // Properties -deprecated("use textContent directly instead") +@Deprecated("use textContent directly instead") public var Node.text: String get() = textContent ?: "" set(value) { textContent = value } -deprecated("You shouldn't use it as setter will drop all elements and get may return not exactly content user can expect") +@Deprecated("You shouldn't use it as setter will drop all elements and get may return not exactly content user can expect") public var Element.childrenText: String get() { val buffer = StringBuilder() @@ -101,7 +101,7 @@ public fun Document?.elements(namespaceUri: String, localName: String): List = if (this == null) emptyList() else NodeListAsList(this) -deprecated("use asList instead", ReplaceWith("asList()")) +@Deprecated("use asList instead", ReplaceWith("asList()")) public fun NodeList?.toList(): List = asList() public fun NodeList?.toElementList(): List { @@ -268,7 +268,7 @@ private class PreviousSiblings(private var node: Node) : Iterable { } /** Returns true if this node is a Text node or a CDATA node */ -deprecated("use property isText instead", ReplaceWith("isText")) +@Deprecated("use property isText instead", ReplaceWith("isText")) public fun Node.isText() : Boolean = isText /** diff --git a/libraries/stdlib/src/kotlin/dom/DomEventsJVM.kt b/libraries/stdlib/src/kotlin/dom/DomEventsJVM.kt index 0f7ae45d086..d141d0dc0d8 100644 --- a/libraries/stdlib/src/kotlin/dom/DomEventsJVM.kt +++ b/libraries/stdlib/src/kotlin/dom/DomEventsJVM.kt @@ -6,12 +6,12 @@ import org.w3c.dom.events.MouseEvent // JavaScript style properties for JVM : TODO could auto-generate these @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("bubbles")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("bubbles")) public val Event.bubbles: Boolean get() = getBubbles() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("cancelable")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("cancelable")) public val Event.cancelable: Boolean get() = getCancelable() @@ -19,17 +19,17 @@ public val Event.getCurrentTarget: EventTarget? get() = getCurrentTarget() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("eventPhase")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("eventPhase")) public val Event.eventPhase: Short get() = getEventPhase() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("target")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("target")) public val Event.target: EventTarget? get() = getTarget() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("timeStamp")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("timeStamp")) public val Event.timeStamp: Long get() = getTimeStamp() @@ -39,51 +39,51 @@ public val Event.eventType: String @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("altKey")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("altKey")) public val MouseEvent.altKey: Boolean get() = getAltKey() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("button")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("button")) public val MouseEvent.button: Short get() = getButton() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("clientX")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("clientX")) public val MouseEvent.clientX: Int get() = getClientX() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("clientY")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("clientY")) public val MouseEvent.clientY: Int get() = getClientY() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("ctrlKey")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("ctrlKey")) public val MouseEvent.ctrlKey: Boolean get() = getCtrlKey() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("metaKey")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("metaKey")) public val MouseEvent.metaKey: Boolean get() = getMetaKey() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("relatedTarget")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("relatedTarget")) public val MouseEvent.relatedTarget: EventTarget? get() = getRelatedTarget() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("screenX")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("screenX")) public val MouseEvent.screenX: Int get() = getScreenX() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("screenY")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("screenY")) public val MouseEvent.screenY: Int get() = getScreenY() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("shiftKey")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("shiftKey")) public val MouseEvent.shiftKey: Boolean get() = getShiftKey() diff --git a/libraries/stdlib/src/kotlin/dom/DomJVM.kt b/libraries/stdlib/src/kotlin/dom/DomJVM.kt index dc68d281b50..88395eaaf6c 100644 --- a/libraries/stdlib/src/kotlin/dom/DomJVM.kt +++ b/libraries/stdlib/src/kotlin/dom/DomJVM.kt @@ -20,80 +20,80 @@ import javax.xml.transform.dom.DOMSource import javax.xml.transform.stream.StreamResult // JavaScript style properties - TODO could auto-generate these -@deprecated("Use getNodeName()", ReplaceWith("getNodeName() ?: \"\"")) +@Deprecated("Use getNodeName()", ReplaceWith("getNodeName() ?: \"\"")) public val Node.nodeName: String get() = getNodeName() ?: "" -@deprecated("Use getNodeValue()", ReplaceWith("getNodeValue() ?: \"\"")) +@Deprecated("Use getNodeValue()", ReplaceWith("getNodeValue() ?: \"\"")) public val Node.nodeValue: String get() = getNodeValue() ?: "" @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("nodeType")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("nodeType")) public val Node.nodeType: Short get() = getNodeType() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("parentNode")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("parentNode")) public val Node.parentNode: Node? get() = getParentNode() -@deprecated("Use getChildNodes()", ReplaceWith("getChildNodes()!!")) +@Deprecated("Use getChildNodes()", ReplaceWith("getChildNodes()!!")) public val Node.childNodes: NodeList get() = getChildNodes()!! @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("firstChild")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("firstChild")) public val Node.firstChild: Node? get() = getFirstChild() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("lastChild")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("lastChild")) public val Node.lastChild: Node? get() = getLastChild() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("nextSibling")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("nextSibling")) public val Node.nextSibling: Node? get() = getNextSibling() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("previousSibling")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("previousSibling")) public val Node.previousSibling: Node? get() = getPreviousSibling() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("attributes")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("attributes")) public val Node.attributes: NamedNodeMap? get() = getAttributes() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("ownerDocument")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("ownerDocument")) public val Node.ownerDocument: Document? get() = getOwnerDocument() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("documentElement")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("documentElement")) public val Document.documentElement: Element? get() = this.getDocumentElement() -@deprecated("Use getNamespaceURI()", ReplaceWith("getNamespaceURI() ?: \"\"")) +@Deprecated("Use getNamespaceURI()", ReplaceWith("getNamespaceURI() ?: \"\"")) public val Node.namespaceURI: String get() = getNamespaceURI() ?: "" -@deprecated("Use getPrefix()", ReplaceWith("getPrefix() ?: \"\"")) +@Deprecated("Use getPrefix()", ReplaceWith("getPrefix() ?: \"\"")) public val Node.prefix: String get() = getPrefix() ?: "" -@deprecated("Use getLocalName()", ReplaceWith("getLocalName() ?: \"\"")) +@Deprecated("Use getLocalName()", ReplaceWith("getLocalName() ?: \"\"")) public val Node.localName: String get() = getLocalName() ?: "" -@deprecated("Use getBaseURI", ReplaceWith("getBaseURI() ?: \"\"")) +@Deprecated("Use getBaseURI", ReplaceWith("getBaseURI() ?: \"\"")) public val Node.baseURI: String get() = getBaseURI() ?: "" -@deprecated("Use getTextContent()/setTextContent()") +@Deprecated("Use getTextContent()/setTextContent()") public var Node.textContent: String get() = getTextContent() ?: "" set(value) { @@ -101,32 +101,32 @@ public var Node.textContent: String } @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("length")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("length")) public val DOMStringList.length: Int get() = this.getLength() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("length")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("length")) public val NameList.length: Int get() = this.getLength() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("length")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("length")) public val DOMImplementationList.length: Int get() = this.getLength() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("length")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("length")) public val NodeList.length: Int get() = this.getLength() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("length")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("length")) public val CharacterData.length: Int get() = this.getLength() @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("length")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("length")) public val NamedNodeMap.length: Int get() = this.getLength() diff --git a/libraries/stdlib/src/kotlin/io/IOStreams.kt b/libraries/stdlib/src/kotlin/io/IOStreams.kt index 55c941cedb5..c2a429a83f7 100644 --- a/libraries/stdlib/src/kotlin/io/IOStreams.kt +++ b/libraries/stdlib/src/kotlin/io/IOStreams.kt @@ -7,7 +7,7 @@ import java.nio.charset.CharsetEncoder import java.util.NoSuchElementException /** Returns an [Iterator] of bytes in this input stream. */ -deprecated("It's not recommended to iterate through input stream bytes") +@Deprecated("It's not recommended to iterate through input stream bytes") public fun InputStream.iterator(): ByteIterator = object : ByteIterator() { diff --git a/libraries/stdlib/src/kotlin/io/ReadWrite.kt b/libraries/stdlib/src/kotlin/io/ReadWrite.kt index 08b779f559f..beae1b81b04 100644 --- a/libraries/stdlib/src/kotlin/io/ReadWrite.kt +++ b/libraries/stdlib/src/kotlin/io/ReadWrite.kt @@ -250,10 +250,10 @@ public inline fun Reader.useLines(block: (Sequence) -> T): T = */ public fun BufferedReader.lineSequence(): Sequence = LinesSequence(this).constrainOnce() -deprecated("Use lineSequence() instead to avoid conflict with JDK8 lines() method.", ReplaceWith("lineSequence()")) +@Deprecated("Use lineSequence() instead to avoid conflict with JDK8 lines() method.", ReplaceWith("lineSequence()")) public fun BufferedReader.lines(): Sequence = lineSequence() -deprecated("Use lineSequence() function which returns Sequence") +@Deprecated("Use lineSequence() function which returns Sequence") public fun BufferedReader.lineIterator(): Iterator = lineSequence().iterator() private class LinesSequence(private val reader: BufferedReader) : Sequence { diff --git a/libraries/stdlib/src/kotlin/io/files/FileTreeWalk.kt b/libraries/stdlib/src/kotlin/io/files/FileTreeWalk.kt index cd5208efa86..1fab71aba9a 100644 --- a/libraries/stdlib/src/kotlin/io/files/FileTreeWalk.kt +++ b/libraries/stdlib/src/kotlin/io/files/FileTreeWalk.kt @@ -153,8 +153,7 @@ public class FileTreeWalk(private val start: File, }) } - tailRecursive - private fun gotoNext(): File? { + tailrec private fun gotoNext(): File? { if (end) { // We are already at the end return null @@ -284,7 +283,7 @@ public fun File.walkBottomUp(): FileTreeWalk = walk(FileWalkDirection.BOTTOM_UP) * * @param function the function to call on each file. */ -deprecated("It's recommended to use walkTopDown() / walkBottomUp()") +@Deprecated("It's recommended to use walkTopDown() / walkBottomUp()") public fun File.recurse(function: (File) -> Unit): Unit { walkTopDown().forEach { function(it) } } diff --git a/libraries/stdlib/src/kotlin/io/files/Utils.kt b/libraries/stdlib/src/kotlin/io/files/Utils.kt index b12d4bb47ca..8da01ba11b6 100644 --- a/libraries/stdlib/src/kotlin/io/files/Utils.kt +++ b/libraries/stdlib/src/kotlin/io/files/Utils.kt @@ -51,7 +51,7 @@ public val File.directory: File /** * Returns parent of this abstract path name, or `null` if it has no parent. */ -@deprecated("Use parentFile", ReplaceWith("parentFile")) +@Deprecated("Use parentFile", ReplaceWith("parentFile")) public val File.parent: File? get() = parentFile @@ -59,7 +59,7 @@ public val File.parent: File? * Returns the canonical path of this file. */ @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("canonicalPath")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("canonicalPath")) public val File.canonicalPath: String get() = getCanonicalPath() @@ -67,7 +67,7 @@ public val File.canonicalPath: String * Returns the file name. */ @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("name")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("name")) public val File.name: String get() = getName() @@ -75,7 +75,7 @@ public val File.name: String * Returns the file path. */ @HiddenDeclaration -@deprecated("Is replaced with automatic synthetic extension", ReplaceWith("path")) +@Deprecated("Is replaced with automatic synthetic extension", ReplaceWith("path")) public val File.path: String get() = getPath() @@ -178,7 +178,7 @@ public fun File.relativeTo(base: File): String { * If this file matches the [descendant] directory or does not belong to it, * then an empty string will be returned. */ -deprecated("Use relativeTo() function instead") +@Deprecated("Use relativeTo() function instead") public fun File.relativePath(descendant: File): String { val prefix = directory.canonicalPath val answer = descendant.canonicalPath diff --git a/libraries/stdlib/src/kotlin/jvm/JvmPlatformAnnotations.kt b/libraries/stdlib/src/kotlin/jvm/JvmPlatformAnnotations.kt index 1e52a82d23f..92878a6bdc7 100644 --- a/libraries/stdlib/src/kotlin/jvm/JvmPlatformAnnotations.kt +++ b/libraries/stdlib/src/kotlin/jvm/JvmPlatformAnnotations.kt @@ -55,7 +55,7 @@ public annotation class JvmName(public val name: String) /** * Instructs the Kotlin compiler to generate a multifile class with this file as one o */ -target(AnnotationTarget.FILE) +@Target(AnnotationTarget.FILE) @Retention(AnnotationRetention.RUNTIME) @MustBeDocumented public annotation class JvmMultifileClass diff --git a/libraries/stdlib/src/kotlin/platform/annotations.kt b/libraries/stdlib/src/kotlin/platform/annotations.kt index 056c780ebfc..deef3bad075 100644 --- a/libraries/stdlib/src/kotlin/platform/annotations.kt +++ b/libraries/stdlib/src/kotlin/platform/annotations.kt @@ -21,11 +21,11 @@ import kotlin.annotation.AnnotationTarget.* @Target(FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER) @Retention(AnnotationRetention.RUNTIME) @MustBeDocumented -@deprecated("Use kotlin.jvm.JvmName instead", ReplaceWith("kotlin.jvm.JvmName")) +@Deprecated("Use kotlin.jvm.platformName instead", ReplaceWith("kotlin.jvm.platformName")) public annotation class platformName(public val name: String) @Target(FUNCTION, PROPERTY, PROPERTY_GETTER, PROPERTY_SETTER) @Retention(AnnotationRetention.RUNTIME) @MustBeDocumented -@deprecated("Use kotlin.jvm.JvmStatic instead", ReplaceWith("kotlin.jvm.JvmStatic")) +@Deprecated("Use kotlin.jvm.JvmStatic instead", ReplaceWith("kotlin.jvm.JvmStatic")) public annotation class platformStatic diff --git a/libraries/stdlib/src/kotlin/properties/Delegation.kt b/libraries/stdlib/src/kotlin/properties/Delegation.kt index 77ae9720923..a95a13b8202 100644 --- a/libraries/stdlib/src/kotlin/properties/Delegation.kt +++ b/libraries/stdlib/src/kotlin/properties/Delegation.kt @@ -19,7 +19,7 @@ public object Delegates { * specified block of code. Supports lazy initialization semantics for properties. * @param initializer the function that returns the value of the property. */ - deprecated("Use lazy {} instead in kotlin package", ReplaceWith("kotlin.lazy(LazyThreadSafetyMode.NONE, initializer)")) + @Deprecated("Use lazy {} instead in kotlin package", ReplaceWith("kotlin.lazy(LazyThreadSafetyMode.NONE, initializer)")) public fun lazy(initializer: () -> T): ReadOnlyProperty = LazyVal(initializer) /** @@ -30,7 +30,7 @@ public object Delegates { * the property delegate object itself is used as a lock. * @param initializer the function that returns the value of the property. */ - deprecated("Use lazy(lock) {} instead in kotlin package", ReplaceWith("lazy(lock, initializer)")) + @Deprecated("Use lazy(lock) {} instead in kotlin package", ReplaceWith("lazy(lock, initializer)")) public fun blockingLazy(lock: Any?, initializer: () -> T): ReadOnlyProperty = BlockingLazyVal(lock, initializer) /** @@ -40,7 +40,7 @@ public object Delegates { * The property delegate object itself is used as a lock. * @param initializer the function that returns the value of the property. */ - deprecated("Use lazy {} instead in kotlin package", ReplaceWith("kotlin.lazy(initializer)")) + @Deprecated("Use lazy {} instead in kotlin package", ReplaceWith("kotlin.lazy(initializer)")) public fun blockingLazy(initializer: () -> T): ReadOnlyProperty = BlockingLazyVal(null, initializer) /** @@ -49,7 +49,7 @@ public object Delegates { * @param onChange the callback which is called after the change of the property is made. The value of the property * has already been changed when this callback is invoked. */ - public inline fun observable(initialValue: T, inlineOptions(InlineOption.ONLY_LOCAL_RETURN) onChange: (property: PropertyMetadata, oldValue: T, newValue: T) -> Unit): + public inline fun observable(initialValue: T, crossinline onChange: (property: PropertyMetadata, oldValue: T, newValue: T) -> Unit): ReadWriteProperty = object : ObservableProperty(initialValue) { override fun afterChange(property: PropertyMetadata, oldValue: T, newValue: T) = onChange(property, oldValue, newValue) } @@ -63,7 +63,7 @@ public object Delegates { * If the callback returns `true` the value of the property is being set to the new value, * and if the callback returns `false` the new value is discarded and the property remains its old value. */ - public inline fun vetoable(initialValue: T, inlineOptions(InlineOption.ONLY_LOCAL_RETURN) onChange: (property: PropertyMetadata, oldValue: T, newValue: T) -> Boolean): + public inline fun vetoable(initialValue: T, crossinline onChange: (property: PropertyMetadata, oldValue: T, newValue: T) -> Boolean): ReadWriteProperty = object : ObservableProperty(initialValue) { override fun beforeChange(property: PropertyMetadata, oldValue: T, newValue: T): Boolean = onChange(property, oldValue, newValue) } @@ -73,7 +73,7 @@ public object Delegates { * as a key. * @param map the map where the property values are stored. */ - deprecated("Delegate property to the map itself without creating a wrapper.", ReplaceWith("map")) + @Deprecated("Delegate property to the map itself without creating a wrapper.", ReplaceWith("map")) public fun mapVar(map: MutableMap): ReadWriteProperty { return FixedMapVar(map, propertyNameSelector, throwKeyNotFound) } @@ -94,7 +94,7 @@ public object Delegates { * as a key. * @param map the map where the property values are stored. */ - deprecated("Delegate property to the map itself without creating a wrapper.", ReplaceWith("map")) + @Deprecated("Delegate property to the map itself without creating a wrapper.", ReplaceWith("map")) public fun mapVal(map: Map): ReadOnlyProperty { return FixedMapVal(map, propertyNameSelector, throwKeyNotFound) } @@ -125,7 +125,7 @@ private class NotNullVar() : ReadWriteProperty { } -deprecated("Use Delegates.vetoable() instead or construct implementation of abstract ObservableProperty", ReplaceWith("Delegates.vetoable(initialValue, onChange)")) +@Deprecated("Use Delegates.vetoable() instead or construct implementation of abstract ObservableProperty", ReplaceWith("Delegates.vetoable(initialValue, onChange)")) public fun ObservableProperty(initialValue: T, onChange: (property: PropertyMetadata, oldValue: T, newValue: T) -> Boolean): ObservableProperty = object : ObservableProperty(initialValue) { override fun beforeChange(property: PropertyMetadata, oldValue: T, newValue: T): Boolean = onChange(property, oldValue, newValue) @@ -189,7 +189,7 @@ private class LazyVal(private val initializer: () -> T) : ReadOnlyProperty(lock: Any?, private val initializer: () -> T) : ReadOnlyProperty { private val lock = lock ?: this - private volatile var value: Any? = null + @volatile private var value: Any? = null public override fun get(thisRef: Any?, property: PropertyMetadata): T { val _v1 = value @@ -215,9 +215,9 @@ private class BlockingLazyVal(lock: Any?, private val initializer: () -> T) : * Exception thrown by the default implementation of property delegates which store values in a map * when the map does not contain the corresponding key. */ -deprecated("Do not throw or catch this exception, use NoSuchElementException instead.") +@Deprecated("Do not throw or catch this exception, use NoSuchElementException instead.") public class KeyMissingException - deprecated("Throw NoSuchElementException instead.", ReplaceWith("NoSuchElementException(message)")) + @Deprecated("Throw NoSuchElementException instead.", ReplaceWith("NoSuchElementException(message)")) constructor(message: String): NoSuchElementException(message) diff --git a/libraries/stdlib/src/kotlin/properties/MapAccessors.kt b/libraries/stdlib/src/kotlin/properties/MapAccessors.kt index e9812c79f19..7d30dd77f45 100644 --- a/libraries/stdlib/src/kotlin/properties/MapAccessors.kt +++ b/libraries/stdlib/src/kotlin/properties/MapAccessors.kt @@ -24,7 +24,7 @@ public fun Map.get(thisRef: Any?, property: PropertyMetadata): * * @throws NoSuchElementException when the map doesn't contain value for the property name and doesn't provide an implicit default (see [withDefault]). */ -platformName("getVar") +@platformName("getVar") public fun MutableMap.get(thisRef: Any?, property: PropertyMetadata): V = getOrImplicitDefault(property.name) as V /** diff --git a/libraries/stdlib/src/kotlin/properties/Properties.kt b/libraries/stdlib/src/kotlin/properties/Properties.kt index d93c08243ed..9ceb9f8ef93 100644 --- a/libraries/stdlib/src/kotlin/properties/Properties.kt +++ b/libraries/stdlib/src/kotlin/properties/Properties.kt @@ -3,7 +3,7 @@ package kotlin.properties import java.util.HashMap import java.util.ArrayList -deprecated("This class is part of an old, incomplete and suboptimal design of change notifications and is going to be removed") +@Deprecated("This class is part of an old, incomplete and suboptimal design of change notifications and is going to be removed") public class ChangeEvent( public val source: Any, public val name: String, @@ -13,7 +13,7 @@ public class ChangeEvent( override fun toString(): String = "ChangeEvent($name, $oldValue, $newValue)" } -deprecated("This class is part of an old, incomplete and suboptimal design of change notifications and is going to be removed") +@Deprecated("This class is part of an old, incomplete and suboptimal design of change notifications and is going to be removed") public interface ChangeListener { public fun onPropertyChange(event: ChangeEvent): Unit } @@ -23,7 +23,7 @@ public interface ChangeListener { * updates for easier binding to user interfaces, undo/redo command stacks and * change tracking mechanisms for persistence or distributed change notifications. */ -deprecated("This class is part of an old, incomplete and suboptimal design of change notifications and is going to be removed") +@Deprecated("This class is part of an old, incomplete and suboptimal design of change notifications and is going to be removed") public abstract class ChangeSupport { private var allListeners: MutableList? = null private var nameListeners: MutableMap>? = null diff --git a/libraries/stdlib/src/kotlin/test/Test.kt b/libraries/stdlib/src/kotlin/test/Test.kt index 2ad10a983a4..26e7d5a90b3 100644 --- a/libraries/stdlib/src/kotlin/test/Test.kt +++ b/libraries/stdlib/src/kotlin/test/Test.kt @@ -5,11 +5,11 @@ package kotlin.test /** Asserts that the given [block] returns `false`. */ -@deprecated("Use assertFalse instead.", ReplaceWith("assertFalse(message, block)")) +@Deprecated("Use assertFalse instead.", ReplaceWith("assertFalse(message, block)")) public fun assertNot(message: String, block: () -> Boolean): Unit = assertFalse(message, block) /** Asserts that the given [block] returns `false`. */ -@deprecated("Use assertFalse instead.", ReplaceWith("assertFalse(null, block)")) +@Deprecated("Use assertFalse instead.", ReplaceWith("assertFalse(null, block)")) public fun assertNot(block: () -> Boolean): Unit = assertFalse(block = block) /** Asserts that the given [block] returns `true`. */ @@ -72,7 +72,7 @@ public fun expect(expected: T, message: String?, block: () -> T) { assertEquals(expected, block(), message) } -@deprecated("Use assertFails instead.", ReplaceWith("assertFails(block)")) +@Deprecated("Use assertFails instead.", ReplaceWith("assertFails(block)")) public fun fails(block: () -> Unit): Throwable? = assertFails(block) /** Asserts that given function [block] fails by throwing an exception. */ diff --git a/libraries/stdlib/src/kotlin/test/TestJVM.kt b/libraries/stdlib/src/kotlin/test/TestJVM.kt index 244f183ea96..11af870272b 100644 --- a/libraries/stdlib/src/kotlin/test/TestJVM.kt +++ b/libraries/stdlib/src/kotlin/test/TestJVM.kt @@ -3,7 +3,7 @@ package kotlin.test import java.util.ServiceLoader import kotlin.reflect.KClass -@deprecated("Use assertFailsWith instead.", ReplaceWith("assertFailsWith(exceptionClass, block)")) +@Deprecated("Use assertFailsWith instead.", ReplaceWith("assertFailsWith(exceptionClass, block)")) public fun failsWith(exceptionClass: Class, block: ()-> Any): T = assertFailsWith(exceptionClass, { block() }) /** Asserts that a [block] fails with a specific exception being thrown. */ @@ -32,7 +32,7 @@ public fun assertFailsWith(exceptionClass: KClass, message: St /** Asserts that a [block] fails with a specific exception of type [T] being thrown. * Since inline method doesn't allow to trace where it was invoked, it is required to pass a [message] to distinguish this method call from others. */ -public inline fun assertFailsWith(message: String, @noinline block: () -> Unit): T = assertFailsWith(T::class.java, message, block) +public inline fun assertFailsWith(message: String, noinline block: () -> Unit): T = assertFailsWith(T::class.java, message, block) /** diff --git a/libraries/stdlib/src/kotlin/text/CharJVM.kt b/libraries/stdlib/src/kotlin/text/CharJVM.kt index 60d6c495287..bed050ac753 100644 --- a/libraries/stdlib/src/kotlin/text/CharJVM.kt +++ b/libraries/stdlib/src/kotlin/text/CharJVM.kt @@ -58,10 +58,10 @@ public fun Char.isJavaIdentifierPart(): Boolean = Character.isJavaIdentifierPart */ public fun Char.isJavaIdentifierStart(): Boolean = Character.isJavaIdentifierStart(this) -deprecated("Please use Char.isJavaIdentifierStart() instead") +@Deprecated("Please use Char.isJavaIdentifierStart() instead") public fun Char.isJavaLetter(): Boolean = Character.isJavaLetter(this) -deprecated("Please use Char.isJavaIdentifierPart() instead") +@Deprecated("Please use Char.isJavaIdentifierPart() instead") public fun Char.isJavaLetterOrDigit(): Boolean = Character.isJavaLetterOrDigit(this) /** diff --git a/libraries/stdlib/src/kotlin/text/CharsetsJVM.kt b/libraries/stdlib/src/kotlin/text/CharsetsJVM.kt index 7862758b40c..34a8812a8c9 100644 --- a/libraries/stdlib/src/kotlin/text/CharsetsJVM.kt +++ b/libraries/stdlib/src/kotlin/text/CharsetsJVM.kt @@ -12,38 +12,38 @@ public object Charsets { /** * Eight-bit UCS Transformation Format. */ - platformStatic + @platformStatic public val UTF_8: Charset = Charset.forName("UTF-8") /** * Sixteen-bit UCS Transformation Format, byte order identified by an * optional byte-order mark. */ - platformStatic + @platformStatic public val UTF_16: Charset = Charset.forName("UTF-16") /** * Sixteen-bit UCS Transformation Format, big-endian byte order. */ - platformStatic + @platformStatic public val UTF_16BE: Charset = Charset.forName("UTF-16BE") /** * Sixteen-bit UCS Transformation Format, little-endian byte order. */ - platformStatic + @platformStatic public val UTF_16LE: Charset = Charset.forName("UTF-16LE") /** * Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the * Unicode character set. */ - platformStatic + @platformStatic public val US_ASCII: Charset = Charset.forName("US-ASCII") /** * ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1. */ - platformStatic + @platformStatic public val ISO_8859_1: Charset = Charset.forName("ISO-8859-1") } diff --git a/libraries/stdlib/src/kotlin/text/Strings.kt b/libraries/stdlib/src/kotlin/text/Strings.kt index 29205c5387b..767e1872b62 100644 --- a/libraries/stdlib/src/kotlin/text/Strings.kt +++ b/libraries/stdlib/src/kotlin/text/Strings.kt @@ -6,11 +6,11 @@ import kotlin.text.MatchResult import kotlin.text.Regex /** Returns the string with leading and trailing text matching the given string removed */ -deprecated("Use removeSurrounding(text, text) or removePrefix(text).removeSuffix(text)") +@Deprecated("Use removeSurrounding(text, text) or removePrefix(text).removeSuffix(text)") public fun String.trim(text: String): String = removePrefix(text).removeSuffix(text) /** Returns the string with the prefix and postfix text trimmed */ -deprecated("Use removeSurrounding(prefix, suffix) or removePrefix(prefix).removeSuffix(suffix)") +@Deprecated("Use removeSurrounding(prefix, suffix) or removePrefix(prefix).removeSuffix(suffix)") public fun String.trim(prefix: String, postfix: String): String = removePrefix(prefix).removeSuffix(postfix) /** @@ -79,10 +79,10 @@ public fun String.trimStart(vararg chars: Char): String = trimStart { it in char */ public fun String.trimEnd(vararg chars: Char): String = trimEnd { it in chars } -deprecated("Use removePrefix() instead", ReplaceWith("removePrefix(prefix)")) +@Deprecated("Use removePrefix() instead", ReplaceWith("removePrefix(prefix)")) public fun String.trimLeading(prefix: String): String = removePrefix(prefix) -deprecated("Use removeSuffix() instead", ReplaceWith("removeSuffix(postfix)")) +@Deprecated("Use removeSuffix() instead", ReplaceWith("removeSuffix(postfix)")) public fun String.trimTrailing(postfix: String): String = removeSuffix(postfix) /** @@ -95,7 +95,7 @@ public fun String.trim(): String = trim { it.isWhitespace() } */ public fun String.trimStart(): String = trimStart { it.isWhitespace() } -deprecated("Use trimStart instead.", ReplaceWith("trimStart()")) +@Deprecated("Use trimStart instead.", ReplaceWith("trimStart()")) public fun String.trimLeading(): String = trimStart { it.isWhitespace() } /** @@ -103,7 +103,7 @@ public fun String.trimLeading(): String = trimStart { it.isWhitespace() } */ public fun String.trimEnd(): String = trimEnd { it.isWhitespace() } -deprecated("Use trimEnd instead.", ReplaceWith("trimEnd()")) +@Deprecated("Use trimEnd instead.", ReplaceWith("trimEnd()")) public fun String.trimTrailing(): String = trimEnd { it.isWhitespace() } /** @@ -149,8 +149,8 @@ public fun String.padEnd(length: Int, padChar: Char = ' '): String { } /** Returns `true` if the string is not `null` and not empty */ -deprecated("Use !isNullOrEmpty() or isNullOrEmpty().not() for nullable strings.", ReplaceWith("this != null && this.isNotEmpty()")) -platformName("isNotEmptyNullable") +@Deprecated("Use !isNullOrEmpty() or isNullOrEmpty().not() for nullable strings.", ReplaceWith("this != null && this.isNotEmpty()")) +@platformName("isNotEmptyNullable") public fun String?.isNotEmpty(): Boolean = this != null && this.length() > 0 /** @@ -738,7 +738,7 @@ public fun String.indexOf(char: Char, startIndex: Int = 0, ignoreCase: Boolean = * @param ignoreCase `true` to ignore character case when matching a string. By default `false`. * @returns An index of the first occurrence of [string] or -1 if none is found. */ -kotlin.jvm.jvmOverloads +@kotlin.jvm.jvmOverloads public fun String.indexOf(string: String, startIndex: Int = 0, ignoreCase: Boolean = false): Int { return if (ignoreCase) indexOfAny(listOf(string), startIndex, ignoreCase) @@ -920,7 +920,7 @@ public fun String.splitToSequence(vararg delimiters: String, ignoreCase: Boolean public fun String.split(vararg delimiters: String, ignoreCase: Boolean = false, limit: Int = 0): List = splitToSequence(*delimiters, ignoreCase = ignoreCase, limit = limit).toList() -deprecated("Use split(delimiters) instead.", ReplaceWith("split(*delimiters, ignoreCase = ignoreCase, limit = limit)")) +@Deprecated("Use split(delimiters) instead.", ReplaceWith("split(*delimiters, ignoreCase = ignoreCase, limit = limit)")) public fun String.splitBy(vararg delimiters: String, ignoreCase: Boolean = false, limit: Int = 0): List = splitToSequence(*delimiters, ignoreCase = ignoreCase, limit = limit).toList() diff --git a/libraries/stdlib/src/kotlin/text/StringsJVM.kt b/libraries/stdlib/src/kotlin/text/StringsJVM.kt index e9952c366b3..2bee9a9c2e3 100644 --- a/libraries/stdlib/src/kotlin/text/StringsJVM.kt +++ b/libraries/stdlib/src/kotlin/text/StringsJVM.kt @@ -32,7 +32,7 @@ private fun String.nativeLastIndexOf(str: String, fromIndex: Int): Int = (this a /** * Compares this string to another string, ignoring case considerations. */ -deprecated("Use equals(anotherString, ignoreCase = true) instead", ReplaceWith("equals(anotherString, ignoreCase = true)")) +@Deprecated("Use equals(anotherString, ignoreCase = true) instead", ReplaceWith("equals(anotherString, ignoreCase = true)")) public fun String.equalsIgnoreCase(anotherString: String): Boolean = equals(anotherString, ignoreCase = true) /** @@ -82,14 +82,14 @@ public fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: B return if (index < 0) this else this.replaceRange(index, index + oldValue.length(), newValue) } -deprecated("Use String.replaceFirst instead.", ReplaceWith("replaceFirst(oldValue, newValue, ignoreCase = ignoreCase)")) +@Deprecated("Use String.replaceFirst instead.", ReplaceWith("replaceFirst(oldValue, newValue, ignoreCase = ignoreCase)")) public fun String.replaceFirstLiteral(oldValue: String, newValue: String, ignoreCase: Boolean = false): String = replaceFirst(oldValue, newValue, ignoreCase = ignoreCase) /** * Returns a new string obtained by replacing each substring of this string that matches the given regular expression * with the given [replacement]. */ -deprecated("Use String.replace(Regex, String) instead. You can convert regex parameter with .toRegex() extension function.", ReplaceWith("replace(regex.toRegex(), replacement)")) +@Deprecated("Use String.replace(Regex, String) instead. You can convert regex parameter with .toRegex() extension function.", ReplaceWith("replace(regex.toRegex(), replacement)")) public fun String.replaceAll(regex: String, replacement: String): String = (this as java.lang.String).replaceAll(regex, replacement) /** @@ -272,7 +272,7 @@ public fun String.codePointCount(beginIndex: Int, endIndex: Int): Int = (this as /** * Compares two strings lexicographically, ignoring case differences. */ -deprecated("Use compareTo with true passed to ignoreCase parameter.", ReplaceWith("compareTo(str, ignoreCase = true)")) +@Deprecated("Use compareTo with true passed to ignoreCase parameter.", ReplaceWith("compareTo(str, ignoreCase = true)")) public fun String.compareToIgnoreCase(str: String): Int = (this as java.lang.String).compareToIgnoreCase(str) /** @@ -323,7 +323,7 @@ public fun String.isBlank(): Boolean = length() == 0 || all { it.isWhitespace() /** * Returns `true` if this string matches the given regular expression. */ -deprecated("Use String.matches(Regex) instead. You can convert regex parameter with .toRegex() extension function.", ReplaceWith("matches(regex.toRegex())")) +@Deprecated("Use String.matches(Regex) instead. You can convert regex parameter with .toRegex() extension function.", ReplaceWith("matches(regex.toRegex())")) public fun String.matches(regex: String): Boolean = (this as java.lang.String).matches(regex) /** @@ -339,7 +339,7 @@ public fun String.offsetByCodePoints(index: Int, codePointOffset: Int): Int = (t * @param ooffset the start offset in the other string of the substring to compare. * @param len the length of the substring to compare. */ -deprecated("Use regionMatches overload with ignoreCase as optional last parameter.", ReplaceWith("regionMatches(toffset, other, ooffset, len, ignoreCase)")) +@Deprecated("Use regionMatches overload with ignoreCase as optional last parameter.", ReplaceWith("regionMatches(toffset, other, ooffset, len, ignoreCase)")) public fun String.regionMatches(ignoreCase: Boolean, toffset: Int, other: String, ooffset: Int, len: Int): Boolean = (this as java.lang.String).regionMatches(ignoreCase, toffset, other, ooffset, len) /** @@ -423,13 +423,13 @@ public fun String.toByteArray(charset: String): ByteArray = (this as java.lang.S */ public fun String.toByteArray(charset: Charset = Charsets.UTF_8): ByteArray = (this as java.lang.String).getBytes(charset) -deprecated("Use toByteArray() instead to emphasize copy behaviour", ReplaceWith("toByteArray()")) +@Deprecated("Use toByteArray() instead to emphasize copy behaviour", ReplaceWith("toByteArray()")) public fun String.getBytes(): ByteArray = (this as java.lang.String).getBytes() -deprecated("Use toByteArray(charset) instead to emphasize copy behaviour", ReplaceWith("toByteArray(charset)")) +@Deprecated("Use toByteArray(charset) instead to emphasize copy behaviour", ReplaceWith("toByteArray(charset)")) public fun String.getBytes(charset: Charset): ByteArray = (this as java.lang.String).getBytes(charset) -deprecated("Use toByteArray(charset) instead to emphasize copy behaviour", ReplaceWith("toByteArray(charset)")) +@Deprecated("Use toByteArray(charset) instead to emphasize copy behaviour", ReplaceWith("toByteArray(charset)")) public fun String.getBytes(charset: String): ByteArray = (this as java.lang.String).getBytes(charset) /** @@ -519,7 +519,7 @@ public inline fun String.takeWhileTo(result: T, predicate: (Cha * Replaces every [regexp] occurence in the text with the value returned by the given function [body] that * takes a [MatchResult]. */ -deprecated("Use String.replace(Regex, (MatchResult)->String) instead. You can convert regex parameter with .toRegex() extension function.") +@Deprecated("Use String.replace(Regex, (MatchResult)->String) instead. You can convert regex parameter with .toRegex() extension function.") public fun String.replaceAll(regexp: String, body: (java.util.regex.MatchResult) -> String): String { val sb = StringBuilder(this.length()) val p = regexp.toPattern() diff --git a/libraries/stdlib/src/kotlin/text/regex/RegexJVM.kt b/libraries/stdlib/src/kotlin/text/regex/RegexJVM.kt index d33c667ea6d..eeb592db58b 100644 --- a/libraries/stdlib/src/kotlin/text/regex/RegexJVM.kt +++ b/libraries/stdlib/src/kotlin/text/regex/RegexJVM.kt @@ -108,7 +108,7 @@ public class Regex internal constructor(private val nativePattern: Pattern) { /** The set of options that were used to create this regular expression. */ public val options: Set = fromInt(nativePattern.flags(), RegexOption.values()) - deprecated("To get the Matcher from java.util.regex.Pattern use toPattern to convert string to Pattern, or migrate to Regex API") + @Deprecated("To get the Matcher from java.util.regex.Pattern use toPattern to convert string to Pattern, or migrate to Regex API") public fun matcher(input: CharSequence): Matcher = nativePattern.matcher(input) /** Indicates whether the regular expression matches the entire [input]. */ diff --git a/libraries/stdlib/src/kotlin/util/AssertionsJVM.kt b/libraries/stdlib/src/kotlin/util/AssertionsJVM.kt index c1e17d607a1..9412cbb4066 100644 --- a/libraries/stdlib/src/kotlin/util/AssertionsJVM.kt +++ b/libraries/stdlib/src/kotlin/util/AssertionsJVM.kt @@ -3,7 +3,7 @@ package kotlin private object _Assertions -deprecated("Must be public to make assert() inlinable") +@Deprecated("Must be public to make assert() inlinable") public val ASSERTIONS_ENABLED: Boolean = _Assertions.javaClass.desiredAssertionStatus() /** @@ -18,7 +18,7 @@ public fun assert(value: Boolean) { * Throws an [AssertionError] with an optional [message] if the [value] is false * and runtime assertions have been enabled on the JVM using the *-ea* JVM option. */ -@deprecated("Use assert with lazy message instead.", ReplaceWith("assert(value) { message }")) +@Deprecated("Use assert with lazy message instead.", ReplaceWith("assert(value) { message }")) public fun assert(value: Boolean, message: Any = "Assertion failed") { if (ASSERTIONS_ENABLED) { if (!value) { diff --git a/libraries/stdlib/src/kotlin/util/Integers.kt b/libraries/stdlib/src/kotlin/util/Integers.kt index 4dc3c19941a..0a7138cb040 100644 --- a/libraries/stdlib/src/kotlin/util/Integers.kt +++ b/libraries/stdlib/src/kotlin/util/Integers.kt @@ -3,7 +3,7 @@ package kotlin /** * Executes the given function [body] the number of times equal to the value of this integer. */ -deprecated("Use repeat(n) { body } instead.") +@Deprecated("Use repeat(n) { body } instead.") public inline fun Int.times(body : () -> Unit) { var count = this; while (count > 0) { diff --git a/libraries/stdlib/src/kotlin/util/JLangJVM.kt b/libraries/stdlib/src/kotlin/util/JLangJVM.kt index 7d8ff4a93d9..c1a7f560a4d 100644 --- a/libraries/stdlib/src/kotlin/util/JLangJVM.kt +++ b/libraries/stdlib/src/kotlin/util/JLangJVM.kt @@ -37,7 +37,7 @@ public val T.javaClass : Class * Returns the Java class for the specified type. */ @Intrinsic("kotlin.javaClass.function") -@deprecated("Use the class reference and .java extension property instead: MyClass::class.java", ReplaceWith("T::class.java")) +@Deprecated("Use the class reference and .java extension property instead: MyClass::class.java", ReplaceWith("T::class.java")) public fun javaClass(): Class = T::class.java /** diff --git a/libraries/stdlib/src/kotlin/util/Lazy.kt b/libraries/stdlib/src/kotlin/util/Lazy.kt index 20028341b22..baef914f0cd 100644 --- a/libraries/stdlib/src/kotlin/util/Lazy.kt +++ b/libraries/stdlib/src/kotlin/util/Lazy.kt @@ -53,7 +53,7 @@ private object UNINITIALIZED_VALUE private open class LazyImpl(initializer: () -> T) : Lazy(), Serializable { private var initializer: (() -> T)? = initializer - private volatile var _value: Any? = UNINITIALIZED_VALUE + @volatile private var _value: Any? = UNINITIALIZED_VALUE protected open val lock: Any get() = this diff --git a/libraries/stdlib/src/kotlin/util/Ordering.kt b/libraries/stdlib/src/kotlin/util/Ordering.kt index a3fac9a4cbe..d78c2ad0a3c 100644 --- a/libraries/stdlib/src/kotlin/util/Ordering.kt +++ b/libraries/stdlib/src/kotlin/util/Ordering.kt @@ -25,7 +25,7 @@ import kotlin.platform.platformName * objects. As soon as the [Comparable] instances returned by a function for [a] and [b] values do not * compare as equal, the result of that comparison is returned. */ -deprecated("Use selector functions accepting nullable T as a receiver.") +@Deprecated("Use selector functions accepting nullable T as a receiver.") public fun compareValuesBy(a: T?, b: T?, vararg functions: (T) -> Comparable<*>?): Int { require(functions.size() > 0) if (a === b) return 0 @@ -47,7 +47,7 @@ public fun compareValuesBy(a: T?, b: T?, vararg functions: (T) -> Comp * compare as equal, the result of that comparison is returned. */ // TODO: Remove platformName after M13 -platformName("compareValuesByNullable") +@platformName("compareValuesByNullable") public fun compareValuesBy(a: T, b: T, vararg selectors: (T) -> Comparable<*>?): Int { require(selectors.size() > 0) for (fn in selectors) { @@ -82,7 +82,7 @@ public inline fun compareValuesBy(a: T, b: T, comparator: Comparator compareValuesWith(a: T, b: T, comparator: Comparator): Int = comparator.compare(a, b) // @@ -113,13 +113,13 @@ public fun compareBy(vararg selectors: (T) -> Comparable<*>?): Comparator /** * Creates a comparator using the sequence of functions to calculate a result of comparison. */ -deprecated("Use compareBy() instead", ReplaceWith("compareBy(*functions)")) +@Deprecated("Use compareBy() instead", ReplaceWith("compareBy(*functions)")) public fun comparator(vararg functions: (T) -> Comparable<*>?): Comparator = compareBy(*functions) /** * Creates a comparator using the function to transform value to a [Comparable] instance for comparison. */ -inline public fun compareBy(inlineOptions(InlineOption.ONLY_LOCAL_RETURN) selector: (T) -> Comparable<*>?): Comparator { +inline public fun compareBy(crossinline selector: (T) -> Comparable<*>?): Comparator { return object : Comparator { public override fun compare(a: T, b: T): Int = compareValuesBy(a, b, selector) } @@ -129,7 +129,7 @@ inline public fun compareBy(inlineOptions(InlineOption.ONLY_LOCAL_RETURN) se * Creates a comparator using the [selector] function to transform values being compared and then applying * the specified [comparator] to compare transformed values. */ -inline public fun compareBy(comparator: Comparator, inlineOptions(InlineOption.ONLY_LOCAL_RETURN) selector: (T) -> K): Comparator { +inline public fun compareBy(comparator: Comparator, crossinline selector: (T) -> K): Comparator { return object : Comparator { public override fun compare(a: T, b: T): Int = compareValuesBy(a, b, comparator, selector) } @@ -138,7 +138,7 @@ inline public fun compareBy(comparator: Comparator, inlineOptions(I /** * Creates a descending comparator using the function to transform value to a [Comparable] instance for comparison. */ -inline public fun compareByDescending(inlineOptions(InlineOption.ONLY_LOCAL_RETURN) selector: (T) -> Comparable<*>?): Comparator { +inline public fun compareByDescending(crossinline selector: (T) -> Comparable<*>?): Comparator { return object : Comparator { public override fun compare(a: T, b: T): Int = compareValuesBy(b, a, selector) } @@ -150,7 +150,7 @@ inline public fun compareByDescending(inlineOptions(InlineOption.ONLY_LOCAL_ * * Note that an order of [comparator] is reversed by this wrapper. */ -inline public fun compareByDescending(comparator: Comparator, inlineOptions(InlineOption.ONLY_LOCAL_RETURN) selector: (T) -> K): Comparator { +inline public fun compareByDescending(comparator: Comparator, crossinline selector: (T) -> K): Comparator { return object : Comparator { public override fun compare(a: T, b: T): Int = compareValuesBy(b, a, comparator, selector) } @@ -160,7 +160,7 @@ inline public fun compareByDescending(comparator: Comparator, inlin * Creates a comparator comparing values after the primary comparator defined them equal. It uses * the function to transform value to a [Comparable] instance for comparison. */ -inline public fun Comparator.thenBy(inlineOptions(InlineOption.ONLY_LOCAL_RETURN) selector: (T) -> Comparable<*>?): Comparator { +inline public fun Comparator.thenBy(crossinline selector: (T) -> Comparable<*>?): Comparator { return object : Comparator { public override fun compare(a: T, b: T): Int { val previousCompare = this@thenBy.compare(a, b) @@ -173,7 +173,7 @@ inline public fun Comparator.thenBy(inlineOptions(InlineOption.ONLY_LOCAL * Creates a comparator comparing values after the primary comparator defined them equal. It uses * the [selector] function to transform values and then compares them with the given [comparator]. */ -inline public fun Comparator.thenBy(comparator: Comparator, inlineOptions(InlineOption.ONLY_LOCAL_RETURN) selector: (T) -> K): Comparator { +inline public fun Comparator.thenBy(comparator: Comparator, crossinline selector: (T) -> K): Comparator { return object : Comparator { public override fun compare(a: T, b: T): Int { val previousCompare = this@thenBy.compare(a, b) @@ -186,7 +186,7 @@ inline public fun Comparator.thenBy(comparator: Comparator, inli * Creates a descending comparator using the primary comparator and * the function to transform value to a [Comparable] instance for comparison. */ -inline public fun Comparator.thenByDescending(inlineOptions(InlineOption.ONLY_LOCAL_RETURN) selector: (T) -> Comparable<*>?): Comparator { +inline public fun Comparator.thenByDescending(crossinline selector: (T) -> Comparable<*>?): Comparator { return object : Comparator { public override fun compare(a: T, b: T): Int { val previousCompare = this@thenByDescending.compare(a, b) @@ -199,7 +199,7 @@ inline public fun Comparator.thenByDescending(inlineOptions(InlineOption. * Creates a descending comparator comparing values after the primary comparator defined them equal. It uses * the [selector] function to transform values and then compares them with the given [comparator]. */ -inline public fun Comparator.thenByDescending(comparator: Comparator, inlineOptions(InlineOption.ONLY_LOCAL_RETURN) selector: (T) -> K): Comparator { +inline public fun Comparator.thenByDescending(comparator: Comparator, crossinline selector: (T) -> K): Comparator { return object : Comparator { public override fun compare(a: T, b: T): Int { val previousCompare = this@thenByDescending.compare(a, b) @@ -212,7 +212,7 @@ inline public fun Comparator.thenByDescending(comparator: Comparator comparator(inlineOptions(InlineOption.ONLY_LOCAL_RETURN) comparison: (T, T) -> Int): Comparator { +inline public fun comparator(crossinline comparison: (T, T) -> Int): Comparator { return object : Comparator { public override fun compare(a: T, b: T): Int = comparison(a, b) } @@ -221,7 +221,7 @@ inline public fun comparator(inlineOptions(InlineOption.ONLY_LOCAL_RETURN) c /** * Creates a comparator using the primary comparator and function to calculate a result of comparison. */ -inline public fun Comparator.thenComparator(inlineOptions(InlineOption.ONLY_LOCAL_RETURN) comparison: (T, T) -> Int): Comparator { +inline public fun Comparator.thenComparator(crossinline comparison: (T, T) -> Int): Comparator { return object : Comparator { public override fun compare(a: T, b: T): Int { val previousCompare = this@thenComparator.compare(a, b) diff --git a/libraries/stdlib/src/kotlin/util/Preconditions.kt b/libraries/stdlib/src/kotlin/util/Preconditions.kt index 1dd75849931..48899c0e932 100644 --- a/libraries/stdlib/src/kotlin/util/Preconditions.kt +++ b/libraries/stdlib/src/kotlin/util/Preconditions.kt @@ -14,7 +14,7 @@ public fun require(value: Boolean): Unit = require(value) { "Failed requirement" * * @sample test.collections.PreconditionsTest.failingRequireWithMessage */ -@deprecated("Use require with lazy message instead.", ReplaceWith("require(value) { message }")) +@Deprecated("Use require with lazy message instead.", ReplaceWith("require(value) { message }")) public fun require(value: Boolean, message: Any = "Failed requirement"): Unit { if (!value) { throw IllegalArgumentException(message.toString()) @@ -44,7 +44,7 @@ public fun requireNotNull(value: T?): T = requireNotNull(value) { "Requi * * @sample test.collections.PreconditionsTest.requireNotNull */ -@deprecated("Use requireNotNull with lazy message instead.", ReplaceWith("requireNotNull(value) { message }")) +@Deprecated("Use requireNotNull with lazy message instead.", ReplaceWith("requireNotNull(value) { message }")) public fun requireNotNull(value: T?, message: Any = "Required value was null"): T { if (value == null) { throw IllegalArgumentException(message.toString()) @@ -78,7 +78,7 @@ public fun check(value: Boolean): Unit = check(value) { "Check failed" } * * @sample test.collections.PreconditionsTest.failingCheckWithMessage */ -@deprecated("Use check with lazy message instead.", ReplaceWith("check(value) { message }")) +@Deprecated("Use check with lazy message instead.", ReplaceWith("check(value) { message }")) public fun check(value: Boolean, message: Any = "Check failed"): Unit { if (!value) { throw IllegalStateException(message.toString()) @@ -109,7 +109,7 @@ public fun checkNotNull(value: T?): T = checkNotNull(value) { "Required * * @sample test.collections.PreconditionsTest.checkNotNull */ -@deprecated("Use checkNotNull with lazy message instead.", ReplaceWith("checkNotNull(value) { message }")) +@Deprecated("Use checkNotNull with lazy message instead.", ReplaceWith("checkNotNull(value) { message }")) public fun checkNotNull(value: T?, message: Any = "Required value was null"): T { if (value == null) { throw IllegalStateException(message.toString()) diff --git a/libraries/stdlib/test/AnnotationsTest.kt b/libraries/stdlib/test/AnnotationsTest.kt index 8fbb3ca3251..5190dce9899 100644 --- a/libraries/stdlib/test/AnnotationsTest.kt +++ b/libraries/stdlib/test/AnnotationsTest.kt @@ -13,7 +13,7 @@ class AnnotatedClass class AnnotationTest { - test fun annotationType() { + @test fun annotationType() { val annotations = javaClass().getAnnotations()!! var foundMyAnno = false diff --git a/libraries/stdlib/test/DataClassTest.kt b/libraries/stdlib/test/DataClassTest.kt index b589d3fb27e..089888cfc68 100644 --- a/libraries/stdlib/test/DataClassTest.kt +++ b/libraries/stdlib/test/DataClassTest.kt @@ -7,7 +7,8 @@ import java.io.Serializable /** */ class DataClassTest { - Test fun dataClass() { + @Test + fun dataClass() { val p = Person("James", 43) println("Got $p") assertEquals("Person(name=James, age=43)", "$p", "toString") diff --git a/libraries/stdlib/test/DefaultIntrinsicObjectsJVMTest.kt b/libraries/stdlib/test/DefaultIntrinsicObjectsJVMTest.kt index 92220dd2788..ebb4c0b18a4 100644 --- a/libraries/stdlib/test/DefaultIntrinsicObjectsJVMTest.kt +++ b/libraries/stdlib/test/DefaultIntrinsicObjectsJVMTest.kt @@ -23,14 +23,14 @@ import kotlin.test.* import org.junit.Test as test class CompanionObjectsExtensionsTest { - test fun intTest() { + @test fun intTest() { val i = Int assertEquals(java.lang.Integer.MAX_VALUE, Int.MAX_VALUE) assertEquals(java.lang.Integer.MIN_VALUE, Int.MIN_VALUE) } - test fun doubleTest() { + @test fun doubleTest() { val d = Double assertEquals(java.lang.Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY) @@ -41,7 +41,7 @@ class CompanionObjectsExtensionsTest { assertEquals(java.lang.Double.MIN_VALUE, Double.MIN_VALUE) } - test fun floatTest() { + @test fun floatTest() { val f = Float assertEquals(java.lang.Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY) @@ -52,34 +52,34 @@ class CompanionObjectsExtensionsTest { assertEquals(java.lang.Float.MIN_VALUE, Float.MIN_VALUE) } - test fun longTest() { + @test fun longTest() { val l = Long assertEquals(java.lang.Long.MAX_VALUE, Long.MAX_VALUE) assertEquals(java.lang.Long.MIN_VALUE, Long.MIN_VALUE) } - test fun shortTest() { + @test fun shortTest() { val s = Short assertEquals(java.lang.Short.MAX_VALUE, Short.MAX_VALUE) assertEquals(java.lang.Short.MIN_VALUE, Short.MIN_VALUE) } - test fun byteTest() { + @test fun byteTest() { val b = Byte assertEquals(java.lang.Byte.MAX_VALUE, Byte.MAX_VALUE) assertEquals(java.lang.Byte.MIN_VALUE, Byte.MIN_VALUE) } - test fun charTest() { + @test fun charTest() { val ch = Char assertEquals(ch, Char) } - test fun stringTest() { + @test fun stringTest() { val s = String assertEquals(s, String) diff --git a/libraries/stdlib/test/ExceptionTest.kt b/libraries/stdlib/test/ExceptionTest.kt index 39a854cd1aa..132a3193e17 100644 --- a/libraries/stdlib/test/ExceptionTest.kt +++ b/libraries/stdlib/test/ExceptionTest.kt @@ -9,12 +9,12 @@ import java.io.* class ExceptionTest { - test fun printStackTraceOnRuntimeException() { + @test fun printStackTraceOnRuntimeException() { assertPrintStackTrace(RuntimeException("Crikey!")) assertPrintStackTraceStream(RuntimeException("Crikey2")) } - test fun printStackTraceOnError() { + @test fun printStackTraceOnError() { assertPrintStackTrace(Error("Oh dear")) assertPrintStackTraceStream(Error("Oh dear2")) } diff --git a/libraries/stdlib/test/GetOrElseTest.kt b/libraries/stdlib/test/GetOrElseTest.kt index d12c9e0efeb..7534c69d231 100644 --- a/libraries/stdlib/test/GetOrElseTest.kt +++ b/libraries/stdlib/test/GetOrElseTest.kt @@ -9,7 +9,7 @@ class GetOrElseTest { val v2: String? = null var counter = 0 - test fun defaultValue() { + @test fun defaultValue() { assertEquals("hello", v1?: "bar") expect("hello") { @@ -17,7 +17,7 @@ class GetOrElseTest { } } - test fun defaultValueOnNull() { + @test fun defaultValueOnNull() { assertEquals("bar", v2?: "bar") expect("bar") { @@ -30,7 +30,7 @@ class GetOrElseTest { return "bar" } - test fun lazyDefaultValue() { + @test fun lazyDefaultValue() { counter = 0 assertEquals("hello", v1?: calculateBar()) diff --git a/libraries/stdlib/test/MathTest.kt b/libraries/stdlib/test/MathTest.kt index 6b33ac04eee..e7428b869cc 100644 --- a/libraries/stdlib/test/MathTest.kt +++ b/libraries/stdlib/test/MathTest.kt @@ -8,7 +8,7 @@ import kotlin.test.* import org.junit.Test as test class MathTest { - test fun testBigInteger() { + @test fun testBigInteger() { val a = BigInteger("2") val b = BigInteger("3") @@ -21,7 +21,7 @@ class MathTest { assertEquals(BigInteger("-2"), -a remainder b) } - test fun testBigDecimal() { + @test fun testBigDecimal() { val a = BigDecimal("2") val b = BigDecimal("3") diff --git a/libraries/stdlib/test/NaturalLanguageTest.kt b/libraries/stdlib/test/NaturalLanguageTest.kt index 8d4a04cf7b4..fb2a3965113 100644 --- a/libraries/stdlib/test/NaturalLanguageTest.kt +++ b/libraries/stdlib/test/NaturalLanguageTest.kt @@ -5,12 +5,12 @@ import kotlin.test.* class NaturalLanguageTest { - test fun `strings equal`() { + @test fun `strings equal`() { val actual = "abc" assertEquals("abc", actual) } - test fun `numbers equal`() { + @test fun `numbers equal`() { val actual = 5 assertEquals(5, actual) } diff --git a/libraries/stdlib/test/OldStdlibTest.kt b/libraries/stdlib/test/OldStdlibTest.kt index 60b911d99fa..fef64899d5b 100644 --- a/libraries/stdlib/test/OldStdlibTest.kt +++ b/libraries/stdlib/test/OldStdlibTest.kt @@ -8,19 +8,19 @@ import java.io.* import org.junit.Test as test class OldStdlibTest() { - test fun testCollectionEmpty() { + @test fun testCollectionEmpty() { assertNot { listOf(0, 1, 2).isEmpty() } } - test fun testCollectionSize() { + @test fun testCollectionSize() { assertTrue { listOf(0, 1, 2).size() == 3 } } - test fun testInputStreamIterator() { + @test fun testInputStreamIterator() { val x = ByteArray (10) for(index in 0..9) { diff --git a/libraries/stdlib/test/OrderingTest.kt b/libraries/stdlib/test/OrderingTest.kt index 88af1588180..fbf61f25e5f 100644 --- a/libraries/stdlib/test/OrderingTest.kt +++ b/libraries/stdlib/test/OrderingTest.kt @@ -14,27 +14,32 @@ class OrderingTest { val v1 = Item("wine", 9) val v2 = Item("beer", 10) - Test fun compareByCompareTo() { + @Test + fun compareByCompareTo() { val diff = v1.compareTo(v2) assertTrue(diff < 0) } - Test fun compareByNameFirst() { + @Test + fun compareByNameFirst() { val diff = compareValuesBy(v1, v2, { it.name }, { it.rating }) assertTrue(diff > 0) } - Test fun compareByRatingFirst() { + @Test + fun compareByRatingFirst() { val diff = compareValuesBy(v1, v2, { it.rating }, { it.name }) assertTrue(diff < 0) } - Test fun compareSameObjectsByRatingFirst() { + @Test + fun compareSameObjectsByRatingFirst() { val diff = compareValuesBy(v1, v1, { it.rating }, { it.name }) assertTrue(diff == 0) } - Test fun compareNullables() { + @Test + fun compareNullables() { val v1: Item? = this.v1 val v2: Item? = null val diff = compareValuesBy(v1, v2) { it?.rating } @@ -43,7 +48,8 @@ class OrderingTest { assertTrue(diff2 < 0) } - Test fun sortComparatorThenComparator() { + @Test + fun sortComparatorThenComparator() { val comparator = comparator { a, b -> a.name.compareTo(b.name) } thenComparator { a, b -> a.rating.compareTo(b.rating) } val diff = comparator.compare(v1, v2) @@ -53,7 +59,8 @@ class OrderingTest { assertEquals(v1, items[1]) } - Test fun combineComparators() { + @Test + fun combineComparators() { val byName = compareBy { it.name } val byRating = compareBy { it.rating } val v3 = Item(v1.name, v1.rating + 1) @@ -67,7 +74,8 @@ class OrderingTest { assertTrue( (byRating thenDescending byName).compare(v4, v2) < 0 ) } - Test fun sortByThenBy() { + @Test + fun sortByThenBy() { val comparator = compareBy { it.rating } thenBy { it.name } val diff = comparator.compare(v1, v2) @@ -77,7 +85,8 @@ class OrderingTest { assertEquals(v2, items[1]) } - Test fun sortByThenByDescending() { + @Test + fun sortByThenByDescending() { val comparator = compareBy { it.rating } thenByDescending { it.name } val diff = comparator.compare(v1, v2) @@ -87,7 +96,8 @@ class OrderingTest { assertEquals(v2, items[1]) } - Test fun sortUsingFunctionalComparator() { + @Test + fun sortUsingFunctionalComparator() { val comparator = compareBy({ it.name }, { it.rating }) val diff = comparator.compare(v1, v2) assertTrue(diff > 0) @@ -96,7 +106,8 @@ class OrderingTest { assertEquals(v1, items[1]) } - Test fun sortUsingCustomComparator() { + @Test + fun sortUsingCustomComparator() { val comparator = object : Comparator { override fun compare(o1: Item, o2: Item): Int { return compareValuesBy(o1, o2, { it.name }, { it.rating }) diff --git a/libraries/stdlib/test/PreconditionsTest.kt b/libraries/stdlib/test/PreconditionsTest.kt index d1076a34544..766e93b3ba8 100644 --- a/libraries/stdlib/test/PreconditionsTest.kt +++ b/libraries/stdlib/test/PreconditionsTest.kt @@ -5,7 +5,7 @@ import kotlin.test.* class PreconditionsTest() { - test fun passingRequire() { + @test fun passingRequire() { require(true) var called = false @@ -13,32 +13,32 @@ class PreconditionsTest() { assertFalse(called) } - test fun failingRequire() { + @test fun failingRequire() { val error = assertFailsWith(IllegalArgumentException::class) { require(false) } assertNotNull(error.getMessage()) } - test fun passingRequireWithMessage() { + @test fun passingRequireWithMessage() { require(true, "Hello") } - test fun failingRequireWithMessage() { + @test fun failingRequireWithMessage() { val error = assertFailsWith(IllegalArgumentException::class) { require(false, "Hello") } assertEquals("Hello", error.getMessage()) } - test fun failingRequireWithLazyMessage() { + @test fun failingRequireWithLazyMessage() { val error = assertFailsWith(IllegalArgumentException::class) { require(false) { "Hello" } } assertEquals("Hello", error.getMessage()) } - test fun passingCheck() { + @test fun passingCheck() { check(true) var called = false @@ -46,45 +46,45 @@ class PreconditionsTest() { assertFalse(called) } - test fun failingCheck() { + @test fun failingCheck() { val error = assertFailsWith(IllegalStateException::class) { check(false) } assertNotNull(error.getMessage()) } - test fun passingCheckWithMessage() { + @test fun passingCheckWithMessage() { check(true, "Hello") } - test fun failingCheckWithMessage() { + @test fun failingCheckWithMessage() { val error = assertFailsWith(IllegalStateException::class) { check(false, "Hello") } assertEquals("Hello", error.getMessage()) } - test fun failingCheckWithLazyMessage() { + @test fun failingCheckWithLazyMessage() { val error = assertFailsWith(IllegalStateException::class) { check(false) { "Hello" } } assertEquals("Hello", error.getMessage()) } - test fun requireNotNull() { + @test fun requireNotNull() { val s1: String? = "S1" val r1: String = requireNotNull(s1) assertEquals("S1", r1) } - test fun requireNotNullFails() { + @test fun requireNotNullFails() { assertFailsWith(IllegalArgumentException::class) { val s2: String? = null requireNotNull(s2) } } - test fun requireNotNullWithLazyMessage() { + @test fun requireNotNullWithLazyMessage() { val error = assertFailsWith(IllegalArgumentException::class) { val obj: Any? = null requireNotNull(obj) { "Message" } @@ -99,20 +99,20 @@ class PreconditionsTest() { assertFalse(lazyCalled, "Message is not evaluated if the condition is met") } - test fun checkNotNull() { + @test fun checkNotNull() { val s1: String? = "S1" val r1: String = checkNotNull(s1) assertEquals("S1", r1) } - test fun checkNotNullFails() { + @test fun checkNotNullFails() { assertFailsWith(IllegalStateException::class) { val s2: String? = null checkNotNull(s2) } } - test fun passingAssert() { + @test fun passingAssert() { assert(true) var called = false assert(true) { called = true; "some message" } @@ -121,7 +121,7 @@ class PreconditionsTest() { } - test fun failingAssert() { + @test fun failingAssert() { val error = assertFails { assert(false) } @@ -132,7 +132,7 @@ class PreconditionsTest() { } } - test fun error() { + @test fun error() { val error = assertFails { error("There was a problem") } @@ -143,11 +143,11 @@ class PreconditionsTest() { } } - test fun passingAssertWithMessage() { + @test fun passingAssertWithMessage() { assert(true, "Hello") } - test fun failingAssertWithMessage() { + @test fun failingAssertWithMessage() { val error = assertFails { assert(false, "Hello") } @@ -158,7 +158,7 @@ class PreconditionsTest() { } } - test fun failingAssertWithLazyMessage() { + @test fun failingAssertWithLazyMessage() { val error = assertFails { assert(false) { "Hello" } } diff --git a/libraries/stdlib/test/StdLibIssuesTest.kt b/libraries/stdlib/test/StdLibIssuesTest.kt index 5b51551d579..12fbac951c5 100644 --- a/libraries/stdlib/test/StdLibIssuesTest.kt +++ b/libraries/stdlib/test/StdLibIssuesTest.kt @@ -9,7 +9,7 @@ private fun listDifference(first : List, second : List) : List { class StdLibIssuesTest { - test fun test_KT_1131() { + @test fun test_KT_1131() { val data = arrayListOf("blah", "foo", "bar") val filterValues = arrayListOf("bar", "something", "blah") diff --git a/libraries/stdlib/test/TuplesTest.kt b/libraries/stdlib/test/TuplesTest.kt index b61c3e1b931..8013381aa9f 100644 --- a/libraries/stdlib/test/TuplesTest.kt +++ b/libraries/stdlib/test/TuplesTest.kt @@ -8,22 +8,22 @@ import kotlin.test.assertNotEquals class PairTest { val p = Pair(1, "a") - test fun pairFirstAndSecond() { + @test fun pairFirstAndSecond() { assertEquals(1, p.first) assertEquals("a", p.second) } - test fun pairMultiAssignment() { + @test fun pairMultiAssignment() { val (a, b) = p assertEquals(1, a) assertEquals("a", b) } - test fun pairToString() { + @test fun pairToString() { assertEquals("(1, a)", p.toString()) } - test fun pairEquals() { + @test fun pairEquals() { assertEquals(Pair(1, "a"), p) assertNotEquals(Pair(2, "a"), p) assertNotEquals(Pair(1, "b"), p) @@ -31,7 +31,7 @@ class PairTest { assertNotEquals("", (p : Any)) } - test fun pairHashCode() { + @test fun pairHashCode() { assertEquals(Pair(1, "a").hashCode(), p.hashCode()) assertNotEquals(Pair(2, "a").hashCode(), p.hashCode()) assertNotEquals(0, Pair(null, "b").hashCode()) @@ -39,13 +39,13 @@ class PairTest { assertEquals(0, Pair(null, null).hashCode()) } - test fun pairHashSet() { + @test fun pairHashSet() { val s = hashSetOf(Pair(1, "a"), Pair(1, "b"), Pair(1, "a")) assertEquals(2, s.size()) assertTrue(s.contains(p)) } - test fun pairToList() { + @test fun pairToList() { assertEquals(listOf(1, 2), (1 to 2).toList()) assertEquals(listOf(1, null), (1 to null).toList()) assertEquals(listOf(1, "2"), (1 to "2").toList()) @@ -55,24 +55,24 @@ class PairTest { class TripleTest { val t = Triple(1, "a", 0.07) - test fun tripleFirstAndSecond() { + @test fun tripleFirstAndSecond() { assertEquals(1, t.first) assertEquals("a", t.second) assertEquals(0.07, t.third) } - test fun tripleMultiAssignment() { + @test fun tripleMultiAssignment() { val (a, b, c) = t assertEquals(1, a) assertEquals("a", b) assertEquals(0.07, c) } - test fun tripleToString() { + @test fun tripleToString() { assertEquals("(1, a, 0.07)", t.toString()) } - test fun tripleEquals() { + @test fun tripleEquals() { assertEquals(Triple(1, "a", 0.07), t) assertNotEquals(Triple(2, "a", 0.07), t) assertNotEquals(Triple(1, "b", 0.07), t) @@ -81,7 +81,7 @@ class TripleTest { assertNotEquals("", (t : Any)) } - test fun tripleHashCode() { + @test fun tripleHashCode() { assertEquals(Triple(1, "a", 0.07).hashCode(), t.hashCode()) assertNotEquals(Triple(2, "a", 0.07).hashCode(), t.hashCode()) assertNotEquals(0, Triple(null, "b", 0.07).hashCode()) @@ -90,13 +90,13 @@ class TripleTest { assertEquals(0, Triple(null, null, null).hashCode()) } - test fun tripleHashSet() { + @test fun tripleHashSet() { val s = hashSetOf(Triple(1, "a", 0.07), Triple(1, "b", 0.07), Triple(1, "a", 0.07)) assertEquals(2, s.size()) assertTrue(s.contains(t)) } - test fun tripleToList() { + @test fun tripleToList() { assertEquals(listOf(1, 2, 3), (Triple(1, 2, 3)).toList()) assertEquals(listOf(1, null, 3), (Triple(1, null, 3)).toList()) assertEquals(listOf(1, 2, "3"), (Triple(1, 2, "3")).toList()) diff --git a/libraries/stdlib/test/browser/BrowserTest.kt b/libraries/stdlib/test/browser/BrowserTest.kt index ddb24a92971..9869e581e66 100644 --- a/libraries/stdlib/test/browser/BrowserTest.kt +++ b/libraries/stdlib/test/browser/BrowserTest.kt @@ -8,7 +8,7 @@ import org.junit.Test as test class BrowserTest { - test fun accessBrowserDOM() { + @test fun accessBrowserDOM() { registerBrowserPage() val h1 = document["h1"].first() diff --git a/libraries/stdlib/test/collections/ArraysJVMTest.kt b/libraries/stdlib/test/collections/ArraysJVMTest.kt index 17f9ac09581..e4ed7cb04c3 100644 --- a/libraries/stdlib/test/collections/ArraysJVMTest.kt +++ b/libraries/stdlib/test/collections/ArraysJVMTest.kt @@ -5,7 +5,7 @@ import org.junit.Test as test class ArraysJVMTest { - test fun orEmptyNull() { + @test fun orEmptyNull() { val x: Array? = null val y: Array? = null val xArray = x.orEmpty() @@ -14,7 +14,7 @@ class ArraysJVMTest { expect(0) { yArray.size() } } - test fun orEmptyNotNull() { + @test fun orEmptyNotNull() { val x: Array? = arrayOf("1", "2") val xArray = x.orEmpty() expect(2) { xArray.size() } diff --git a/libraries/stdlib/test/collections/ArraysTest.kt b/libraries/stdlib/test/collections/ArraysTest.kt index 40ad2fed1c6..7d4e2dcbaaf 100644 --- a/libraries/stdlib/test/collections/ArraysTest.kt +++ b/libraries/stdlib/test/collections/ArraysTest.kt @@ -17,7 +17,7 @@ fun assertArrayNotSameButEquals(expected: BooleanArray, actual: BooleanArray, me class ArraysTest { - test fun emptyArrayLastIndex() { + @test fun emptyArrayLastIndex() { val arr1 = IntArray(0) assertEquals(-1, arr1.lastIndex) @@ -25,7 +25,7 @@ class ArraysTest { assertEquals(-1, arr2.lastIndex) } - test fun arrayLastIndex() { + @test fun arrayLastIndex() { val arr1 = intArrayOf(0, 1, 2, 3, 4) assertEquals(4, arr1.lastIndex) assertEquals(4, arr1[arr1.lastIndex]) @@ -35,7 +35,7 @@ class ArraysTest { assertEquals("4", arr2[arr2.lastIndex]) } - test fun byteArray() { + @test fun byteArray() { val arr = ByteArray(2) val expected: Byte = 0 @@ -44,7 +44,7 @@ class ArraysTest { assertEquals(expected, arr[1]) } - test fun shortArray() { + @test fun shortArray() { val arr = ShortArray(2) val expected: Short = 0 @@ -53,7 +53,7 @@ class ArraysTest { assertEquals(expected, arr[1]) } - test fun intArray() { + @test fun intArray() { val arr = IntArray(2) assertEquals(arr.size(), 2) @@ -61,7 +61,7 @@ class ArraysTest { assertEquals(0, arr[1]) } - test fun longArray() { + @test fun longArray() { val arr = LongArray(2) val expected: Long = 0 @@ -70,7 +70,7 @@ class ArraysTest { assertEquals(expected, arr[1]) } - test fun floatArray() { + @test fun floatArray() { val arr = FloatArray(2) val expected: Float = 0.0F @@ -79,7 +79,7 @@ class ArraysTest { assertEquals(expected, arr[1]) } - test fun doubleArray() { + @test fun doubleArray() { val arr = DoubleArray(2) assertEquals(arr.size(), 2) @@ -87,7 +87,7 @@ class ArraysTest { assertEquals(0.0, arr[1]) } - test fun charArray() { + @test fun charArray() { val arr = CharArray(2) val expected: Char = '\u0000' @@ -96,14 +96,14 @@ class ArraysTest { assertEquals(expected, arr[1]) } - test fun booleanArray() { + @test fun booleanArray() { val arr = BooleanArray(2) assertEquals(arr.size(), 2) assertEquals(false, arr[0]) assertEquals(false, arr[1]) } - test fun min() { + @test fun min() { expect(null, { arrayOf().min() }) expect(1, { arrayOf(1).min() }) expect(2, { arrayOf(2, 3).min() }) @@ -112,7 +112,7 @@ class ArraysTest { expect("a", { arrayOf("a", "b").min() }) } - test fun minInPrimitiveArrays() { + @test fun minInPrimitiveArrays() { expect(null, { intArrayOf().min() }) expect(1, { intArrayOf(1).min() }) expect(2, { intArrayOf(2, 3).min() }) @@ -124,7 +124,7 @@ class ArraysTest { expect('a', { charArrayOf('a', 'b').min() }) } - test fun max() { + @test fun max() { expect(null, { arrayOf().max() }) expect(1, { arrayOf(1).max() }) expect(3, { arrayOf(2, 3).max() }) @@ -133,7 +133,7 @@ class ArraysTest { expect("b", { arrayOf("a", "b").max() }) } - test fun maxInPrimitiveArrays() { + @test fun maxInPrimitiveArrays() { expect(null, { intArrayOf().max() }) expect(1, { intArrayOf(1).max() }) expect(3, { intArrayOf(2, 3).max() }) @@ -145,7 +145,7 @@ class ArraysTest { expect('b', { charArrayOf('a', 'b').max() }) } - test fun minBy() { + @test fun minBy() { expect(null, { arrayOf().minBy { it } }) expect(1, { arrayOf(1).minBy { it } }) expect(3, { arrayOf(2, 3).minBy { -it } }) @@ -153,7 +153,7 @@ class ArraysTest { expect("b", { arrayOf("b", "abc").minBy { it.length() } }) } - test fun minByInPrimitiveArrays() { + @test fun minByInPrimitiveArrays() { expect(null, { intArrayOf().minBy { it } }) expect(1, { intArrayOf(1).minBy { it } }) expect(3, { intArrayOf(2, 3).minBy { -it } }) @@ -164,7 +164,7 @@ class ArraysTest { expect(2.0, { doubleArrayOf(2.0, 3.0).minBy { Math.sqrt(it) } }) } - test fun maxBy() { + @test fun maxBy() { expect(null, { arrayOf().maxBy { it } }) expect(1, { arrayOf(1).maxBy { it } }) expect(2, { arrayOf(2, 3).maxBy { -it } }) @@ -172,7 +172,7 @@ class ArraysTest { expect("abc", { arrayOf("b", "abc").maxBy { it.length() } }) } - test fun maxByInPrimitiveArrays() { + @test fun maxByInPrimitiveArrays() { expect(null, { intArrayOf().maxBy { it } }) expect(1, { intArrayOf(1).maxBy { it } }) expect(2, { intArrayOf(2, 3).maxBy { -it } }) @@ -183,29 +183,29 @@ class ArraysTest { expect(3.0, { doubleArrayOf(2.0, 3.0).maxBy { Math.sqrt(it) } }) } - test fun minIndex() { + @test fun minIndex() { val a = intArrayOf(1, 7, 9, -42, 54, 93) expect(3, { a.indices.minBy { a[it] } }) } - test fun maxIndex() { + @test fun maxIndex() { val a = intArrayOf(1, 7, 9, 239, 54, 93) expect(3, { a.indices.maxBy { a[it] } }) } - test fun minByEvaluateOnce() { + @test fun minByEvaluateOnce() { var c = 0 expect(1, { arrayOf(5, 4, 3, 2, 1).minBy { c++; it * it } }) assertEquals(5, c) } - test fun maxByEvaluateOnce() { + @test fun maxByEvaluateOnce() { var c = 0 expect(5, { arrayOf(5, 4, 3, 2, 1).maxBy { c++; it * it } }) assertEquals(5, c) } - test fun sum() { + @test fun sum() { expect(0) { arrayOf().sum() } expect(14) { arrayOf(2, 3, 9).sum() } expect(3.0) { arrayOf(1.0, 2.0).sum() } @@ -215,7 +215,7 @@ class ArraysTest { expect(3.0F) { arrayOf(1.0F, 2.0F).sum() } } - test fun sumInPrimitiveArrays() { + @test fun sumInPrimitiveArrays() { expect(0) { intArrayOf().sum() } expect(14) { intArrayOf(2, 3, 9).sum() } expect(3.0) { doubleArrayOf(1.0, 2.0).sum() } @@ -225,7 +225,7 @@ class ArraysTest { expect(3.0F) { floatArrayOf(1.0F, 2.0F).sum() } } - test fun average() { + @test fun average() { expect(0.0) { arrayOf().average() } expect(3.8) { arrayOf(1, 2, 5, 8, 3).average() } expect(2.1) { arrayOf(1.6, 2.6, 3.6, 0.6).average() } @@ -236,7 +236,7 @@ class ArraysTest { // for each arr with size > 0 arr.average() = arr.sum().toDouble() / arr.size() } - test fun indexOfInPrimitiveArrays() { + @test fun indexOfInPrimitiveArrays() { expect(-1) { byteArrayOf(1, 2, 3) indexOf 0 } expect(0) { byteArrayOf(1, 2, 3) indexOf 1 } expect(1) { byteArrayOf(1, 2, 3) indexOf 2 } @@ -277,7 +277,7 @@ class ArraysTest { expect(-1) { booleanArrayOf(true) indexOf false } } - test fun indexOf() { + @test fun indexOf() { expect(-1) { arrayOf("cat", "dog", "bird").indexOf("mouse") } expect(0) { arrayOf("cat", "dog", "bird").indexOf("cat") } expect(1) { arrayOf("cat", "dog", "bird").indexOf("dog") } @@ -295,7 +295,7 @@ class ArraysTest { expect(2) { sequenceOf("cat", "dog", "bird").indexOfFirst { it.endsWith('d') } } } - test fun lastIndexOf() { + @test fun lastIndexOf() { expect(-1) { arrayOf("cat", "dog", "bird").lastIndexOf("mouse") } expect(0) { arrayOf("cat", "dog", "bird").lastIndexOf("cat") } expect(1) { arrayOf("cat", "dog", "bird").lastIndexOf("dog") } @@ -315,7 +315,7 @@ class ArraysTest { expect(3) { sequenceOf("cat", "dog", "bird", "red").indexOfLast { it.endsWith('d') } } } - test fun isEmpty() { + @test fun isEmpty() { assertTrue(emptyArray().isEmpty()) assertFalse(arrayOf("").isEmpty()) assertTrue(intArrayOf().isEmpty()) @@ -336,12 +336,12 @@ class ArraysTest { assertFalse(booleanArrayOf(false).isEmpty()) } - test fun isNotEmpty() { + @test fun isNotEmpty() { assertFalse(intArrayOf().isNotEmpty()) assertTrue(intArrayOf(1).isNotEmpty()) } - test fun plus() { + @test fun plus() { assertEquals(listOf("1", "2", "3", "4"), listOf("1", "2") + arrayOf("3", "4")) assertArrayNotSameButEquals(arrayOf("1", "2", "3"), arrayOf("1", "2") + "3") assertArrayNotSameButEquals(arrayOf("1", "2", "3", "4"), arrayOf("1", "2") + arrayOf("3", "4")) @@ -351,7 +351,7 @@ class ArraysTest { assertArrayNotSameButEquals(intArrayOf(1, 2, 3, 4), intArrayOf(1, 2) + intArrayOf(3, 4)) } - test fun plusVararg() { + @test fun plusVararg() { fun stringOnePlus(vararg a: String) = arrayOf("1") + a fun longOnePlus(vararg a: Long) = longArrayOf(1) + a fun intOnePlus(vararg a: Int) = intArrayOf(1) + a @@ -361,7 +361,7 @@ class ArraysTest { assertArrayNotSameButEquals(longArrayOf(1, 2), longOnePlus(2), "LongArray.plus") } - test fun plusAssign() { + @test fun plusAssign() { // lets use a mutable variable var result = arrayOf("a") result += "foo" @@ -370,23 +370,23 @@ class ArraysTest { assertArrayNotSameButEquals(arrayOf("a", "foo", "beer", "cheese", "wine"), result) } - test fun first() { + @test fun first() { expect(1) { arrayOf(1, 2, 3).first() } expect(2) { arrayOf(1, 2, 3).first { it % 2 == 0 } } } - test fun last() { + @test fun last() { expect(3) { arrayOf(1, 2, 3).last() } expect(2) { arrayOf(1, 2, 3).last { it % 2 == 0 } } } - test fun contains() { + @test fun contains() { assertTrue(arrayOf("1", "2", "3", "4").contains("2")) assertTrue("3" in arrayOf("1", "2", "3", "4")) assertTrue("0" !in arrayOf("1", "2", "3", "4")) } - test fun slice() { + @test fun slice() { val iter: Iterable = listOf(3, 1, 2) assertEquals(listOf("B"), arrayOf("A", "B", "C").slice(1..1)) @@ -403,7 +403,7 @@ class ArraysTest { assertEquals(listOf(true, false, true), booleanArrayOf(true, false, true, true).slice(iter)) } - test fun sliceArray() { + @test fun sliceArray() { val coll: Collection = listOf(3, 1, 2) assertArrayNotSameButEquals(arrayOf("B"), arrayOf("A", "B", "C").sliceArray(1..1)) @@ -420,7 +420,7 @@ class ArraysTest { assertArrayNotSameButEquals(booleanArrayOf(true, false, true), booleanArrayOf(true, false, true, true).sliceArray(coll)) } - test fun asIterable() { + @test fun asIterable() { val arr1 = intArrayOf(1, 2, 3, 4, 5) val iter1 = arr1.asIterable() assertEquals(arr1.toList(), iter1.toList()) @@ -442,7 +442,7 @@ class ArraysTest { assertEquals(iter4.toList(), emptyList()) } - test fun asList() { + @test fun asList() { assertEquals(listOf(1, 2, 3), intArrayOf(1, 2, 3).asList()) assertEquals(listOf(1, 2, 3), byteArrayOf(1, 2, 3).asList()) assertEquals(listOf(true, false), booleanArrayOf(true, false).asList()) @@ -457,7 +457,7 @@ class ArraysTest { assertEquals(10, intsAsList[1], "Should reflect changes in original array") } - test fun toPrimitiveArray() { + @test fun toPrimitiveArray() { val genericArray: Array = arrayOf(1, 2, 3) val primitiveArray: IntArray = genericArray.toIntArray() expect(3) { primitiveArray.size() } @@ -469,14 +469,14 @@ class ArraysTest { assertEquals(charList, charArray.asList()) } - test fun toTypedArray() { + @test fun toTypedArray() { val primitiveArray: LongArray = longArrayOf(1, 2, Long.MAX_VALUE) val genericArray: Array = primitiveArray.toTypedArray() expect(3) { genericArray.size() } assertEquals(primitiveArray.asList(), genericArray.asList()) } - test fun copyOf() { + @test fun copyOf() { booleanArrayOf(true, false, true).let { assertArrayNotSameButEquals(it, it.copyOf()) } byteArrayOf(0, 1, 2, 3, 4, 5).let { assertArrayNotSameButEquals(it, it.copyOf()) } shortArrayOf(0, 1, 2, 3, 4, 5).let { assertArrayNotSameButEquals(it, it.copyOf()) } @@ -487,7 +487,7 @@ class ArraysTest { charArrayOf('0', '1', '2', '3', '4', '5').let { assertArrayNotSameButEquals(it, it.copyOf()) } } - test fun copyAndResize() { + @test fun copyAndResize() { assertArrayNotSameButEquals(arrayOf("1", "2"), arrayOf("1", "2", "3").copyOf(2)) assertArrayNotSameButEquals(arrayOf("1", "2", null), arrayOf("1", "2").copyOf(3)) @@ -501,7 +501,7 @@ class ArraysTest { assertArrayNotSameButEquals(charArrayOf('A', 'B', '\u0000'), charArrayOf('A', 'B').copyOf(3)) } - test fun copyOfRange() { + @test fun copyOfRange() { assertArrayNotSameButEquals(booleanArrayOf(true, false, true), booleanArrayOf(true, false, true, true).copyOfRange(0, 3)) assertArrayNotSameButEquals(byteArrayOf(0, 1, 2), byteArrayOf(0, 1, 2, 3, 4, 5).copyOfRange(0, 3)) assertArrayNotSameButEquals(shortArrayOf(0, 1, 2), shortArrayOf(0, 1, 2, 3, 4, 5).copyOfRange(0, 3)) @@ -514,7 +514,7 @@ class ArraysTest { - test fun reduce() { + @test fun reduce() { expect(-4) { intArrayOf(1, 2, 3) reduce { a, b -> a - b } } expect(-4.toLong()) { longArrayOf(1, 2, 3) reduce { a, b -> a - b } } expect(-4F) { floatArrayOf(1F, 2F, 3F) reduce { a, b -> a - b } } @@ -530,7 +530,7 @@ class ArraysTest { } is UnsupportedOperationException) } - test fun reduceRight() { + @test fun reduceRight() { expect(2) { intArrayOf(1, 2, 3) reduceRight { a, b -> a - b } } expect(2.toLong()) { longArrayOf(1, 2, 3) reduceRight { a, b -> a - b } } expect(2F) { floatArrayOf(1F, 2F, 3F) reduceRight { a, b -> a - b } } @@ -546,7 +546,7 @@ class ArraysTest { } is UnsupportedOperationException) } - test fun reversed() { + @test fun reversed() { expect(listOf(3, 2, 1)) { intArrayOf(1, 2, 3).reversed() } expect(listOf(3, 2, 1)) { byteArrayOf(1, 2, 3).reversed() } expect(listOf(3, 2, 1)) { shortArrayOf(1, 2, 3).reversed() } @@ -557,7 +557,7 @@ class ArraysTest { expect(listOf(false, false, true)) { booleanArrayOf(true, false, false).reversed() } } - test fun reversedArray() { + @test fun reversedArray() { assertArrayNotSameButEquals(intArrayOf(3, 2, 1), intArrayOf(1, 2, 3).reversedArray()) assertArrayNotSameButEquals(byteArrayOf(3, 2, 1), byteArrayOf(1, 2, 3).reversedArray()) assertArrayNotSameButEquals(shortArrayOf(3, 2, 1), shortArrayOf(1, 2, 3).reversedArray()) @@ -568,7 +568,7 @@ class ArraysTest { assertArrayNotSameButEquals(booleanArrayOf(false, false, true), booleanArrayOf(true, false, false).reversedArray()) } - test fun drop() { + @test fun drop() { expect(listOf(1), { intArrayOf(1).drop(0) }) expect(listOf(), { intArrayOf().drop(1) }) expect(listOf(), { intArrayOf(1).drop(1) }) @@ -586,7 +586,7 @@ class ArraysTest { } } - test fun dropLast() { + @test fun dropLast() { expect(listOf(), { intArrayOf().dropLast(1) }) expect(listOf(), { intArrayOf(1).dropLast(1) }) expect(listOf(1), { intArrayOf(1).dropLast(0) }) @@ -604,7 +604,7 @@ class ArraysTest { } } - test fun dropWhile() { + @test fun dropWhile() { expect(listOf(), { intArrayOf().dropWhile { it < 3 } }) expect(listOf(), { intArrayOf(1).dropWhile { it < 3 } }) expect(listOf(3, 1), { intArrayOf(2, 3, 1).dropWhile { it < 3 } }) @@ -618,7 +618,7 @@ class ArraysTest { expect(listOf("b", "a"), { arrayOf("a", "b", "a").dropWhile { it < "b" } }) } - test fun dropLastWhile() { + @test fun dropLastWhile() { expect(listOf(), { intArrayOf().dropLastWhile { it < 3 } }) expect(listOf(), { intArrayOf(1).dropLastWhile { it < 3 } }) expect(listOf(2, 3), { intArrayOf(2, 3, 1).dropLastWhile { it < 3 } }) @@ -632,7 +632,7 @@ class ArraysTest { expect(listOf("a", "b"), { arrayOf("a", "b", "a").dropLastWhile { it < "b" } }) } - test fun take() { + @test fun take() { expect(listOf(), { intArrayOf().take(1) }) expect(listOf(), { intArrayOf(1).take(0) }) expect(listOf(1), { intArrayOf(1).take(1) }) @@ -650,7 +650,7 @@ class ArraysTest { } } - test fun takeLast() { + @test fun takeLast() { expect(listOf(), { intArrayOf().takeLast(1) }) expect(listOf(), { intArrayOf(1).takeLast(0) }) expect(listOf(1), { intArrayOf(1).takeLast(1) }) @@ -668,7 +668,7 @@ class ArraysTest { } } - test fun takeWhile() { + @test fun takeWhile() { expect(listOf(), { intArrayOf().takeWhile { it < 3 } }) expect(listOf(1), { intArrayOf(1).takeWhile { it < 3 } }) expect(listOf(2), { intArrayOf(2, 3, 1).takeWhile { it < 3 } }) @@ -682,7 +682,7 @@ class ArraysTest { expect(listOf("a"), { arrayOf("a", "c", "b").takeWhile { it < "c" } }) } - test fun takeLastWhile() { + @test fun takeLastWhile() { expect(listOf(), { intArrayOf().takeLastWhile { it < 3 } }) expect(listOf(1), { intArrayOf(1).takeLastWhile { it < 3 } }) expect(listOf(1), { intArrayOf(2, 3, 1).takeLastWhile { it < 3 } }) @@ -696,7 +696,7 @@ class ArraysTest { expect(listOf("b"), { arrayOf("a", "c", "b").takeLastWhile { it < "c" } }) } - test fun filter() { + @test fun filter() { expect(listOf(), { intArrayOf().filter { it > 2 } }) expect(listOf(), { intArrayOf(1).filter { it > 2 } }) expect(listOf(3), { intArrayOf(2, 3).filter { it > 2 } }) @@ -710,7 +710,7 @@ class ArraysTest { expect(listOf("b"), { arrayOf("a", "b").filter { it > "a" } }) } - test fun filterNot() { + @test fun filterNot() { expect(listOf(), { intArrayOf().filterNot { it > 2 } }) expect(listOf(1), { intArrayOf(1).filterNot { it > 2 } }) expect(listOf(2), { intArrayOf(2, 3).filterNot { it > 2 } }) @@ -724,11 +724,11 @@ class ArraysTest { expect(listOf("a"), { arrayOf("a", "b").filterNot { it > "a" } }) } - test fun filterNotNull() { + @test fun filterNotNull() { expect(listOf("a"), { arrayOf("a", null).filterNotNull() }) } - test fun asListPrimitives() { + @test fun asListPrimitives() { // Array of primitives val arr = intArrayOf(1, 2, 3, 4, 2, 5) val list = arr.asList() @@ -760,7 +760,7 @@ class ArraysTest { assertEquals(IntArray(0).asList(), emptyList()) } - test fun asListObjects() { + @test fun asListObjects() { val arr = arrayOf("a", "b", "c", "d", "b", "e") val list = arr.asList() @@ -793,7 +793,7 @@ class ArraysTest { assertEquals(Array(0, { "" }).asList(), emptyList()) } - test fun sort() { + @test fun sort() { val intArr = intArrayOf(5, 2, 1, 9, 80, Int.MIN_VALUE, Int.MAX_VALUE) intArr.sort() assertArrayNotSameButEquals(intArrayOf(Int.MIN_VALUE, 1, 2, 5, 9, 80, Int.MAX_VALUE), intArr) @@ -811,7 +811,7 @@ class ArraysTest { assertArrayNotSameButEquals(arrayOf("80", "9", "Foo", "all"), strArr) } - test fun sorted() { + @test fun sorted() { assertTrue(arrayOf().sorted().none()) assertEquals(listOf(1), arrayOf(1).sorted()) @@ -849,14 +849,14 @@ class ArraysTest { } } - test fun sortedBy() { + @test fun sortedBy() { val values = arrayOf("ac", "aD", "aba") val indices = values.indices.toList().toIntArray() assertEquals(listOf(1, 2, 0), indices.sortedBy { values[it] }) } - test fun sortedNullableBy() { + @test fun sortedNullableBy() { fun String.nullIfEmpty() = if (isEmpty()) null else this arrayOf(null, "").let { expect(listOf(null, "")) { it.sortedWith(nullsFirst(compareBy { it })) } @@ -865,7 +865,7 @@ class ArraysTest { } } - test fun sortedWith() { + @test fun sortedWith() { val comparator = compareBy { it: Int -> it % 3 }.thenByDescending { it } fun arrayData(array: A, comparator: Comparator) = ArraySortedChecker(array, comparator) diff --git a/libraries/stdlib/test/collections/CollectionJVMTest.kt b/libraries/stdlib/test/collections/CollectionJVMTest.kt index acd154b6a14..a88a902a8ca 100644 --- a/libraries/stdlib/test/collections/CollectionJVMTest.kt +++ b/libraries/stdlib/test/collections/CollectionJVMTest.kt @@ -20,7 +20,7 @@ class CollectionJVMTest { private data class IdentityData(public val value: Int) - test fun removeAllWithDifferentEquality() { + @test fun removeAllWithDifferentEquality() { val data = listOf(IdentityData(1), IdentityData(1)) val list = data.toArrayList() list -= identitySetOf(data[0]) as Iterable @@ -35,7 +35,7 @@ class CollectionJVMTest { assertTrue(set3.isEmpty(), "Array doesn't have contains, equality contains is used instead") } - test fun flatMap() { + @test fun flatMap() { val data = listOf("", "foo", "bar", "x", "") val characters = data.flatMap { it.toCharList() } println("Got list of characters ${characters}") @@ -45,7 +45,7 @@ class CollectionJVMTest { } - test fun filterIntoLinkedList() { + @test fun filterIntoLinkedList() { val data = listOf("foo", "bar") val foo = data.filterTo(linkedListOf()) { it.startsWith("f") } @@ -60,7 +60,7 @@ class CollectionJVMTest { } } - test fun filterNotIntoLinkedListOf() { + @test fun filterNotIntoLinkedListOf() { val data = listOf("foo", "bar") val foo = data.filterNotTo(linkedListOf()) { it.startsWith("f") } @@ -75,7 +75,7 @@ class CollectionJVMTest { } } - test fun filterNotNullIntoLinkedListOf() { + @test fun filterNotNullIntoLinkedListOf() { val data = listOf(null, "foo", null, "bar") val foo = data.filterNotNullTo(linkedListOf()) @@ -87,7 +87,7 @@ class CollectionJVMTest { } } - test fun filterIntoSortedSet() { + @test fun filterIntoSortedSet() { val data = listOf("foo", "bar") val sorted = data.filterTo(sortedSetOf()) { it.length() == 3 } assertEquals(2, sorted.size()) @@ -97,26 +97,26 @@ class CollectionJVMTest { } } - test fun first() { + @test fun first() { assertEquals(19, TreeSet(listOf(90, 47, 19)).first()) } - test fun last() { + @test fun last() { val data = listOf("foo", "bar") assertEquals("bar", data.last()) assertEquals(25, listOf(15, 19, 20, 25).last()) assertEquals('a', linkedListOf('a').last()) } - test fun lastException() { + @test fun lastException() { fails { linkedListOf().last() } } - test fun contains() { + @test fun contains() { assertTrue(linkedListOf(15, 19, 20).contains(15)) } - test fun toArray() { + @test fun toArray() { val data = listOf("foo", "bar") val arr = data.toTypedArray() println("Got array ${arr}") @@ -128,11 +128,11 @@ class CollectionJVMTest { } } - test fun takeReturnsFirstNElements() { + @test fun takeReturnsFirstNElements() { expect(setOf(1, 2)) { sortedSetOf(1, 2, 3, 4, 5).take(2).toSet() } } - test fun filterIsInstanceList() { + @test fun filterIsInstanceList() { val values: List = listOf(1, 2, 3.toDouble(), "abc", "cde") val intValues: List = values.filterIsInstance() @@ -151,7 +151,7 @@ class CollectionJVMTest { assertEquals(0, charValues.size()) } - test fun filterIsInstanceArray() { + @test fun filterIsInstanceArray() { val src: Array = arrayOf(1, 2, 3.toDouble(), "abc", "cde") val intValues: List = src.filterIsInstance() @@ -170,11 +170,11 @@ class CollectionJVMTest { assertEquals(0, charValues.size()) } - test fun emptyListIsSerializable() = testSingletonSerialization(emptyList()) + @test fun emptyListIsSerializable() = testSingletonSerialization(emptyList()) - test fun emptySetIsSerializable() = testSingletonSerialization(emptySet()) + @test fun emptySetIsSerializable() = testSingletonSerialization(emptySet()) - test fun emptyMapIsSerializable() = testSingletonSerialization(emptyMap()) + @test fun emptyMapIsSerializable() = testSingletonSerialization(emptyMap()) private fun testSingletonSerialization(value: Any) { val result = serializeAndDeserialize(value) diff --git a/libraries/stdlib/test/collections/CollectionTest.kt b/libraries/stdlib/test/collections/CollectionTest.kt index ceb73475438..c008aead52d 100644 --- a/libraries/stdlib/test/collections/CollectionTest.kt +++ b/libraries/stdlib/test/collections/CollectionTest.kt @@ -7,14 +7,14 @@ import test.collections.behaviors.* class CollectionTest { - test fun joinTo() { + @test fun joinTo() { val data = listOf("foo", "bar") val buffer = StringBuilder() data.joinTo(buffer, "-", "{", "}") assertEquals("{foo-bar}", buffer.toString()) } - test fun join() { + @test fun join() { val data = listOf("foo", "bar") val text = data.join("-", "<", ">") assertEquals("", text) @@ -24,7 +24,7 @@ class CollectionTest { assertEquals("a, b, c, *", text2) } - test fun filterNotNull() { + @test fun filterNotNull() { val data = listOf(null, "foo", null, "bar") val foo = data.filterNotNull() @@ -36,7 +36,7 @@ class CollectionTest { } } - test fun mapNotNull() { + @test fun mapNotNull() { val data = listOf(null, "foo", null, "bar") val foo = data.mapNotNull { it.length() } assertEquals(2, foo.size()) @@ -47,7 +47,7 @@ class CollectionTest { } } - test fun listOfNotNull() { + @test fun listOfNotNull() { val l1: List = listOfNotNull(null) assertTrue(l1.isEmpty()) @@ -59,7 +59,7 @@ class CollectionTest { assertEquals(listOf("value1", "value2"), l3) } - test fun filterIntoSet() { + @test fun filterIntoSet() { val data = listOf("foo", "bar") val foo = data.filterTo(hashSetOf()) { it.startsWith("f") } @@ -74,7 +74,7 @@ class CollectionTest { } } - test fun fold() { + @test fun fold() { // lets calculate the sum of some numbers expect(10) { val numbers = listOf(1, 2, 3, 4) @@ -93,7 +93,7 @@ class CollectionTest { } } - test fun foldWithDifferentTypes() { + @test fun foldWithDifferentTypes() { expect(7) { val numbers = listOf("a", "ab", "abc") numbers.fold(1) { a, b -> a + b.length() } @@ -105,49 +105,49 @@ class CollectionTest { } } - test fun foldWithNonCommutativeOperation() { + @test fun foldWithNonCommutativeOperation() { expect(1) { val numbers = listOf(1, 2, 3) numbers.fold(7) { a, b -> a - b } } } - test fun foldRight() { + @test fun foldRight() { expect("1234") { val numbers = listOf(1, 2, 3, 4) numbers.map { it.toString() }.foldRight("") { a, b -> a + b } } } - test fun foldRightWithDifferentTypes() { + @test fun foldRightWithDifferentTypes() { expect("1234") { val numbers = listOf(1, 2, 3, 4) numbers.foldRight("") { a, b -> "" + a + b } } } - test fun foldRightWithNonCommutativeOperation() { + @test fun foldRightWithNonCommutativeOperation() { expect(-5) { val numbers = listOf(1, 2, 3) numbers.foldRight(7) { a, b -> a - b } } } - test + @test fun merge() { expect(listOf("ab", "bc", "cd")) { listOf("a", "b", "c").merge(listOf("b", "c", "d")) { a, b -> a + b } } } - test + @test fun zip() { expect(listOf("a" to "b", "b" to "c", "c" to "d")) { listOf("a", "b", "c").zip(listOf("b", "c", "d")) } } - test fun partition() { + @test fun partition() { val data = listOf("foo", "bar", "something", "xyz") val pair = data.partition { it.length() == 3 } @@ -155,7 +155,7 @@ class CollectionTest { assertEquals(listOf("something"), pair.second, "pair.second") } - test fun reduce() { + @test fun reduce() { expect("1234") { val list = listOf("1", "2", "3", "4") list.reduce { a, b -> a + b } @@ -168,7 +168,7 @@ class CollectionTest { } } - test fun reduceRight() { + @test fun reduceRight() { expect("1234") { val list = listOf("1", "2", "3", "4") list.reduceRight { a, b -> a + b } @@ -181,7 +181,7 @@ class CollectionTest { } } - test fun groupBy() { + @test fun groupBy() { val words = listOf("a", "abc", "ab", "def", "abcd") val byLength = words.groupBy { it.length() } assertEquals(4, byLength.size()) @@ -197,14 +197,14 @@ class CollectionTest { assertEquals(2, l3.size()) } - test fun plusRanges() { + @test fun plusRanges() { val range1 = 1..3 val range2 = 4..7 val combined = range1 + range2 assertEquals((1..7).toList(), combined) } - test fun mapRanges() { + @test fun mapRanges() { val range = 1..3 map { it * 2 } assertEquals(listOf(2, 4, 6), range) } @@ -216,18 +216,18 @@ class CollectionTest { assertEquals(listOf("foo", "bar", "cheese", "wine"), list2) } - test fun plusElement() = testPlus { it + "cheese" + "wine" } - test fun plusCollection() = testPlus { it + listOf("cheese", "wine") } - test fun plusArray() = testPlus { it + arrayOf("cheese", "wine") } - test fun plusSequence() = testPlus { it + sequenceOf("cheese", "wine") } + @test fun plusElement() = testPlus { it + "cheese" + "wine" } + @test fun plusCollection() = testPlus { it + listOf("cheese", "wine") } + @test fun plusArray() = testPlus { it + arrayOf("cheese", "wine") } + @test fun plusSequence() = testPlus { it + sequenceOf("cheese", "wine") } - test fun plusCollectionBug() { + @test fun plusCollectionBug() { val list = listOf("foo", "bar") + listOf("cheese", "wine") assertEquals(listOf("foo", "bar", "cheese", "wine"), list) } - test fun plusAssign() { + @test fun plusAssign() { // lets use a mutable variable of readonly list var l: List = listOf("cheese") val lOriginal = l @@ -254,12 +254,12 @@ class CollectionTest { assertEquals(expected_, b.toList()) } - test fun minusElement() = testMinus(expected = listOf("foo", "bar")) { it - "bar" - "zoo" } - test fun minusCollection() = testMinus { it - listOf("bar", "zoo") } - test fun minusArray() = testMinus { it - arrayOf("bar", "zoo") } - test fun minusSequence() = testMinus { it - sequenceOf("bar", "zoo") } + @test fun minusElement() = testMinus(expected = listOf("foo", "bar")) { it - "bar" - "zoo" } + @test fun minusCollection() = testMinus { it - listOf("bar", "zoo") } + @test fun minusArray() = testMinus { it - arrayOf("bar", "zoo") } + @test fun minusSequence() = testMinus { it - sequenceOf("bar", "zoo") } - test fun minusIsEager() { + @test fun minusIsEager() { val source = listOf("foo", "bar") val list = arrayListOf() val result = source - list @@ -270,7 +270,7 @@ class CollectionTest { assertEquals(source, result) } - test fun minusAssign() { + @test fun minusAssign() { // lets use a mutable variable of readonly list val data: List = listOf("cheese", "foo", "beer", "cheese", "wine") var l = data @@ -293,7 +293,7 @@ class CollectionTest { - test fun requireNoNulls() { + @test fun requireNoNulls() { val data = arrayListOf("foo", "bar") val notNull = data.requireNoNulls() assertEquals(listOf("foo", "bar"), notNull) @@ -308,37 +308,37 @@ class CollectionTest { } } - test fun reverse() { + @test fun reverse() { val data = listOf("foo", "bar") val rev = data.reversed() assertEquals(listOf("bar", "foo"), rev) } - test fun reverseFunctionShouldReturnReversedCopyForList() { + @test fun reverseFunctionShouldReturnReversedCopyForList() { val list: List = listOf(2, 3, 1) expect(listOf(1, 3, 2)) { list.reversed() } expect(listOf(2, 3, 1)) { list } } - test fun reverseFunctionShouldReturnReversedCopyForIterable() { + @test fun reverseFunctionShouldReturnReversedCopyForIterable() { val iterable: Iterable = listOf(2, 3, 1) expect(listOf(1, 3, 2)) { iterable.reversed() } expect(listOf(2, 3, 1)) { iterable } } - test fun drop() { + @test fun drop() { val coll = listOf("foo", "bar", "abc") assertEquals(listOf("bar", "abc"), coll.drop(1)) assertEquals(listOf("abc"), coll.drop(2)) } - test fun dropWhile() { + @test fun dropWhile() { val coll = listOf("foo", "bar", "abc") assertEquals(listOf("bar", "abc"), coll.dropWhile { it.startsWith("f") }) } - test fun dropLast() { + @test fun dropLast() { val coll = listOf("foo", "bar", "abc") assertEquals(coll, coll.dropLast(0)) assertEquals(emptyList(), coll.dropLast(coll.size())) @@ -349,7 +349,7 @@ class CollectionTest { fails { coll.dropLast(-1) } } - test fun dropLastWhile() { + @test fun dropLastWhile() { val coll = listOf("Foo", "bare", "abc" ) assertEquals(coll, coll.dropLastWhile { false }) assertEquals(listOf(), coll.dropLastWhile { true }) @@ -357,7 +357,7 @@ class CollectionTest { assertEquals(listOf("Foo"), coll.dropLastWhile { it.all { it in 'a'..'z' } }) } - test fun take() { + @test fun take() { val coll = listOf("foo", "bar", "abc") assertEquals(emptyList(), coll.take(0)) assertEquals(listOf("foo"), coll.take(1)) @@ -368,7 +368,7 @@ class CollectionTest { fails { coll.take(-1) } } - test fun takeWhile() { + @test fun takeWhile() { val coll = listOf("foo", "bar", "abc") assertEquals(emptyList(), coll.takeWhile { false }) assertEquals(coll, coll.takeWhile { true }) @@ -376,7 +376,7 @@ class CollectionTest { assertEquals(listOf("foo", "bar", "abc"), coll.takeWhile { it.length() == 3 }) } - test fun takeLast() { + @test fun takeLast() { val coll = listOf("foo", "bar", "abc") assertEquals(emptyList(), coll.takeLast(0)) @@ -388,7 +388,7 @@ class CollectionTest { fails { coll.takeLast(-1) } } - test fun takeLastWhile() { + @test fun takeLastWhile() { val coll = listOf("foo", "bar", "abc") assertEquals(emptyList(), coll.takeLastWhile { false }) assertEquals(coll, coll.takeLastWhile { true }) @@ -396,7 +396,7 @@ class CollectionTest { assertEquals(listOf("bar", "abc"), coll.takeLastWhile { it[0] < 'c' }) } - test fun copyToArray() { + @test fun copyToArray() { val data = listOf("foo", "bar") val arr = data.toTypedArray() println("Got array ${arr}") @@ -408,14 +408,14 @@ class CollectionTest { } } - test fun count() { + @test fun count() { val data = listOf("foo", "bar") assertEquals(2, data.count()) assertEquals(3, hashSetOf(12, 14, 15).count()) assertEquals(0, ArrayList().count()) } - test fun first() { + @test fun first() { val data = listOf("foo", "bar") assertEquals("foo", data.first()) assertEquals(15, listOf(15, 19, 20, 25).first()) @@ -423,7 +423,7 @@ class CollectionTest { fails { arrayListOf().first() } } - test fun last() { + @test fun last() { val data = listOf("foo", "bar") assertEquals("bar", data.last()) assertEquals(25, listOf(15, 19, 20, 25).last()) @@ -431,7 +431,7 @@ class CollectionTest { fails { arrayListOf().last() } } - test fun subscript() { + @test fun subscript() { val list = arrayListOf("foo", "bar") assertEquals("foo", list[0]) assertEquals("bar", list[1]) @@ -454,7 +454,7 @@ class CollectionTest { assertEquals(listOf("new", "thing", "works"), list) } - test fun indices() { + @test fun indices() { val data = listOf("foo", "bar") val indices = data.indices assertEquals(0, indices.start) @@ -462,14 +462,14 @@ class CollectionTest { assertEquals(0..data.size() - 1, indices) } - test fun contains() { + @test fun contains() { assertFalse(hashSetOf().contains(12)) assertTrue(listOf(15, 19, 20).contains(15)) assertTrue(IterableWrapper(hashSetOf(45, 14, 13)).contains(14)) } - test fun min() { + @test fun min() { expect(null, { listOf().min() }) expect(1, { listOf(1).min() }) expect(2, { listOf(2, 3).min() }) @@ -480,7 +480,7 @@ class CollectionTest { expect(2, { listOf(2, 3).asSequence().min() }) } - test fun max() { + @test fun max() { expect(null, { listOf().max() }) expect(1, { listOf(1).max() }) expect(3, { listOf(2, 3).max() }) @@ -491,7 +491,7 @@ class CollectionTest { expect(3, { listOf(2, 3).asSequence().max() }) } - test fun minBy() { + @test fun minBy() { expect(null, { listOf().minBy { it } }) expect(1, { listOf(1).minBy { it } }) expect(3, { listOf(2, 3).minBy { -it } }) @@ -501,7 +501,7 @@ class CollectionTest { expect(3, { listOf(2, 3).asSequence().minBy { -it } }) } - test fun maxBy() { + @test fun maxBy() { expect(null, { listOf().maxBy { it } }) expect(1, { listOf(1).maxBy { it } }) expect(2, { listOf(2, 3).maxBy { -it } }) @@ -511,7 +511,7 @@ class CollectionTest { expect(2, { listOf(2, 3).asSequence().maxBy { -it } }) } - test fun minByEvaluateOnce() { + @test fun minByEvaluateOnce() { var c = 0 expect(1, { listOf(5, 4, 3, 2, 1).minBy { c++; it * it } }) assertEquals(5, c) @@ -520,7 +520,7 @@ class CollectionTest { assertEquals(5, c) } - test fun maxByEvaluateOnce() { + @test fun maxByEvaluateOnce() { var c = 0 expect(5, { listOf(5, 4, 3, 2, 1).maxBy { c++; it * it } }) assertEquals(5, c) @@ -529,7 +529,7 @@ class CollectionTest { assertEquals(5, c) } - test fun sum() { + @test fun sum() { expect(0) { arrayListOf().sum() } expect(14) { listOf(2, 3, 9).sum() } expect(3.0) { listOf(1.0, 2.0).sum() } @@ -538,7 +538,7 @@ class CollectionTest { expect(3.0.toFloat()) { sequenceOf(1.0.toFloat(), 2.0.toFloat()).sum() } } - test fun average() { + @test fun average() { expect(0.0) { arrayListOf().average() } expect(3.8) { listOf(1, 2, 5, 8, 3).average() } expect(2.1) { sequenceOf(1.6, 2.6, 3.6, 0.6).average() } @@ -548,7 +548,7 @@ class CollectionTest { expect(n.toDouble()/2) { range.average() } } - test fun takeReturnsFirstNElements() { + @test fun takeReturnsFirstNElements() { expect(listOf(1, 2, 3, 4, 5)) { (1..10) take 5 } expect(listOf(1, 2, 3, 4, 5)) { (1..10).toList().take(5) } expect(listOf(1, 2)) { (1..10) take 2 } @@ -559,18 +559,18 @@ class CollectionTest { expect(listOf(1)) { listOf(1) take 10 } } - test fun sorted() { + @test fun sorted() { assertEquals(listOf(1, 3, 7), listOf(3, 7, 1).sorted()) assertEquals(listOf(7, 3, 1), listOf(3, 7, 1).sortedDescending()) } - test fun sortedBy() { + @test fun sortedBy() { assertEquals(listOf("two" to 2, "three" to 3), listOf("three" to 3, "two" to 2).sortedBy { it.second }) assertEquals(listOf("three" to 3, "two" to 2), listOf("three" to 3, "two" to 2).sortedBy { it.first }) assertEquals(listOf("three", "two"), listOf("two", "three").sortedByDescending { it.length() }) } - test fun sortedNullableBy() { + @test fun sortedNullableBy() { fun String.nullIfEmpty() = if (isEmpty()) null else this listOf(null, "", "a").let { expect(listOf(null, "", "a")) { it.sortedWith(nullsFirst(compareBy { it })) } @@ -579,7 +579,7 @@ class CollectionTest { } } - test fun sortedByNullable() { + @test fun sortedByNullable() { fun String.nonEmptyLength() = if (isEmpty()) null else length() listOf("", "sort", "abc").let { assertEquals(listOf("", "abc", "sort"), it.sortedBy { it.nonEmptyLength() }) @@ -588,7 +588,7 @@ class CollectionTest { } } - test fun sortedWith() { + @test fun sortedWith() { val comparator = compareBy { it.toUpperCase().reversed() } val data = listOf("cat", "dad", "BAD") @@ -597,18 +597,18 @@ class CollectionTest { expect(listOf("BAD", "dad", "cat")) { data.sortedWith(comparator.reversed().reversed()) } } - test fun decomposeFirst() { + @test fun decomposeFirst() { val (first) = listOf(1, 2) assertEquals(first, 1) } - test fun decomposeSplit() { + @test fun decomposeSplit() { val (key, value) = "key = value".split("=").map { it.trim() } assertEquals(key, "key") assertEquals(value, "value") } - test fun decomposeList() { + @test fun decomposeList() { val (a, b, c, d, e) = listOf(1, 2, 3, 4, 5) assertEquals(a, 1) assertEquals(b, 2) @@ -617,7 +617,7 @@ class CollectionTest { assertEquals(e, 5) } - test fun decomposeArray() { + @test fun decomposeArray() { val (a, b, c, d, e) = arrayOf(1, 2, 3, 4, 5) assertEquals(a, 1) assertEquals(b, 2) @@ -626,7 +626,7 @@ class CollectionTest { assertEquals(e, 5) } - test fun decomposeIntArray() { + @test fun decomposeIntArray() { val (a, b, c, d, e) = intArrayOf(1, 2, 3, 4, 5) assertEquals(a, 1) assertEquals(b, 2) @@ -635,39 +635,39 @@ class CollectionTest { assertEquals(e, 5) } - test fun unzipList() { + @test fun unzipList() { val list = listOf(1 to 'a', 2 to 'b', 3 to 'c') val (ints, chars) = list.unzip() assertEquals(listOf(1, 2, 3), ints) assertEquals(listOf('a', 'b', 'c'), chars) } - test fun unzipArray() { + @test fun unzipArray() { val array = arrayOf(1 to 'a', 2 to 'b', 3 to 'c') val (ints, chars) = array.unzip() assertEquals(listOf(1, 2, 3), ints) assertEquals(listOf('a', 'b', 'c'), chars) } - test fun specialLists() { + @test fun specialLists() { compare(arrayListOf(), listOf()) { listBehavior() } compare(arrayListOf(), emptyList()) { listBehavior() } compare(arrayListOf("value"), listOf("value")) { listBehavior() } } - test fun specialSets() { + @test fun specialSets() { compare(linkedSetOf(), setOf()) { setBehavior() } compare(hashSetOf(), emptySet()) { setBehavior() } compare(listOf("value").toMutableSet(), setOf("value")) { setBehavior() } } - test fun specialMaps() { + @test fun specialMaps() { compare(hashMapOf(), mapOf()) { mapBehavior() } compare(linkedMapOf(), emptyMap()) { mapBehavior() } compare(linkedMapOf(2 to 3), mapOf(2 to 3)) { mapBehavior() } } - test fun toStringTest() { + @test fun toStringTest() { // we need toString() inside pattern because of KT-8666 assertEquals("[1, a, null, ${Long.MAX_VALUE.toString()}]", listOf(1, "a", null, Long.MAX_VALUE).toString()) } diff --git a/libraries/stdlib/test/collections/IterableTests.kt b/libraries/stdlib/test/collections/IterableTests.kt index c346b4e4ede..c0bb24d4b58 100644 --- a/libraries/stdlib/test/collections/IterableTests.kt +++ b/libraries/stdlib/test/collections/IterableTests.kt @@ -22,33 +22,38 @@ class ListTest : OrderedIterableTests>(listOf("foo", "bar"), listOf class ArrayListTest : OrderedIterableTests>(arrayListOf("foo", "bar"), arrayListOf()) abstract class OrderedIterableTests>(data: T, empty: T) : IterableTests(data, empty) { - Test fun indexOf() { + @Test + fun indexOf() { expect(0) { data.indexOf("foo") } expect(-1) { empty.indexOf("foo") } expect(1) { data.indexOf("bar") } expect(-1) { data.indexOf("zap") } } - Test fun lastIndexOf() { + @Test + fun lastIndexOf() { expect(0) { data.lastIndexOf("foo") } expect(-1) { empty.lastIndexOf("foo") } expect(1) { data.lastIndexOf("bar") } expect(-1) { data.lastIndexOf("zap") } } - Test fun indexOfFirst() { + @Test + fun indexOfFirst() { expect(-1) { data.indexOfFirst { it.contains("p") } } expect(0) { data.indexOfFirst { it.startsWith('f') } } expect(-1) { empty.indexOfFirst { it.startsWith('f') } } } - Test fun indexOfLast() { + @Test + fun indexOfLast() { expect(-1) { data.indexOfLast { it.contains("p") } } expect(1) { data.indexOfLast { it.length() == 3 } } expect(-1) { empty.indexOfLast { it.startsWith('f') } } } - Test fun elementAt() { + @Test + fun elementAt() { expect("foo") { data.elementAt(0) } expect("bar") { data.elementAt(1) } fails { data.elementAt(2) } @@ -64,7 +69,8 @@ abstract class OrderedIterableTests>(data: T, empty: T) : I } - Test fun first() { + @Test + fun first() { expect("foo") { data.first() } fails { data.first { it.startsWith("x") } @@ -75,7 +81,8 @@ abstract class OrderedIterableTests>(data: T, empty: T) : I expect("foo") { data.first { it.startsWith("f") } } } - Test fun firstOrNull() { + @Test + fun firstOrNull() { expect(null) { data.firstOrNull { it.startsWith("x") } } expect(null) { empty.firstOrNull() } @@ -83,7 +90,8 @@ abstract class OrderedIterableTests>(data: T, empty: T) : I assertEquals("foo", f) } - Test fun last() { + @Test + fun last() { assertEquals("bar", data.last()) fails { data.last { it.startsWith("x") } @@ -94,7 +102,8 @@ abstract class OrderedIterableTests>(data: T, empty: T) : I expect("foo") { data.last { it.startsWith("f") } } } - Test fun lastOrNull() { + @Test + fun lastOrNull() { expect(null) { data.lastOrNull { it.startsWith("x") } } expect(null) { empty.lastOrNull() } expect("foo") { data.lastOrNull { it.startsWith("f") } } @@ -102,7 +111,8 @@ abstract class OrderedIterableTests>(data: T, empty: T) : I } abstract class IterableTests>(val data: T, val empty: T) { - Test fun any() { + @Test + fun any() { expect(true) { data.any() } expect(false) { empty.any() } expect(true) { data.any { it.startsWith("f") } } @@ -110,13 +120,15 @@ abstract class IterableTests>(val data: T, val empty: T) { expect(false) { empty.any { it.startsWith("x") } } } - Test fun all() { + @Test + fun all() { expect(true) { data.all { it.length() == 3 } } expect(false) { data.all { it.startsWith("b") } } expect(true) { empty.all { it.startsWith("b") } } } - Test fun none() { + @Test + fun none() { expect(false) { data.none() } expect(true) { empty.none() } expect(false) { data.none { it.length() == 3 } } @@ -125,7 +137,8 @@ abstract class IterableTests>(val data: T, val empty: T) { expect(true) { empty.none { it.startsWith("b") } } } - Test fun filter() { + @Test + fun filter() { val foo = data.filter { it.startsWith("f") } expect(true) { foo is List } expect(true) { foo.all { it.startsWith("f") } } @@ -133,7 +146,8 @@ abstract class IterableTests>(val data: T, val empty: T) { assertEquals(listOf("foo"), foo) } - Test fun drop() { + @Test + fun drop() { val foo = data.drop(1) expect(true) { foo is List } expect(true) { foo.all { it.startsWith("b") } } @@ -141,7 +155,8 @@ abstract class IterableTests>(val data: T, val empty: T) { assertEquals(listOf("bar"), foo) } - Test fun dropWhile() { + @Test + fun dropWhile() { val foo = data.dropWhile { it[0] == 'f' } expect(true) { foo is List } expect(true) { foo.all { it.startsWith("b") } } @@ -149,7 +164,8 @@ abstract class IterableTests>(val data: T, val empty: T) { assertEquals(listOf("bar"), foo) } - Test fun filterNot() { + @Test + fun filterNot() { val notFoo = data.filterNot { it.startsWith("f") } expect(true) { notFoo is List } expect(true) { notFoo.none { it.startsWith("f") } } @@ -157,20 +173,23 @@ abstract class IterableTests>(val data: T, val empty: T) { assertEquals(listOf("bar"), notFoo) } - Test fun forEach() { + @Test + fun forEach() { var count = 0 data.forEach { count += it.length() } assertEquals(6, count) } - Test fun contains() { + @Test + fun contains() { assertTrue(data.contains("foo")) assertTrue("bar" in data) assertTrue("baz" !in data) assertFalse("baz" in empty) } - Test fun single() { + @Test + fun single() { fails { data.single() } fails { empty.single() } expect("foo") { data.single { it.startsWith("f") } } @@ -180,7 +199,7 @@ abstract class IterableTests>(val data: T, val empty: T) { } } - Test + @Test fun singleOrNull() { expect(null) { data.singleOrNull() } expect(null) { empty.singleOrNull() } @@ -191,7 +210,7 @@ abstract class IterableTests>(val data: T, val empty: T) { } } - Test + @Test fun map() { val lengths = data.map { it.length() } assertTrue { @@ -201,38 +220,38 @@ abstract class IterableTests>(val data: T, val empty: T) { assertEquals(listOf(3, 3), lengths) } - Test + @Test fun flatten() { assertEquals(listOf(0, 1, 2, 3, 0, 1, 2, 3), data.map { 0..it.length() }.flatten()) } - Test + @Test fun mapIndexed() { val shortened = data.mapIndexed { index, value -> value.substring(0..index) } assertEquals(2, shortened.size()) assertEquals(listOf("f", "ba"), shortened) } - Test + @Test fun withIndex() { val indexed = data.withIndex().map { it.value.substring(0..it.index) } assertEquals(2, indexed.size()) assertEquals(listOf("f", "ba"), indexed) } - Test + @Test fun max() { expect("foo") { data.max() } expect("bar") { data.maxBy { it.last() } } } - Test + @Test fun min() { expect("bar") { data.min() } expect("foo") { data.minBy { it.last() } } } - Test + @Test fun count() { expect(2) { data.count() } expect(0) { empty.count() } @@ -244,7 +263,7 @@ abstract class IterableTests>(val data: T, val empty: T) { expect(0) { empty.count { it.startsWith("x") } } } - Test + @Test fun sumBy() { expect(6) { data.sumBy { it.length() } } expect(0) { empty.sumBy { it.length() } } @@ -253,7 +272,7 @@ abstract class IterableTests>(val data: T, val empty: T) { expect(0.0) { empty.sumByDouble { it.length().toDouble() / 2 } } } - Test + @Test fun withIndices() { var index = 0 for ((i, d) in data.withIndex()) { @@ -264,19 +283,19 @@ abstract class IterableTests>(val data: T, val empty: T) { assertEquals(data.count(), index) } - Test + @Test fun fold() { expect(231) { data.fold(1, { a, b -> a + if (b == "foo") 200 else 30 }) } } - Test + @Test fun reduce() { val reduced = data.reduce { a, b -> a + b } assertEquals(6, reduced.length()) assertTrue(reduced == "foobar" || reduced == "barfoo") } - Test + @Test fun mapAndJoinToString() { val result = data.joinToString(separator = "-") { it.toUpperCase() } assertEquals("FOO-BAR", result) @@ -288,16 +307,16 @@ abstract class IterableTests>(val data: T, val empty: T) { assertFalse(result === data) } - Test + @Test fun plusElement() = testPlus { it + "zoo" + "g" } - Test + @Test fun plusCollection() = testPlus { it + listOf("zoo", "g") } - Test + @Test fun plusArray() = testPlus { it + arrayOf("zoo", "g") } - Test + @Test fun plusSequence() = testPlus { it + sequenceOf("zoo", "g") } - Test + @Test fun plusAssign() { // lets use a mutable variable var result: Iterable = data @@ -308,31 +327,31 @@ abstract class IterableTests>(val data: T, val empty: T) { assertEquals(listOf("foo", "bar", "foo", "beer", "cheese", "wine", "zoo", "g"), result) } - Test + @Test fun minusElement() { val result = data - "foo" - "g" assertEquals(listOf("bar"), result) } - Test + @Test fun minusCollection() { val result = data - listOf("foo", "g") assertEquals(listOf("bar"), result) } - Test + @Test fun minusArray() { val result = data - arrayOf("foo", "g") assertEquals(listOf("bar"), result) } - Test + @Test fun minusSequence() { val result = data - sequenceOf("foo", "g") assertEquals(listOf("bar"), result) } - Test + @Test fun minusAssign() { // lets use a mutable variable var result: Iterable = data diff --git a/libraries/stdlib/test/collections/IteratorsJVMTest.kt b/libraries/stdlib/test/collections/IteratorsJVMTest.kt index 07e8a72427d..65f39f15703 100644 --- a/libraries/stdlib/test/collections/IteratorsJVMTest.kt +++ b/libraries/stdlib/test/collections/IteratorsJVMTest.kt @@ -6,7 +6,7 @@ import java.util.* class IteratorsJVMTest { - test fun testEnumeration() { + @test fun testEnumeration() { val v = Vector() for (i in 1..5) v.add(i) diff --git a/libraries/stdlib/test/collections/IteratorsTest.kt b/libraries/stdlib/test/collections/IteratorsTest.kt index 199e61c5667..ffe52457149 100644 --- a/libraries/stdlib/test/collections/IteratorsTest.kt +++ b/libraries/stdlib/test/collections/IteratorsTest.kt @@ -4,7 +4,7 @@ import kotlin.test.* import org.junit.Test as test class IteratorsTest { - test fun iterationOverIterator() { + @test fun iterationOverIterator() { val c = listOf(0, 1, 2, 3, 4, 5) var s = "" for (i in c.iterator()) { diff --git a/libraries/stdlib/test/collections/ListBinarySearchTest.kt b/libraries/stdlib/test/collections/ListBinarySearchTest.kt index 6deff32fd74..6b73bc937e7 100644 --- a/libraries/stdlib/test/collections/ListBinarySearchTest.kt +++ b/libraries/stdlib/test/collections/ListBinarySearchTest.kt @@ -11,7 +11,8 @@ class ListBinarySearchTest { val comparator = compareBy?> { it?.value } - Test fun binarySearchByElement() { + @Test + fun binarySearchByElement() { val list = values list.forEachIndexed { index, item -> assertEquals(index, list.binarySearch(item)) @@ -25,7 +26,8 @@ class ListBinarySearchTest { } } - Test fun binarySearchByElementNullable() { + @Test + fun binarySearchByElementNullable() { val list = listOf(null) + values list.forEachIndexed { index, item -> assertEquals(index, list.binarySearch(item)) @@ -37,7 +39,8 @@ class ListBinarySearchTest { } } - Test fun binarySearchWithComparator() { + @Test + fun binarySearchWithComparator() { val list = values map { IncomparableDataItem(it) } list.forEachIndexed { index, item -> @@ -52,7 +55,8 @@ class ListBinarySearchTest { } } - Test fun binarySearchByKey() { + @Test + fun binarySearchByKey() { val list = values map { IncomparableDataItem(it) } list.forEachIndexed { index, item -> @@ -68,7 +72,8 @@ class ListBinarySearchTest { } - Test fun binarySearchByKeyWithComparator() { + @Test + fun binarySearchByKeyWithComparator() { val list = values map { IncomparableDataItem(IncomparableDataItem(it)) } list.forEachIndexed { index, item -> @@ -87,7 +92,8 @@ class ListBinarySearchTest { } } - Test fun binarySearchByMultipleKeys() { + @Test + fun binarySearchByMultipleKeys() { val list = values.flatMap { v1 -> values.map { v2 -> Pair(v1, v2) } } list.forEachIndexed { index, item -> diff --git a/libraries/stdlib/test/collections/ListSpecificTest.kt b/libraries/stdlib/test/collections/ListSpecificTest.kt index 7d2aa49ab43..16d390d0344 100644 --- a/libraries/stdlib/test/collections/ListSpecificTest.kt +++ b/libraries/stdlib/test/collections/ListSpecificTest.kt @@ -7,17 +7,20 @@ class ListSpecificTest { val data = listOf("foo", "bar") val empty = listOf() - Test fun _toString() { + @Test + fun _toString() { assertEquals("[foo, bar]", data.toString()) } - Test fun tail() { + @Test + fun tail() { val data = listOf("foo", "bar", "whatnot") val actual = data.drop(1) assertEquals(listOf("bar", "whatnot"), actual) } - Test fun slice() { + @Test + fun slice() { val list = listOf('A', 'B', 'C', 'D') // ABCD // 0123 @@ -28,7 +31,8 @@ class ListSpecificTest { assertEquals(listOf('C', 'A', 'D'), list.slice(iter)) } - Test fun getOr() { + @Test + fun getOr() { expect("foo") { data.get(0) } expect("bar") { data.get(1) } fails { data.get(2) } @@ -44,12 +48,14 @@ class ListSpecificTest { } - Test fun lastIndex() { + @Test + fun lastIndex() { assertEquals(-1, empty.lastIndex) assertEquals(1, data.lastIndex) } - Test fun mutableList() { + @Test + fun mutableList() { val items = listOf("beverage", "location", "name") var list = listOf() @@ -61,7 +67,8 @@ class ListSpecificTest { assertEquals("beverage,location,name", list.join(",")) } - Test fun testNullToString() { + @Test + fun testNullToString() { assertEquals("[null]", listOf(null).toString()) } } diff --git a/libraries/stdlib/test/collections/MapJVMTest.kt b/libraries/stdlib/test/collections/MapJVMTest.kt index eef2cd9626b..f6908d42daa 100644 --- a/libraries/stdlib/test/collections/MapJVMTest.kt +++ b/libraries/stdlib/test/collections/MapJVMTest.kt @@ -6,7 +6,7 @@ import kotlin.test.* import org.junit.Test as test class MapJVMTest { - test fun createSortedMap() { + @test fun createSortedMap() { val map = sortedMapOf(Pair("c", 3), Pair("b", 2), Pair("a", 1)) assertEquals(1, map["a"]) assertEquals(2, map["b"]) @@ -14,7 +14,7 @@ class MapJVMTest { assertEquals(listOf("a", "b", "c"), map.keySet().toList()) } - test fun toSortedMap() { + @test fun toSortedMap() { val map = mapOf(Pair("c", 3), Pair("b", 2), Pair("a", 1)) val sorted = map.toSortedMap() assertEquals(1, sorted["a"]) @@ -23,7 +23,7 @@ class MapJVMTest { assertEquals(listOf("a", "b", "c"), sorted.keySet().toList()) } - test fun toSortedMapWithComparator() { + @test fun toSortedMapWithComparator() { val map = mapOf(Pair("c", 3), Pair("bc", 2), Pair("bd", 4), Pair("abc", 1)) val sorted = map.toSortedMap(compareBy { it.length() } thenBy { it }) assertEquals(listOf("c", "bc", "bd", "abc"), sorted.keySet().toList()) @@ -32,7 +32,7 @@ class MapJVMTest { assertEquals(3, sorted["c"]) } - test fun toProperties() { + @test fun toProperties() { val map = mapOf("a" to "A", "b" to "B") val prop = map.toProperties() assertEquals(2, prop.size()) @@ -40,7 +40,7 @@ class MapJVMTest { assertEquals("B", prop.getProperty("b", "fail")) } - test fun getOrPutFailsOnConcurrentMap() { + @test fun getOrPutFailsOnConcurrentMap() { val map = ConcurrentHashMap() fails { diff --git a/libraries/stdlib/test/collections/MapTest.kt b/libraries/stdlib/test/collections/MapTest.kt index 6eeec4ed7e4..492162f42f1 100644 --- a/libraries/stdlib/test/collections/MapTest.kt +++ b/libraries/stdlib/test/collections/MapTest.kt @@ -9,7 +9,7 @@ import org.junit.Test as test class MapTest { - test fun getOrElse() { + @test fun getOrElse() { val data = mapOf() val a = data.getOrElse("foo") { 2 } assertEquals(2, a) @@ -23,7 +23,7 @@ class MapTest { assertEquals(null, c) } - test fun getOrImplicitDefault() { + @test fun getOrImplicitDefault() { val data: MutableMap = hashMapOf("bar" to 1) assertTrue(fails { data.getOrImplicitDefault("foo") } is NoSuchElementException) assertEquals(1, data.getOrImplicitDefault("bar")) @@ -44,7 +44,7 @@ class MapTest { assertEquals(42, withReplacedDefault.getOrImplicitDefault("loop")) } - test fun getOrPut() { + @test fun getOrPut() { val data = hashMapOf() val a = data.getOrPut("foo") { 2 } assertEquals(2, a) @@ -59,13 +59,13 @@ class MapTest { assertEquals(null, c) } - test fun sizeAndEmpty() { + @test fun sizeAndEmpty() { val data = hashMapOf() assertTrue { data.none() } assertEquals(data.size(), 0) } - test fun setViaIndexOperators() { + @test fun setViaIndexOperators() { val map = hashMapOf() assertTrue { map.none() } assertEquals(map.size(), 0) @@ -77,7 +77,7 @@ class MapTest { assertEquals("James", map["name"]) } - test fun iterate() { + @test fun iterate() { val map = mapOf("beverage" to "beer", "location" to "Mells", "name" to "James") val list = arrayListOf() for (e in map) { @@ -89,13 +89,13 @@ class MapTest { assertEquals("beverage,beer,location,Mells,name,James", list.join(",")) } - test fun stream() { + @test fun stream() { val map = mapOf("beverage" to "beer", "location" to "Mells", "name" to "James") val named = map.asSequence().filter { it.key == "name" }.single() assertEquals("James", named.value) } - test fun iterateWithProperties() { + @test fun iterateWithProperties() { val map = mapOf("beverage" to "beer", "location" to "Mells", "name" to "James") val list = arrayListOf() for (e in map) { @@ -107,7 +107,7 @@ class MapTest { assertEquals("beverage,beer,location,Mells,name,James", list.join(",")) } - test fun iterateWithExtraction() { + @test fun iterateWithExtraction() { val map = mapOf("beverage" to "beer", "location" to "Mells", "name" to "James") val list = arrayListOf() for ((key, value) in map) { @@ -119,20 +119,20 @@ class MapTest { assertEquals("beverage,beer,location,Mells,name,James", list.join(",")) } - test fun contains() { + @test fun contains() { val map = mapOf("a" to 1, "b" to 2) assertTrue("a" in map) assertTrue("c" !in map) } - test fun map() { + @test fun map() { val m1 = mapOf("beverage" to "beer", "location" to "Mells") val list = m1.map { it.value + " rocks" } assertEquals(listOf("beer rocks", "Mells rocks"), list) } - test fun mapValues() { + @test fun mapValues() { val m1 = mapOf("beverage" to "beer", "location" to "Mells") val m2 = m1.mapValues { it.value + "2" } @@ -140,7 +140,7 @@ class MapTest { assertEquals("Mells2", m2["location"]) } - test fun mapKeys() { + @test fun mapKeys() { val m1 = mapOf("beverage" to "beer", "location" to "Mells") val m2 = m1.mapKeys { it.key + "2" } @@ -148,21 +148,21 @@ class MapTest { assertEquals("Mells", m2["location2"]) } - test fun createUsingPairs() { + @test fun createUsingPairs() { val map = mapOf(Pair("a", 1), Pair("b", 2)) assertEquals(2, map.size()) assertEquals(1, map["a"]) assertEquals(2, map["b"]) } - test fun createFromIterable() { + @test fun createFromIterable() { val map = listOf(Pair("a", 1), Pair("b", 2)).toMap() assertEquals(2, map.size()) assertEquals(1, map.get("a")) assertEquals(2, map.get("b")) } - test fun createWithSelector() { + @test fun createWithSelector() { val map = listOf("a", "bb", "ccc").toMap { it.length() } assertEquals(3, map.size()) assertEquals("a", map.get(1)) @@ -170,14 +170,14 @@ class MapTest { assertEquals("ccc", map.get(3)) } - test fun createWithSelectorAndOverwrite() { + @test fun createWithSelectorAndOverwrite() { val map = listOf("aa", "bb", "ccc").toMap { it.length() } assertEquals(2, map.size()) assertEquals("bb", map.get(2)) assertEquals("ccc", map.get(3)) } - test fun createWithSelectorForKeyAndValue() { + @test fun createWithSelectorForKeyAndValue() { val map = listOf("a", "bb", "ccc").toMap({ it.length() }, { it.toUpperCase() }) assertEquals(3, map.size()) assertEquals("A", map.get(1)) @@ -185,14 +185,14 @@ class MapTest { assertEquals("CCC", map.get(3)) } - test fun createUsingTo() { + @test fun createUsingTo() { val map = mapOf("a" to 1, "b" to 2) assertEquals(2, map.size()) assertEquals(1, map["a"]) assertEquals(2, map["b"]) } - test fun createLinkedMap() { + @test fun createLinkedMap() { val map = linkedMapOf(Pair("c", 3), Pair("b", 2), Pair("a", 1)) assertEquals(1, map["a"]) assertEquals(2, map["b"]) @@ -200,7 +200,7 @@ class MapTest { assertEquals(listOf("c", "b", "a"), map.keySet().toList()) } - test fun filter() { + @test fun filter() { val map = mapOf(Pair("b", 3), Pair("c", 2), Pair("a", 2)) val filteredByKey = map.filter { it.key == "b" } assertEquals(1, filteredByKey.size()) @@ -223,7 +223,7 @@ class MapTest { assertEquals(2, filteredByValue2["a"]) } - test fun any() { + @test fun any() { val map = mapOf(Pair("b", 3), Pair("c", 2), Pair("a", 2)) assertTrue(map.any()) assertFalse(emptyMap().any()) @@ -235,7 +235,7 @@ class MapTest { assertFalse(map.any { it.value == 5 }) } - test fun all() { + @test fun all() { val map = mapOf(Pair("b", 3), Pair("c", 2), Pair("a", 2)) assertTrue(map.all { it.key != "d" }) assertTrue(emptyMap().all { it.key == "d" }) @@ -244,7 +244,7 @@ class MapTest { assertFalse(map.all { it.value == 2 }) } - test fun countBy() { + @test fun countBy() { val map = mapOf(Pair("b", 3), Pair("c", 2), Pair("a", 2)) assertEquals(3, map.count()) @@ -255,7 +255,7 @@ class MapTest { assertEquals(2, filteredByValue) } - test fun filterNot() { + @test fun filterNot() { val map = mapOf(Pair("b", 3), Pair("c", 2), Pair("a", 2)) val filteredByKey = map.filterNot { it.key == "b" } assertEquals(2, filteredByKey.size()) @@ -277,18 +277,18 @@ class MapTest { assertEquals(3, map["c"]) } - test fun plusAssign() = testPlusAssign { + @test fun plusAssign() = testPlusAssign { it += "b" to 4 it += "c" to 3 } - test fun plusAssignList() = testPlusAssign { it += listOf("c" to 3, "b" to 4) } + @test fun plusAssignList() = testPlusAssign { it += listOf("c" to 3, "b" to 4) } - test fun plusAssignArray() = testPlusAssign { it += arrayOf("c" to 3, "b" to 4) } + @test fun plusAssignArray() = testPlusAssign { it += arrayOf("c" to 3, "b" to 4) } - test fun plusAssignSequence() = testPlusAssign { it += sequenceOf("c" to 3, "b" to 4) } + @test fun plusAssignSequence() = testPlusAssign { it += sequenceOf("c" to 3, "b" to 4) } - test fun plusAssignMap() = testPlusAssign { it += mapOf("c" to 3, "b" to 4) } + @test fun plusAssignMap() = testPlusAssign { it += mapOf("c" to 3, "b" to 4) } fun testPlus(doPlus: (Map) -> Map) { val original = mapOf("A" to 1, "B" to 2) @@ -299,15 +299,15 @@ class MapTest { assertEquals(3, extended["C"]) } - test fun plus() = testPlus { it + ("C" to 3) + ("B" to 4) } + @test fun plus() = testPlus { it + ("C" to 3) + ("B" to 4) } - test fun plusList() = testPlus { it + listOf("C" to 3, "B" to 4) } + @test fun plusList() = testPlus { it + listOf("C" to 3, "B" to 4) } - test fun plusArray() = testPlus { it + arrayOf("C" to 3, "B" to 4) } + @test fun plusArray() = testPlus { it + arrayOf("C" to 3, "B" to 4) } - test fun plusSequence() = testPlus { it + sequenceOf("C" to 3, "B" to 4) } + @test fun plusSequence() = testPlus { it + sequenceOf("C" to 3, "B" to 4) } - test fun plusMap() = testPlus { it + mapOf("C" to 3, "B" to 4) } + @test fun plusMap() = testPlus { it + mapOf("C" to 3, "B" to 4) } fun testMinus(doMinus: (Map) -> Map) { @@ -316,15 +316,15 @@ class MapTest { assertEquals("A" to 1, shortened.entrySet().single().toPair()) } - test fun minus() = testMinus { it - "B" - "C" } + @test fun minus() = testMinus { it - "B" - "C" } - test fun minusList() = testMinus { it - listOf("B", "C") } + @test fun minusList() = testMinus { it - listOf("B", "C") } - test fun minusArray() = testMinus { it - arrayOf("B", "C") } + @test fun minusArray() = testMinus { it - arrayOf("B", "C") } - test fun minusSequence() = testMinus { it - sequenceOf("B", "C") } + @test fun minusSequence() = testMinus { it - sequenceOf("B", "C") } - test fun minusSet() = testMinus { it - setOf("B", "C") } + @test fun minusSet() = testMinus { it - setOf("B", "C") } @@ -334,16 +334,16 @@ class MapTest { assertEquals("A" to 1, original.entrySet().single().toPair()) } - test fun minusAssign() = testMinusAssign { + @test fun minusAssign() = testMinusAssign { it -= "B" it -= "C" } - test fun minusAssignList() = testMinusAssign { it -= listOf("B", "C") } + @test fun minusAssignList() = testMinusAssign { it -= listOf("B", "C") } - test fun minusAssignArray() = testMinusAssign { it -= arrayOf("B", "C") } + @test fun minusAssignArray() = testMinusAssign { it -= arrayOf("B", "C") } - test fun minusAssignSequence() = testMinusAssign { it -= sequenceOf("B", "C") } + @test fun minusAssignSequence() = testMinusAssign { it -= sequenceOf("B", "C") } fun testIdempotent(operation: (Map) -> Map) { @@ -359,17 +359,17 @@ class MapTest { } - test fun plusEmptyList() = testIdempotent { it + listOf() } - test fun minusEmptyList() = testIdempotent { it - listOf() } + @test fun plusEmptyList() = testIdempotent { it + listOf() } + @test fun minusEmptyList() = testIdempotent { it - listOf() } - test fun plusEmptySet() = testIdempotent { it + setOf() } - test fun minusEmptySet() = testIdempotent { it - setOf() } + @test fun plusEmptySet() = testIdempotent { it + setOf() } + @test fun minusEmptySet() = testIdempotent { it - setOf() } - test fun plusAssignEmptyList() = testIdempotentAssign { it += listOf() } - test fun minusAssignEmptyList() = testIdempotentAssign { it -= listOf() } + @test fun plusAssignEmptyList() = testIdempotentAssign { it += listOf() } + @test fun minusAssignEmptyList() = testIdempotentAssign { it -= listOf() } - test fun plusAssignEmptySet() = testIdempotentAssign { it += setOf() } - test fun minusAssignEmptySet() = testIdempotentAssign { it -= setOf() } + @test fun plusAssignEmptySet() = testIdempotentAssign { it += setOf() } + @test fun minusAssignEmptySet() = testIdempotentAssign { it -= setOf() } } diff --git a/libraries/stdlib/test/collections/MutableCollectionsTest.kt b/libraries/stdlib/test/collections/MutableCollectionsTest.kt index bffe1255e3b..0a2e3732df5 100644 --- a/libraries/stdlib/test/collections/MutableCollectionsTest.kt +++ b/libraries/stdlib/test/collections/MutableCollectionsTest.kt @@ -10,7 +10,7 @@ class MutableCollectionTest { // TODO: Use apply scope function - test fun addAll() { + @test fun addAll() { val data = listOf("foo", "bar") fun assertAdd(f: MutableList.() -> Unit) = assertEquals(data, arrayListOf().let { it.f(); it }) @@ -21,7 +21,7 @@ class MutableCollectionTest { assertAdd { addAll(data.asSequence()) } } - test fun removeAll() { + @test fun removeAll() { val content = arrayOf("foo", "bar", "bar") val data = listOf("bar") val expected = listOf("foo") @@ -35,7 +35,7 @@ class MutableCollectionTest { } - test fun retainAll() { + @test fun retainAll() { val content = arrayOf("foo", "bar", "bar") val data = listOf("bar") val expected = listOf("bar", "bar") diff --git a/libraries/stdlib/test/collections/ReversedViewsJVMTest.kt b/libraries/stdlib/test/collections/ReversedViewsJVMTest.kt index 7d78b23129a..b6f8fe01b79 100644 --- a/libraries/stdlib/test/collections/ReversedViewsJVMTest.kt +++ b/libraries/stdlib/test/collections/ReversedViewsJVMTest.kt @@ -25,7 +25,7 @@ import org.junit.Test as test */ class ReversedViewsJVMTest { - test fun testMutableSubList() { + @test fun testMutableSubList() { val original = arrayListOf(1, 2, 3, 4) val reversedSubList = original.asReversed().subList(1, 3) diff --git a/libraries/stdlib/test/collections/ReversedViewsTest.kt b/libraries/stdlib/test/collections/ReversedViewsTest.kt index 32da294d589..d3317eec25d 100644 --- a/libraries/stdlib/test/collections/ReversedViewsTest.kt +++ b/libraries/stdlib/test/collections/ReversedViewsTest.kt @@ -26,11 +26,11 @@ import org.junit.Test as test class ReversedViewsTest { - test fun testNullToString() { + @test fun testNullToString() { assertEquals("[null]", listOf(null).asReversed().toString()) } - test fun testBehavior() { + @test fun testBehavior() { val original = listOf(2L, 3L, Long.MAX_VALUE) val reversed = original.reversed() compare(reversed, original.asReversed()) { @@ -38,12 +38,12 @@ class ReversedViewsTest { } } - test fun testSimple() { + @test fun testSimple() { assertEquals(listOf(3, 2, 1), listOf(1, 2, 3).asReversed()) assertEquals(listOf(3, 2, 1), listOf(1, 2, 3).asReversed().toList()) } - test fun testRandomAccess() { + @test fun testRandomAccess() { val reversed = listOf(1, 2, 3).asReversed() assertEquals(3, reversed[0]) @@ -51,40 +51,40 @@ class ReversedViewsTest { assertEquals(1, reversed[2]) } - test fun testDoubleReverse() { + @test fun testDoubleReverse() { assertEquals(listOf(1, 2, 3), listOf(1, 2, 3).asReversed().asReversed()) assertEquals(listOf(2, 3), listOf(1, 2, 3, 4).asReversed().subList(1, 3).asReversed()) } - test fun testEmpty() { + @test fun testEmpty() { assertEquals(emptyList(), emptyList().asReversed()) } - test fun testReversedSubList() { + @test fun testReversedSubList() { val reversed = (1..10).toList().asReversed() assertEquals(listOf(9, 8, 7), reversed.subList(1, 4)) } - test fun testMutableSimple() { + @test fun testMutableSimple() { assertEquals(listOf(3, 2, 1), arrayListOf(1, 2, 3).asReversed()) assertEquals(listOf(3, 2, 1), arrayListOf(1, 2, 3).asReversed().toList()) } - test fun testMutableDoubleReverse() { + @test fun testMutableDoubleReverse() { assertEquals(listOf(1, 2, 3), arrayListOf(1, 2, 3).asReversed().asReversed()) assertEquals(listOf(2, 3), arrayListOf(1, 2, 3, 4).asReversed().subList(1, 3).asReversed()) } - test fun testMutableEmpty() { + @test fun testMutableEmpty() { assertEquals(emptyList(), arrayListOf().asReversed()) } - test fun testMutableReversedSubList() { + @test fun testMutableReversedSubList() { val reversed = (1..10).toArrayList().asReversed() assertEquals(listOf(9, 8, 7), reversed.subList(1, 4)) } - test fun testMutableAdd() { + @test fun testMutableAdd() { val original = arrayListOf(1, 2, 3) val reversed = original.asReversed() @@ -97,7 +97,7 @@ class ReversedViewsTest { assertEquals(listOf(0, 1, 2, 3, 4), original) } - test fun testMutableSet() { + @test fun testMutableSet() { val original = arrayListOf(1, 2, 3) val reversed = original.asReversed() @@ -109,7 +109,7 @@ class ReversedViewsTest { assertEquals(listOf(300, 200, 100), reversed) } - test fun testMutableRemove() { + @test fun testMutableRemove() { val original = arrayListOf("a", "b", "c") val reversed = original.asReversed() @@ -124,7 +124,7 @@ class ReversedViewsTest { assertEquals(emptyList(), original) } - test fun testMutableRemoveByObj() { + @test fun testMutableRemoveByObj() { val original = arrayListOf("a", "b", "c") val reversed = original.asReversed() @@ -133,7 +133,7 @@ class ReversedViewsTest { assertEquals(listOf("b", "a"), reversed) } - test fun testMutableClear() { + @test fun testMutableClear() { val original = arrayListOf(1, 2, 3) val reversed = original.asReversed() @@ -143,17 +143,17 @@ class ReversedViewsTest { assertEquals(emptyList(), original) } - test fun testContains() { + @test fun testContains() { assertTrue { 1 in listOf(1, 2, 3).asReversed() } assertTrue { 1 in arrayListOf(1, 2, 3).asReversed() } } - test fun testIndexOf() { + @test fun testIndexOf() { assertEquals(2, listOf(1, 2, 3).asReversed().indexOf(1)) assertEquals(2, arrayListOf(1, 2, 3).asReversed().indexOf(1)) } - test fun testBidirectionalModifications() { + @test fun testBidirectionalModifications() { val original = arrayListOf(1, 2, 3, 4) val reversed = original.asReversed() @@ -166,7 +166,7 @@ class ReversedViewsTest { assertEquals(listOf(3, 2), reversed) } - test fun testGetIOOB() { + @test fun testGetIOOB() { val success = try { listOf(1, 2, 3).asReversed().get(3) true @@ -177,7 +177,7 @@ class ReversedViewsTest { assertFalse(success) } - test fun testSetIOOB() { + @test fun testSetIOOB() { val success = try { arrayListOf(1, 2, 3).asReversed().set(3, 0) true @@ -188,7 +188,7 @@ class ReversedViewsTest { assertFalse(success) } - test fun testAddIOOB() { + @test fun testAddIOOB() { val success = try { arrayListOf(1, 2, 3).asReversed().add(4, 0) true @@ -199,7 +199,7 @@ class ReversedViewsTest { assertFalse(success) } - test fun testRemoveIOOB() { + @test fun testRemoveIOOB() { val success = try { arrayListOf(1, 2, 3).asReversed().remove(3) true diff --git a/libraries/stdlib/test/collections/SequenceJVMTest.kt b/libraries/stdlib/test/collections/SequenceJVMTest.kt index 0e691561bf2..e7e37d1b0cb 100644 --- a/libraries/stdlib/test/collections/SequenceJVMTest.kt +++ b/libraries/stdlib/test/collections/SequenceJVMTest.kt @@ -5,7 +5,7 @@ import kotlin.test.assertEquals class SequenceJVMTest { - test fun filterIsInstance() { + @test fun filterIsInstance() { val src: Sequence = listOf(1, 2, 3.toDouble(), "abc", "cde").asSequence() val intValues: Sequence = src.filterIsInstance() diff --git a/libraries/stdlib/test/collections/SequenceTest.kt b/libraries/stdlib/test/collections/SequenceTest.kt index df11de69760..a4d860be004 100644 --- a/libraries/stdlib/test/collections/SequenceTest.kt +++ b/libraries/stdlib/test/collections/SequenceTest.kt @@ -19,20 +19,20 @@ fun fibonacci(): Sequence { public class SequenceTest { - test fun filterEmptySequence() { + @test fun filterEmptySequence() { for (sequence in listOf(emptySequence(), sequenceOf())) { assertEquals(0, sequence.filter { false }.count()) assertEquals(0, sequence.filter { true }.count()) } } - test fun mapEmptySequence() { + @test fun mapEmptySequence() { for (sequence in listOf(emptySequence(), sequenceOf())) { assertEquals(0, sequence.map { true }.count()) } } - test fun requireNoNulls() { + @test fun requireNoNulls() { val sequence = sequenceOf("foo", "bar") val notNull = sequence.requireNoNulls() assertEquals(listOf("foo", "bar"), notNull.toList()) @@ -45,25 +45,25 @@ public class SequenceTest { } } - test fun filterNullable() { + @test fun filterNullable() { val data = sequenceOf(null, "foo", null, "bar") val filtered = data.filter { it == null || it == "foo" } assertEquals(listOf(null, "foo", null), filtered.toList()) } - test fun filterNot() { + @test fun filterNot() { val data = sequenceOf(null, "foo", null, "bar") val filtered = data.filterNot { it == null } assertEquals(listOf("foo", "bar"), filtered.toList()) } - test fun filterNotNull() { + @test fun filterNotNull() { val data = sequenceOf(null, "foo", null, "bar") val filtered = data.filterNotNull() assertEquals(listOf("foo", "bar"), filtered.toList()) } - test fun mapNotNull() { + @test fun mapNotNull() { val data = sequenceOf(null, "foo", null, "bar") val foo = data.mapNotNull { it.length() } assertEquals(listOf(3, 3), foo.toList()) @@ -73,60 +73,60 @@ public class SequenceTest { } } - test fun mapAndJoinToString() { + @test fun mapAndJoinToString() { assertEquals("3, 5, 8", fibonacci().withIndex().filter { it.index > 3 }.take(3).joinToString { it.value.toString() }) } - test fun withIndex() { + @test fun withIndex() { val data = sequenceOf("foo", "bar") val indexed = data.withIndex().map { it.value.substring(0..it.index) }.toList() assertEquals(2, indexed.size()) assertEquals(listOf("f", "ba"), indexed) } - test fun filterAndTakeWhileExtractTheElementsWithinRange() { + @test fun filterAndTakeWhileExtractTheElementsWithinRange() { assertEquals(listOf(144, 233, 377, 610, 987), fibonacci().filter { it > 100 }.takeWhile { it < 1000 }.toList()) } - test fun foldReducesTheFirstNElements() { + @test fun foldReducesTheFirstNElements() { val sum = { a: Int, b: Int -> a + b } assertEquals(listOf(13, 21, 34, 55, 89).fold(0, sum), fibonacci().filter { it > 10 }.take(5).fold(0, sum)) } - test fun takeExtractsTheFirstNElements() { + @test fun takeExtractsTheFirstNElements() { assertEquals(listOf(0, 1, 1, 2, 3, 5, 8, 13, 21, 34), fibonacci().take(10).toList()) } - test fun mapAndTakeWhileExtractTheTransformedElements() { + @test fun mapAndTakeWhileExtractTheTransformedElements() { assertEquals(listOf(0, 3, 3, 6, 9, 15), fibonacci().map { it * 3 }.takeWhile { i: Int -> i < 20 }.toList()) } - test fun joinConcatenatesTheFirstNElementsAboveAThreshold() { + @test fun joinConcatenatesTheFirstNElementsAboveAThreshold() { assertEquals("13, 21, 34, 55, 89, ...", fibonacci().filter { it > 10 }.joinToString(separator = ", ", limit = 5)) } - test fun drop() { + @test fun drop() { assertEquals("13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...", fibonacci().drop(7).joinToString(limit = 10)) assertEquals("13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...", fibonacci().drop(3).drop(4).joinToString(limit = 10)) } - test fun take() { + @test fun take() { assertEquals("0, 1, 1, 2, 3, 5, 8", fibonacci().take(7).joinToString()) assertEquals("2, 3, 5, 8", fibonacci().drop(3).take(4).joinToString()) } - test fun dropWhile() { + @test fun dropWhile() { assertEquals("233, 377, 610", fibonacci().dropWhile { it < 200 }.take(3).joinToString(limit = 10)) assertEquals("", sequenceOf(1).dropWhile { it < 200 }.joinToString(limit = 10)) } - test fun merge() { + @test fun merge() { expect(listOf("ab", "bc", "cd")) { sequenceOf("a", "b", "c").merge(sequenceOf("b", "c", "d")) { a, b -> a + b }.toList() } } - test fun toStringJoinsNoMoreThanTheFirstTenElements() { + @test fun toStringJoinsNoMoreThanTheFirstTenElements() { assertEquals("0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...", fibonacci().joinToString(limit = 10)) assertEquals("13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...", fibonacci().filter { it > 10 }.joinToString(limit = 10)) assertEquals("144, 233, 377, 610, 987", fibonacci().filter { it > 100 }.takeWhile { it < 1000 }.joinToString()) @@ -141,12 +141,12 @@ public class SequenceTest { } - test fun plusElement() = testPlus { it + "cheese" + "wine" } - test fun plusCollection() = testPlus { it + listOf("cheese", "wine") } - test fun plusArray() = testPlus { it + arrayOf("cheese", "wine") } - test fun plusSequence() = testPlus { it + sequenceOf("cheese", "wine") } + @test fun plusElement() = testPlus { it + "cheese" + "wine" } + @test fun plusCollection() = testPlus { it + listOf("cheese", "wine") } + @test fun plusArray() = testPlus { it + arrayOf("cheese", "wine") } + @test fun plusSequence() = testPlus { it + sequenceOf("cheese", "wine") } - test fun plusAssign() { + @test fun plusAssign() { // lets use a mutable variable var seq = sequenceOf("a") seq += "foo" @@ -163,12 +163,12 @@ public class SequenceTest { assertEquals(expected_, b.toList()) } - test fun minusElement() = testMinus(expected = listOf("foo", "bar")) { it - "bar" - "zoo" } - test fun minusCollection() = testMinus { it - listOf("bar", "zoo") } - test fun minusArray() = testMinus { it - arrayOf("bar", "zoo") } - test fun minusSequence() = testMinus { it - sequenceOf("bar", "zoo") } + @test fun minusElement() = testMinus(expected = listOf("foo", "bar")) { it - "bar" - "zoo" } + @test fun minusCollection() = testMinus { it - listOf("bar", "zoo") } + @test fun minusArray() = testMinus { it - arrayOf("bar", "zoo") } + @test fun minusSequence() = testMinus { it - sequenceOf("bar", "zoo") } - test fun minusIsLazyIterated() { + @test fun minusIsLazyIterated() { val seq = sequenceOf("foo", "bar") val list = arrayListOf() val result = seq - list @@ -179,7 +179,7 @@ public class SequenceTest { assertEquals(emptyList(), result.toList()) } - test fun minusAssign() { + @test fun minusAssign() { // lets use a mutable variable of readonly list val data = sequenceOf("cheese", "foo", "beer", "cheese", "wine") var l = data @@ -194,7 +194,7 @@ public class SequenceTest { - test fun iterationOverSequence() { + @test fun iterationOverSequence() { var s = "" for (i in sequenceOf(0, 1, 2, 3, 4, 5)) { s += i.toString() @@ -202,7 +202,7 @@ public class SequenceTest { assertEquals("012345", s) } - test fun sequenceFromFunction() { + @test fun sequenceFromFunction() { var count = 3 val sequence = sequence { @@ -218,7 +218,7 @@ public class SequenceTest { } } - test fun sequenceFromFunctionWithInitialValue() { + @test fun sequenceFromFunctionWithInitialValue() { val values = sequence(3) { n -> if (n > 0) n - 1 else null } val expected = listOf(3, 2, 1, 0) assertEquals(expected, values.toList()) @@ -226,7 +226,7 @@ public class SequenceTest { } - test fun sequenceFromIterator() { + @test fun sequenceFromIterator() { val list = listOf(3, 2, 1, 0) val iterator = list.iterator() val sequence = iterator.asSequence() @@ -236,7 +236,7 @@ public class SequenceTest { } } - test fun makeSequenceOneTimeConstrained() { + @test fun makeSequenceOneTimeConstrained() { val sequence = sequenceOf(1, 2, 3, 4) sequence.toList() sequence.toList() @@ -256,13 +256,13 @@ public class SequenceTest { return result } - test fun sequenceExtensions() { + @test fun sequenceExtensions() { val d = ArrayList() sequenceOf(0, 1, 2, 3, 4, 5).takeWhileTo(d, { i -> i < 4 }) assertEquals(4, d.size()) } - test fun flatMapAndTakeExtractTheTransformedElements() { + @test fun flatMapAndTakeExtractTheTransformedElements() { val expected = listOf( '3', // fibonacci(4) = 3 '5', // fibonacci(5) = 5 @@ -276,51 +276,51 @@ public class SequenceTest { assertEquals(expected, fibonacci().drop(4).flatMap { it.toString().asSequence() }.take(10).toList()) } - test fun flatMap() { + @test fun flatMap() { val result = sequenceOf(1, 2).flatMap { sequenceOf(0..it) } assertEquals(listOf(0, 1, 0, 1, 2), result.toList()) } - test fun flatMapOnEmpty() { + @test fun flatMapOnEmpty() { val result = sequenceOf().flatMap { sequenceOf(0..it) } assertTrue(result.none()) } - test fun flatMapWithEmptyItems() { + @test fun flatMapWithEmptyItems() { val result = sequenceOf(1, 2, 4).flatMap { if (it == 2) sequenceOf() else sequenceOf(it - 1..it) } assertEquals(listOf(0, 1, 3, 4), result.toList()) } - test fun flatten() { + @test fun flatten() { val data = sequenceOf(1, 2).map { sequenceOf(0..it) } assertEquals(listOf(0, 1, 0, 1, 2), data.flatten().toList()) } - test fun distinct() { + @test fun distinct() { val sequence = fibonacci().dropWhile { it < 10 }.take(20) assertEquals(listOf(1, 2, 3, 0), sequence.map { it % 4 }.distinct().toList()) } - test fun distinctBy() { + @test fun distinctBy() { val sequence = fibonacci().dropWhile { it < 10 }.take(20) assertEquals(listOf(13, 34, 55, 144), sequence.distinctBy { it % 4 }.toList()) } - test fun unzip() { + @test fun unzip() { val seq = sequenceOf(1 to 'a', 2 to 'b', 3 to 'c') val (ints, chars) = seq.unzip() assertEquals(listOf(1, 2, 3), ints) assertEquals(listOf('a', 'b', 'c'), chars) } - test fun sorted() { + @test fun sorted() { sequenceOf(3, 7, 5).let { it.sorted().iterator().assertSorted { a, b -> a <= b } it.sortedDescending().iterator().assertSorted { a, b -> a >= b } } } - test fun sortedBy() { + @test fun sortedBy() { sequenceOf("it", "greater", "less").let { it.sortedBy { it.length() }.iterator().assertSorted { a, b -> compareValuesBy(a, b) { it.length() } <= 0 } it.sortedByDescending { it.length() }.iterator().assertSorted { a, b -> compareValuesBy(a, b) { it.length() } >= 0 } @@ -332,7 +332,7 @@ public class SequenceTest { } } - test fun sortedWith() { + @test fun sortedWith() { val comparator = compareBy { s: String -> s.reversed() } assertEquals(listOf("act", "wast", "test"), sequenceOf("act", "test", "wast").sortedWith(comparator).toList()) } diff --git a/libraries/stdlib/test/collections/SetOperationsTest.kt b/libraries/stdlib/test/collections/SetOperationsTest.kt index 92de7472a1a..dff41568683 100644 --- a/libraries/stdlib/test/collections/SetOperationsTest.kt +++ b/libraries/stdlib/test/collections/SetOperationsTest.kt @@ -4,29 +4,29 @@ import kotlin.test.* import org.junit.Test as test class SetOperationsTest { - test fun distinct() { + @test fun distinct() { assertEquals(listOf(1, 3, 5), listOf(1, 3, 3, 1, 5, 1, 3).distinct()) assertTrue(listOf().distinct().isEmpty()) } - test fun distinctBy() { + @test fun distinctBy() { assertEquals(listOf("some", "cat", "do"), arrayOf("some", "case", "cat", "do", "dog", "it").distinctBy { it.length() }) assertTrue(charArrayOf().distinctBy { it }.isEmpty()) } - test fun union() { + @test fun union() { assertEquals(listOf(1, 3, 5), listOf(1, 3).union(listOf(5)).toList()) assertEquals(listOf(1), listOf().union(listOf(1)).toList()) } - test fun subtract() { + @test fun subtract() { assertEquals(listOf(1, 3), listOf(1, 3).subtract(listOf(5)).toList()) assertEquals(listOf(1, 3), listOf(1, 3, 5).subtract(listOf(5)).toList()) assertTrue(listOf(1, 3, 5).subtract(listOf(1, 3, 5)).none()) assertTrue(listOf().subtract(listOf(1)).none()) } - test fun intersect() { + @test fun intersect() { assertTrue(listOf(1, 3).intersect(listOf(5)).none()) assertEquals(listOf(5), listOf(1, 3, 5).intersect(listOf(5)).toList()) assertEquals(listOf(1, 3, 5), listOf(1, 3, 5).intersect(listOf(1, 3, 5)).toList()) @@ -40,12 +40,12 @@ class SetOperationsTest { assertEquals(setOf("foo", "bar", "cheese", "wine"), set2) } - test fun plusElement() = testPlus { it + "bar" + "cheese" + "wine" } - test fun plusCollection() = testPlus { it + listOf("bar", "cheese", "wine") } - test fun plusArray() = testPlus { it + arrayOf("bar", "cheese", "wine") } - test fun plusSequence() = testPlus { it + sequenceOf("bar", "cheese", "wine") } + @test fun plusElement() = testPlus { it + "bar" + "cheese" + "wine" } + @test fun plusCollection() = testPlus { it + listOf("bar", "cheese", "wine") } + @test fun plusArray() = testPlus { it + arrayOf("bar", "cheese", "wine") } + @test fun plusSequence() = testPlus { it + sequenceOf("bar", "cheese", "wine") } - test fun plusAssign() { + @test fun plusAssign() { // lets use a mutable variable var set = setOf("a") val setOriginal = set @@ -70,9 +70,9 @@ class SetOperationsTest { assertEquals(setOf("foo"), b) } - test fun minusElement() = testMinus { it - "bar" - "zoo" } - test fun minusCollection() = testMinus { it - listOf("bar", "zoo") } - test fun minusArray() = testMinus { it - arrayOf("bar", "zoo") } - test fun minusSequence() = testMinus { it - sequenceOf("bar", "zoo") } + @test fun minusElement() = testMinus { it - "bar" - "zoo" } + @test fun minusCollection() = testMinus { it - listOf("bar", "zoo") } + @test fun minusArray() = testMinus { it - arrayOf("bar", "zoo") } + @test fun minusSequence() = testMinus { it - sequenceOf("bar", "zoo") } } \ No newline at end of file diff --git a/libraries/stdlib/test/concurrent/ThreadTest.kt b/libraries/stdlib/test/concurrent/ThreadTest.kt index 068a79147d8..1a542f434f3 100644 --- a/libraries/stdlib/test/concurrent/ThreadTest.kt +++ b/libraries/stdlib/test/concurrent/ThreadTest.kt @@ -9,7 +9,7 @@ import java.util.concurrent.* import java.util.concurrent.TimeUnit.* class ThreadTest { - test fun scheduledTask() { + @test fun scheduledTask() { val pool = Executors.newFixedThreadPool(1) val countDown = CountDownLatch(1) @@ -19,7 +19,7 @@ class ThreadTest { assertTrue(countDown.await(2, SECONDS), "Count down is executed") } - test fun callableInvoke() { + @test fun callableInvoke() { val pool = Executors.newFixedThreadPool(1) val future = pool.submit { // type specification required here to choose overload for callable, see KT-7882 @@ -28,7 +28,7 @@ class ThreadTest { assertEquals("Hello", future.get(2, SECONDS)) } - test fun threadLocalGetOrSet() { + @test fun threadLocalGetOrSet() { val v = ThreadLocal() assertEquals("v1", v.getOrSet { "v1" }) diff --git a/libraries/stdlib/test/concurrent/TimerTest.kt b/libraries/stdlib/test/concurrent/TimerTest.kt index f27731e590b..91a9b7b46ce 100644 --- a/libraries/stdlib/test/concurrent/TimerTest.kt +++ b/libraries/stdlib/test/concurrent/TimerTest.kt @@ -9,7 +9,7 @@ import java.util.Timer import org.junit.Test as test class TimerTest { - test fun scheduledTask() { + @test fun scheduledTask() { val counter = AtomicInteger(0) val timer = Timer() diff --git a/libraries/stdlib/test/dom/DomBuilderTest.kt b/libraries/stdlib/test/dom/DomBuilderTest.kt index 55b0bfc1d11..6085ba1a3c3 100644 --- a/libraries/stdlib/test/dom/DomBuilderTest.kt +++ b/libraries/stdlib/test/dom/DomBuilderTest.kt @@ -7,7 +7,7 @@ import org.junit.Test as test class DomBuilderTest() { - test fun buildDocument() { + @test fun buildDocument() { var doc = createDocument() assertTrue { diff --git a/libraries/stdlib/test/dom/DomTest.kt b/libraries/stdlib/test/dom/DomTest.kt index ca502ec7615..b990228b217 100644 --- a/libraries/stdlib/test/dom/DomTest.kt +++ b/libraries/stdlib/test/dom/DomTest.kt @@ -8,7 +8,7 @@ import org.junit.Test as test class DomTest { - test fun testCreateDocument() { + @test fun testCreateDocument() { var doc = createDocument() assertNotNull(doc, "Should have created a document") @@ -27,7 +27,7 @@ class DomTest { println("document ${doc.toXmlString()}") } - test fun addText() { + @test fun addText() { var doc = createDocument() assertNotNull(doc, "Should have created a document") diff --git a/libraries/stdlib/test/dom/NextSiblingTest.kt b/libraries/stdlib/test/dom/NextSiblingTest.kt index 3034d1a00a2..da057245394 100644 --- a/libraries/stdlib/test/dom/NextSiblingTest.kt +++ b/libraries/stdlib/test/dom/NextSiblingTest.kt @@ -7,7 +7,7 @@ import org.junit.Test as test class NextSiblingTest { - test fun nextSibling() { + @test fun nextSibling() { val doc = createDocument() doc.addElement("foo") { diff --git a/libraries/stdlib/test/io/Files.kt b/libraries/stdlib/test/io/Files.kt index 4d457dda207..37f162c9445 100644 --- a/libraries/stdlib/test/io/Files.kt +++ b/libraries/stdlib/test/io/Files.kt @@ -14,13 +14,13 @@ import kotlin.test.assertTrue class FilesTest { - test fun testPath() { + @test fun testPath() { val fileSuf = System.currentTimeMillis().toString() val file1 = createTempFile("temp", fileSuf) assertTrue(file1.path.endsWith(fileSuf), file1.path) } - test fun testCreateTempDir() { + @test fun testCreateTempDir() { val dirSuf = System.currentTimeMillis().toString() val dir1 = createTempDir("temp", dirSuf) assert(dir1.exists() && dir1.isDirectory() && dir1.name.startsWith("temp") && dir1.name.endsWith(dirSuf)) @@ -41,7 +41,7 @@ class FilesTest { dir3.delete() } - test fun testCreateTempFile() { + @test fun testCreateTempFile() { val fileSuf = System.currentTimeMillis().toString() val file1 = createTempFile("temp", fileSuf) assert(file1.exists() && file1.name.startsWith("temp") && file1.name.endsWith(fileSuf)) @@ -79,7 +79,7 @@ class FilesTest { } } - test fun withSimple() { + @test fun withSimple() { val basedir = createTestFiles() try { val referenceNames = @@ -104,7 +104,7 @@ class FilesTest { } } - test fun withEnterLeave() { + @test fun withEnterLeave() { val basedir = createTestFiles() try { val referenceNames = @@ -163,7 +163,7 @@ class FilesTest { } } - test fun withFilterAndMap() { + @test fun withFilterAndMap() { val basedir = createTestFiles() try { val referenceNames = @@ -178,7 +178,7 @@ class FilesTest { } - test fun withDeleteTxtTopDown() { + @test fun withDeleteTxtTopDown() { val basedir = createTestFiles() try { val referenceNames = @@ -203,7 +203,7 @@ class FilesTest { } } - test fun withDeleteTxtBottomUp() { + @test fun withDeleteTxtBottomUp() { val basedir = createTestFiles() try { val referenceNames = @@ -228,7 +228,7 @@ class FilesTest { } } - test fun withFilter() { + @test fun withFilter() { val basedir = createTestFiles() try { fun filter(file: File): Boolean { @@ -258,7 +258,7 @@ class FilesTest { } } - test fun withTotalFilter() { + @test fun withTotalFilter() { val basedir = createTestFiles() try { val referenceNames: Set = setOf() @@ -283,7 +283,7 @@ class FilesTest { } } - test fun withForEach() { + @test fun withForEach() { val basedir = createTestFiles() try { var i = 0 @@ -297,7 +297,7 @@ class FilesTest { } } - test fun withCount() { + @test fun withCount() { val basedir = createTestFiles() try { assertEquals(10, basedir.walkTopDown().count()); @@ -307,7 +307,7 @@ class FilesTest { } } - test fun withReduce() { + @test fun withReduce() { val basedir = createTestFiles() try { val res = basedir.walkTopDown().reduce { a, b -> if (a.canonicalPath > b.canonicalPath) a else b } @@ -317,7 +317,7 @@ class FilesTest { } } - test fun withVisitorAndDepth() { + @test fun withVisitorAndDepth() { val basedir = createTestFiles() try { val files = HashSet() @@ -394,7 +394,7 @@ class FilesTest { } } - test fun topDown() { + @test fun topDown() { val basedir = createTestFiles() try { val visited = HashSet() @@ -411,7 +411,7 @@ class FilesTest { } } - test fun restrictedAccess() { + @test fun restrictedAccess() { val basedir = createTestFiles() val restricted = File(basedir, "1") try { @@ -431,7 +431,7 @@ class FilesTest { } } - test fun backup() { + @test fun backup() { var count = 0 fun makeBackup(file: File) { count++ @@ -465,7 +465,7 @@ class FilesTest { } } - test fun find() { + @test fun find() { val basedir = createTestFiles() try { File(basedir, "8/4.txt".separatorsToSystem()).createNewFile() @@ -481,7 +481,7 @@ class FilesTest { } } - test fun findGits() { + @test fun findGits() { val basedir = createTestFiles() try { File(basedir, "1/3/.git").mkdir() @@ -499,7 +499,7 @@ class FilesTest { } } - test fun streamFileTree() { + @test fun streamFileTree() { val dir = createTempDir() try { val subDir1 = createTempDir(prefix = "d1_", directory = dir) @@ -523,7 +523,7 @@ class FilesTest { } } - test fun recurse() { + @test fun recurse() { val set: MutableSet = HashSet() val dir = createTestFiles() dir.recurse { set.add(it.path) } @@ -531,7 +531,7 @@ class FilesTest { } } - test fun listFilesWithFilter() { + @test fun listFilesWithFilter() { val dir = createTempDir("temp") createTempFile("temp1", ".kt", dir) @@ -546,7 +546,7 @@ class FilesTest { assertEquals(2, result2!!.size()) } - test fun relativeToTest() { + @test fun relativeToTest() { val file1 = File("/foo/bar/baz") val file2 = File("/foo/baa/ghoo") assertEquals("../../bar/baz".separatorsToSystem(), file1.relativeTo(file2)) @@ -577,7 +577,7 @@ class FilesTest { assertEquals("..", file11.relativeTo(file10)) } - test fun relativeTo() { + @test fun relativeTo() { assertEquals("kotlin", File("src/kotlin".separatorsToSystem()).relativeTo(File("src"))) assertEquals("", File("dir").relativeTo(File("dir"))) assertEquals("..", File("dir").relativeTo(File("dir/subdir".separatorsToSystem()))) @@ -596,7 +596,7 @@ class FilesTest { } } - test fun relativePath() { + @test fun relativePath() { val file1 = File("src") val file2 = File(file1, "kotlin") val file3 = File("test") @@ -616,7 +616,7 @@ class FilesTest { assertEquals(elements.size(), i) } - test fun fileIterator() { + @test fun fileIterator() { checkFileElements(File("/foo/bar"), File("/"), listOf("foo", "bar")) checkFileElements(File("\\foo\\bar"), File("\\".separatorsToSystem()), listOf("foo", "bar")) checkFileElements(File("/foo/bar/gav"), File("/"), listOf("foo", "bar", "gav")) @@ -637,13 +637,13 @@ class FilesTest { checkFileElements(File(".."), null, listOf("..")) } - test fun startsWith() { + @test fun startsWith() { assertTrue(File("C:\\Users\\Me\\Temp\\Game").startsWith("C:\\Users\\Me")) assertFalse(File("C:\\Users\\Me\\Temp\\Game").startsWith("C:\\Users\\He")) assertTrue(File("C:\\Users\\Me").startsWith("C:\\")) } - test fun endsWith() { + @test fun endsWith() { assertTrue(File("/foo/bar").endsWith("bar")) assertTrue(File("/foo/bar").endsWith("/bar")) assertTrue(File("/foo/bar/gav/bar").endsWith("/bar")) @@ -652,7 +652,7 @@ class FilesTest { assertFalse(File("foo/bar").endsWith("/bar")) } - test fun subPath() { + @test fun subPath() { if (File.separatorChar == '\\') { // Check only in Windows assertEquals(File("mike"), File("//my.host.net/home/mike/temp").subPath(0, 1)) @@ -663,7 +663,7 @@ class FilesTest { assertEquals(File("gav/hi"), File("/foo/bar/gav/hi").subPath(2, 4)) } - test fun normalize() { + @test fun normalize() { assertEquals(File("/foo/bar/baaz"), File("/foo/./bar/gav/../baaz").normalize()) assertEquals(File("/foo/bar/baaz"), File("/foo/bak/../bar/gav/../baaz").normalize()) assertEquals(File("../../bar"), File("../foo/../../bar").normalize()) @@ -674,7 +674,7 @@ class FilesTest { assertEquals(File("foo"), File("gav/bar/../../foo").normalize()) } - test fun resolve() { + @test fun resolve() { assertEquals(File("/foo/bar/gav"), File("/foo/bar").resolve("gav")) assertEquals(File("/foo/bar/gav"), File("/foo/bar/").resolve("gav")) assertEquals(File("/gav"), File("/foo/bar").resolve("/gav")) @@ -685,7 +685,7 @@ class FilesTest { File("C:/Users/Me").resolve("Documents/important.doc")) } - test fun resolveSibling() { + @test fun resolveSibling() { assertEquals(File("/foo/gav"), File("/foo/bar").resolveSibling("gav")) assertEquals(File("/foo/gav"), File("/foo/bar/").resolveSibling("gav")) assertEquals(File("/gav"), File("/foo/bar").resolveSibling("/gav")) @@ -696,7 +696,7 @@ class FilesTest { File("C:/Users/Me/profile.ini").resolveSibling("Documents/important.doc")) } - test fun extension() { + @test fun extension() { assertEquals("bbb", File("aaa.bbb").extension) assertEquals("", File("aaa").extension) assertEquals("", File("aaa.").extension) @@ -705,7 +705,7 @@ class FilesTest { assertEquals("", File("/my.dir/log").extension) } - test fun nameWithoutExtension() { + @test fun nameWithoutExtension() { assertEquals("aaa", File("aaa.bbb").nameWithoutExtension) assertEquals("aaa", File("aaa").nameWithoutExtension) assertEquals("aaa", File("aaa.").nameWithoutExtension) @@ -713,7 +713,7 @@ class FilesTest { assertEquals("log", File("/my.dir/log").nameWithoutExtension) } - test fun separatorsToSystem() { + @test fun separatorsToSystem() { var path = "/aaa/bbb/ccc" assertEquals(path.replace("/", File.separator), File(path).separatorsToSystem()) @@ -733,7 +733,7 @@ class FilesTest { assertEquals("test", "test".allSeparatorsToSystem()) } - test fun testCopyTo() { + @test fun testCopyTo() { val srcFile = createTempFile() val dstFile = createTempFile() srcFile.writeText("Hello, World!", "UTF8") @@ -780,7 +780,7 @@ class FilesTest { srcFile.delete() } - test fun copyToNameWithoutParent() { + @test fun copyToNameWithoutParent() { val currentDir = File("").getAbsoluteFile()!! val srcFile = createTempFile() val dstFile = createTempFile(directory = currentDir) @@ -800,7 +800,7 @@ class FilesTest { } } - test fun deleteRecursively() { + @test fun deleteRecursively() { val dir = createTempDir() dir.delete() dir.mkdir() @@ -814,7 +814,7 @@ class FilesTest { assert(!dir.deleteRecursively()) } - test fun deleteRecursivelyWithFail() { + @test fun deleteRecursivelyWithFail() { val basedir = Walks.createTestFiles() val restricted = File(basedir, "1") try { @@ -837,7 +837,7 @@ class FilesTest { } } - test fun copyRecursively() { + @test fun copyRecursively() { val src = createTempDir() val dst = createTempDir() dst.delete() @@ -921,7 +921,7 @@ class FilesTest { } } - test fun helpers1() { + @test fun helpers1() { val str = "123456789\n" System.setIn(str.byteInputStream()) val reader = System.`in`.bufferedReader() @@ -932,7 +932,7 @@ class FilesTest { assertEquals('3', stringReader.read().toChar()) } - test fun helpers2() { + @test fun helpers2() { val file = createTempFile() val writer = file.printWriter() val str1 = "Hello, world!" diff --git a/libraries/stdlib/test/io/IOStreams.kt b/libraries/stdlib/test/io/IOStreams.kt index 20cee137592..b57b574c7c5 100644 --- a/libraries/stdlib/test/io/IOStreams.kt +++ b/libraries/stdlib/test/io/IOStreams.kt @@ -7,7 +7,7 @@ import java.io.BufferedReader import java.io.File class IOStreamsTest { - test fun testGetStreamOfFile() { + @test fun testGetStreamOfFile() { val tmpFile = createTempFile() var writer: Writer? = null try { diff --git a/libraries/stdlib/test/io/ReadWrite.kt b/libraries/stdlib/test/io/ReadWrite.kt index 39c84e6fe73..aa0eb7f669e 100644 --- a/libraries/stdlib/test/io/ReadWrite.kt +++ b/libraries/stdlib/test/io/ReadWrite.kt @@ -13,7 +13,7 @@ import kotlin.test.assertTrue fun sample(): Reader = StringReader("Hello\nWorld"); class ReadWriteTest { - test fun testAppendText() { + @test fun testAppendText() { val file = File.createTempFile("temp", System.nanoTime().toString()) file.writeText("Hello\n", "UTF8") file.appendText("World\n", "UTF8") @@ -24,7 +24,7 @@ class ReadWriteTest { file.deleteOnExit() } - test fun reader() { + @test fun reader() { val list = ArrayList() /* TODO would be nicer maybe to write this as @@ -63,7 +63,7 @@ class ReadWriteTest { assertEquals(2, c) } - test fun file() { + @test fun file() { val file = File.createTempFile("temp", System.nanoTime().toString()) val writer = file.outputStream().writer().buffered() @@ -109,7 +109,7 @@ class ReadWriteTest { } class LineIteratorTest { - test fun useLines() { + @test fun useLines() { // TODO we should maybe zap the useLines approach as it encourages // use of iterators which don't close the underlying stream val list1 = sample().useLines { it.toArrayList() } @@ -119,7 +119,7 @@ class ReadWriteTest { assertEquals(arrayListOf("Hello", "World"), list2) } - test fun manualClose() { + @test fun manualClose() { val reader = sample().buffered() try { val list = reader.lineSequence().toArrayList() @@ -129,7 +129,7 @@ class ReadWriteTest { } } - test fun boundaryConditions() { + @test fun boundaryConditions() { var reader = StringReader("").buffered() assertEquals(ArrayList(), reader.lineSequence().toArrayList()) reader.close() @@ -148,7 +148,7 @@ class ReadWriteTest { } } - test fun testUse() { + @test fun testUse() { val list = ArrayList() val reader = sample().buffered() @@ -165,7 +165,7 @@ class ReadWriteTest { assertEquals(arrayListOf("Hello", "World"), list) } - test fun testURL() { + @test fun testURL() { val url = URL("http://kotlinlang.org") val text = url.readText() assertFalse(text.isEmpty()) diff --git a/libraries/stdlib/test/iterators/FunctionIteratorTest.kt b/libraries/stdlib/test/iterators/FunctionIteratorTest.kt index de5722bcbb1..bb2f00c5e1a 100644 --- a/libraries/stdlib/test/iterators/FunctionIteratorTest.kt +++ b/libraries/stdlib/test/iterators/FunctionIteratorTest.kt @@ -7,7 +7,8 @@ import org.junit.Test class FunctionIteratorTest { - Test fun iterateOverFunction() { + @Test + fun iterateOverFunction() { var count = 3 val iter = sequence { @@ -19,7 +20,8 @@ class FunctionIteratorTest { assertEquals(arrayListOf(2, 1, 0), list) } - Test fun iterateOverFunction2() { + @Test + fun iterateOverFunction2() { val values = sequence(3) { n -> if (n > 0) n - 1 else null } assertEquals(arrayListOf(3, 2, 1, 0), values.toList()) } diff --git a/libraries/stdlib/test/iterators/IteratorsJVMTest.kt b/libraries/stdlib/test/iterators/IteratorsJVMTest.kt index a5cf78f17d9..6d010f43033 100644 --- a/libraries/stdlib/test/iterators/IteratorsJVMTest.kt +++ b/libraries/stdlib/test/iterators/IteratorsJVMTest.kt @@ -6,7 +6,7 @@ import org.junit.Test as test class IteratorsJVMTest { - test fun flatMapAndTakeExtractTheTransformedElements() { + @test fun flatMapAndTakeExtractTheTransformedElements() { fun intToBinaryDigits() = { i: Int -> val binary = Integer.toBinaryString(i)!! var index = 0 @@ -25,7 +25,7 @@ class IteratorsJVMTest { assertEquals(expected, fibonacci().flatMap(intToBinaryDigits()).take(10).toList()) } - test fun flatMapOnIterator() { + @test fun flatMapOnIterator() { val result = sequenceOf(1, 2).flatMap { i -> (0..i).asSequence()} assertEquals(listOf(0, 1, 0, 1, 2), result.toList()) } diff --git a/libraries/stdlib/test/iterators/IteratorsTest.kt b/libraries/stdlib/test/iterators/IteratorsTest.kt index e68c3e67b74..69618367541 100644 --- a/libraries/stdlib/test/iterators/IteratorsTest.kt +++ b/libraries/stdlib/test/iterators/IteratorsTest.kt @@ -13,32 +13,32 @@ fun fibonacci(): Sequence { class IteratorsTest { - test fun filterAndTakeWhileExtractTheElementsWithinRange() { + @test fun filterAndTakeWhileExtractTheElementsWithinRange() { assertEquals(arrayListOf(144, 233, 377, 610, 987), fibonacci().filter { it > 100 }.takeWhile { it < 1000 }.toList()) } - test fun foldReducesTheFirstNElements() { + @test fun foldReducesTheFirstNElements() { val sum = { a: Int, b: Int -> a + b } assertEquals(arrayListOf(13, 21, 34, 55, 89).fold(0, sum), fibonacci().filter { it > 10 }.take(5).fold(0, sum)) } - test fun takeExtractsTheFirstNElements() { + @test fun takeExtractsTheFirstNElements() { assertEquals(arrayListOf(0, 1, 1, 2, 3, 5, 8, 13, 21, 34), fibonacci().take(10).toList()) } - test fun mapAndTakeWhileExtractTheTransformedElements() { + @test fun mapAndTakeWhileExtractTheTransformedElements() { assertEquals(arrayListOf(0, 3, 3, 6, 9, 15), fibonacci().map { it * 3 }.takeWhile { i: Int -> i < 20 }.toList()) } - test fun mapIndexed() { + @test fun mapIndexed() { assertEquals(arrayListOf(0, 1, 2, 6, 12), fibonacci().mapIndexed { index, value -> index * value }.takeWhile { i: Int -> i < 20 }.toList()) } - test fun joinConcatenatesTheFirstNElementsAboveAThreshold() { + @test fun joinConcatenatesTheFirstNElementsAboveAThreshold() { assertEquals("13, 21, 34, 55, 89, ...", fibonacci().filter { it > 10 }.joinToString(separator = ", ", limit = 5)) } - test fun plus() { + @test fun plus() { val iter = arrayListOf("foo", "bar").asSequence() val iter2 = iter + "cheese" assertEquals(arrayListOf("foo", "bar", "cheese"), iter2.toList()) @@ -49,7 +49,7 @@ class IteratorsTest { assertEquals(arrayListOf("a", "b", "c"), mi.toList()) } - test fun plusCollection() { + @test fun plusCollection() { val a = arrayListOf("foo", "bar") val b = arrayListOf("cheese", "wine") val iter = a.asSequence() + b.asSequence() @@ -64,7 +64,7 @@ class IteratorsTest { assertEquals(arrayListOf("a", "foo", "bar", "beer", "cheese", "wine", "z"), ml.toList()) } - test fun requireNoNulls() { + @test fun requireNoNulls() { val iter = arrayListOf("foo", "bar").asSequence() val notNull = iter.requireNoNulls() assertEquals(arrayListOf("foo", "bar"), notNull.toList()) @@ -77,23 +77,23 @@ class IteratorsTest { } } - test fun toStringJoinsNoMoreThanTheFirstTenElements() { + @test fun toStringJoinsNoMoreThanTheFirstTenElements() { assertEquals("0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...", fibonacci().joinToString(limit = 10)) assertEquals("13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...", fibonacci().filter { it > 10 }.joinToString(limit = 10)) assertEquals("144, 233, 377, 610, 987", fibonacci().filter { it > 100 }.takeWhile { it < 1000 }.joinToString()) } - test fun pairIterator() { + @test fun pairIterator() { val pairStr = (fibonacci() zip fibonacci().map { i -> i*2 }).joinToString(limit = 10) assertEquals("(0, 0), (1, 2), (1, 2), (2, 4), (3, 6), (5, 10), (8, 16), (13, 26), (21, 42), (34, 68), ...", pairStr) } - test fun skippingIterator() { + @test fun skippingIterator() { assertEquals("13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...", fibonacci().drop(7).joinToString(limit = 10)) assertEquals("13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...", fibonacci().drop(3).drop(4).joinToString(limit = 10)) } - test fun iterationOverIterator() { + @test fun iterationOverIterator() { val c = arrayListOf(0, 1, 2, 3, 4, 5) var s = "" for (i in c.iterator()) { @@ -107,7 +107,7 @@ class IteratorsTest { return result } - test fun iterableExtension() { + @test fun iterableExtension() { val c = arrayListOf(0, 1, 2, 3, 4, 5) val d = ArrayList() c.iterator().takeWhileTo(d, {i -> i < 4 }) diff --git a/libraries/stdlib/test/js/JsArrayTest.kt b/libraries/stdlib/test/js/JsArrayTest.kt index 9c69b8bef10..efcabda558d 100644 --- a/libraries/stdlib/test/js/JsArrayTest.kt +++ b/libraries/stdlib/test/js/JsArrayTest.kt @@ -6,7 +6,7 @@ import java.util.ArrayList; class JsArrayTest { - test fun arraySizeAndToList() { + @test fun arraySizeAndToList() { val a1 = arrayOf() val a2 = arrayOf("foo") val a3 = arrayOf("foo", "bar") @@ -21,7 +21,7 @@ class JsArrayTest { } - test fun arrayListFromCollection() { + @test fun arrayListFromCollection() { var c: Collection = arrayOf("A", "B", "C").toList() var a = ArrayList(c) diff --git a/libraries/stdlib/test/js/JsDomTest.kt b/libraries/stdlib/test/js/JsDomTest.kt index 977926b7574..899f7175edc 100644 --- a/libraries/stdlib/test/js/JsDomTest.kt +++ b/libraries/stdlib/test/js/JsDomTest.kt @@ -9,7 +9,7 @@ import org.junit.Test as test class JsDomTest { - test fun testCreateDocument() { + @test fun testCreateDocument() { var doc = document assertNotNull(doc, "Should have created a document") @@ -25,7 +25,7 @@ class JsDomTest { assertCssClass(e, "bar") } - test fun addText() { + @test fun addText() { var doc = document assertNotNull(doc, "Should have created a document") @@ -38,7 +38,7 @@ class JsDomTest { assertEquals("hello", e.textContent) } - test fun testAddClassMissing() { + @test fun testAddClassMissing() { val e = document.createElement("e")!! assertNotNull(e) @@ -49,7 +49,7 @@ class JsDomTest { assertEquals("class1 class2", e.classes) } - test fun testAddClassPresent() { + @test fun testAddClassPresent() { val e = document.createElement("e")!! assertNotNull(e) @@ -60,13 +60,13 @@ class JsDomTest { assertEquals("class2 class1", e.classes) } - test fun testAddClassUndefinedClasses() { + @test fun testAddClassUndefinedClasses() { val e = document.createElement("e")!! e.addClass("class1") assertEquals("class1", e.classes) } - test fun testRemoveClassMissing() { + @test fun testRemoveClassMissing() { val e = document.createElement("e")!! assertNotNull(e) @@ -77,7 +77,7 @@ class JsDomTest { assertEquals("class2 class1", e.classes) } - test fun testRemoveClassPresent1() { + @test fun testRemoveClassPresent1() { val e = document.createElement("e")!! assertNotNull(e) @@ -88,7 +88,7 @@ class JsDomTest { assertEquals("class1", e.classes) } - test fun testRemoveClassPresent2() { + @test fun testRemoveClassPresent2() { val e = document.createElement("e")!! assertNotNull(e) @@ -99,7 +99,7 @@ class JsDomTest { assertEquals("class2", e.classes) } - test fun testRemoveClassPresent3() { + @test fun testRemoveClassPresent3() { val e = document.createElement("e")!! assertNotNull(e) @@ -110,13 +110,13 @@ class JsDomTest { assertEquals("class2 class3", e.classes) } - test fun testRemoveClassUndefinedClasses() { + @test fun testRemoveClassUndefinedClasses() { val e = document.createElement("e")!! e.removeClass("class1") assertEquals("", e.classes) } - test fun testRemoveFromParent() { + @test fun testRemoveFromParent() { val doc = document val parent = doc.createElement("pp") @@ -135,7 +135,7 @@ class JsDomTest { assertNull(child.parentNode) } - test fun testRemoveFromParentOrphanNode() { + @test fun testRemoveFromParentOrphanNode() { val child = document.createElement("cc") child.removeFromParent() diff --git a/libraries/stdlib/test/js/MapJsTest.kt b/libraries/stdlib/test/js/MapJsTest.kt index 923860fe6a8..d16bdae0eeb 100644 --- a/libraries/stdlib/test/js/MapJsTest.kt +++ b/libraries/stdlib/test/js/MapJsTest.kt @@ -17,7 +17,7 @@ class ComplexMapJsTest : MapJsTest() { assertEquals(KEYS.toNormalizedList(), map.keySet().toNormalizedList()) assertEquals(VALUES.toNormalizedList(), map.values().toNormalizedList()) } - test override fun constructors() { + @test override fun constructors() { doTest() } @@ -28,7 +28,7 @@ class ComplexMapJsTest : MapJsTest() { } class PrimitiveMapJsTest : MapJsTest() { - test override fun constructors() { + @test override fun constructors() { HashMap() HashMap(3) HashMap(3, 0.5f) @@ -43,7 +43,7 @@ class PrimitiveMapJsTest : MapJsTest() { override fun emptyMutableMap(): MutableMap = HashMap() override fun emptyMutableMapWithNullableKeyValue(): MutableMap = HashMap() - test fun compareBehavior() { + @test fun compareBehavior() { val specialJsStringMap = HashMap() specialJsStringMap.put("k1", "v1") compare(genericHashMapOf("k1" to "v1"), specialJsStringMap) { mapBehavior() } @@ -55,7 +55,7 @@ class PrimitiveMapJsTest : MapJsTest() { } class LinkedHashMapTest : MapJsTest() { - test override fun constructors() { + @test override fun constructors() { LinkedHashMap() LinkedHashMap(3) LinkedHashMap(3, 0.5f) @@ -77,7 +77,7 @@ abstract class MapJsTest { val SPECIAL_NAMES = arrayOf("__proto__", "constructor", "toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable") - test fun getOrElse() { + @test fun getOrElse() { val data = emptyMap() val a = data.getOrElse("foo"){2} assertEquals(2, a) @@ -87,7 +87,7 @@ abstract class MapJsTest { assertEquals(0, data.size()) } - test fun getOrPut() { + @test fun getOrPut() { val data = emptyMutableMap() val a = data.getOrPut("foo"){2} assertEquals(2, a) @@ -98,13 +98,13 @@ abstract class MapJsTest { assertEquals(1, data.size()) } - test fun emptyMapGet() { + @test fun emptyMapGet() { val map = emptyMap() assertEquals(null, map.get("foo"), """failed on map.get("foo")""") assertEquals(null, map["bar"], """failed on map["bar"]""") } - test fun mapGet() { + @test fun mapGet() { val map = createTestMap() for (i in KEYS.indices) { assertEquals(VALUES[i], map.get(KEYS[i]), """failed on map.get(KEYS[$i])""") @@ -114,7 +114,7 @@ abstract class MapJsTest { assertEquals(null, map.get("foo")) } - test fun mapPut() { + @test fun mapPut() { val map = emptyMutableMap() map.put("foo", 1) @@ -130,7 +130,7 @@ abstract class MapJsTest { assertEquals(2, map["bar"]) } - test fun sizeAndEmptyForEmptyMap() { + @test fun sizeAndEmptyForEmptyMap() { val data = emptyMap() assertTrue(data.isEmpty()) @@ -140,7 +140,7 @@ abstract class MapJsTest { assertEquals(0, data.size()) } - test fun sizeAndEmpty() { + @test fun sizeAndEmpty() { val data = createTestMap() assertFalse(data.isEmpty()) @@ -150,22 +150,22 @@ abstract class MapJsTest { } // #KT-3035 - test fun emptyMapValues() { + @test fun emptyMapValues() { val emptyMap = emptyMap() assertTrue(emptyMap.values().isEmpty()) } - test fun mapValues() { + @test fun mapValues() { val map = createTestMap() assertEquals(VALUES.toNormalizedList(), map.values().toNormalizedList()) } - test fun mapKeySet() { + @test fun mapKeySet() { val map = createTestMap() assertEquals(KEYS.toNormalizedList(), map.keySet().toNormalizedList()) } - test fun mapEntrySet() { + @test fun mapEntrySet() { val map = createTestMap() val actualKeys = ArrayList() @@ -179,7 +179,7 @@ abstract class MapJsTest { assertEquals(VALUES.toNormalizedList(), actualValues.toNormalizedList()) } - test fun mapContainsKey() { + @test fun mapContainsKey() { val map = createTestMap() assertTrue(map.containsKey(KEYS[0]) && @@ -191,7 +191,7 @@ abstract class MapJsTest { map.containsKey(1)) } - test fun mapContainsValue() { + @test fun mapContainsValue() { val map = createTestMap() assertTrue(map.containsValue(VALUES[0]) && @@ -203,14 +203,14 @@ abstract class MapJsTest { map.containsValue(5)) } - test fun mapPutAll() { + @test fun mapPutAll() { val map = createTestMap() val newMap = emptyMutableMap() newMap.putAll(map) assertEquals(KEYS.size(), newMap.size()) } - test fun mapRemove() { + @test fun mapRemove() { val map = createTestMutableMap() val last = KEYS.size() - 1 val first = 0 @@ -227,14 +227,14 @@ abstract class MapJsTest { assertEquals(KEYS.size() - 3, map.size()) } - test fun mapClear() { + @test fun mapClear() { val map = createTestMutableMap() assertFalse(map.isEmpty()) map.clear() assertTrue(map.isEmpty()) } - test fun nullAsKey() { + @test fun nullAsKey() { val map = emptyMutableMapWithNullableKeyValue() assertTrue(map.isEmpty()) @@ -247,7 +247,7 @@ abstract class MapJsTest { assertEquals(null, map[null]) } - test fun nullAsValue() { + @test fun nullAsValue() { val map = emptyMutableMapWithNullableKeyValue() val KEY = "Key" @@ -260,7 +260,7 @@ abstract class MapJsTest { assertTrue(map.isEmpty()) } - test fun setViaIndexOperators() { + @test fun setViaIndexOperators() { val map = HashMap() assertTrue{ map.isEmpty() } assertEquals(map.size(), 0) @@ -272,21 +272,21 @@ abstract class MapJsTest { assertEquals("James", map["name"]) } - test fun createUsingPairs() { + @test fun createUsingPairs() { val map = mapOf(Pair("a", 1), Pair("b", 2)) assertEquals(2, map.size()) assertEquals(1, map.get("a")) assertEquals(2, map.get("b")) } - test fun createUsingTo() { + @test fun createUsingTo() { val map = mapOf("a" to 1, "b" to 2) assertEquals(2, map.size()) assertEquals(1, map.get("a")) assertEquals(2, map.get("b")) } - test fun mapIteratorImplicitly() { + @test fun mapIteratorImplicitly() { val map = createTestMap() val actualKeys = ArrayList() @@ -300,7 +300,7 @@ abstract class MapJsTest { assertEquals(VALUES.toNormalizedList(), actualValues.toNormalizedList()) } - test fun mapIteratorExplicitly() { + @test fun mapIteratorExplicitly() { val map = createTestMap() val actualKeys = ArrayList() @@ -315,7 +315,7 @@ abstract class MapJsTest { assertEquals(VALUES.toNormalizedList(), actualValues.toNormalizedList()) } - test fun specialNamesNotContainsInEmptyMap() { + @test fun specialNamesNotContainsInEmptyMap() { val map = emptyMap() for (key in SPECIAL_NAMES) { @@ -323,7 +323,7 @@ abstract class MapJsTest { } } - test fun specialNamesNotContainsInNonEmptyMap() { + @test fun specialNamesNotContainsInNonEmptyMap() { val map = createTestMap() for (key in SPECIAL_NAMES) { @@ -331,7 +331,7 @@ abstract class MapJsTest { } } - test fun putAndGetSpecialNamesToMap() { + @test fun putAndGetSpecialNamesToMap() { val map = createTestMutableMap() var value = 0 @@ -351,7 +351,7 @@ abstract class MapJsTest { } } - test abstract fun constructors() + @test abstract fun constructors() /* test fun createLinkedMap() { diff --git a/libraries/stdlib/test/js/SetJsTest.kt b/libraries/stdlib/test/js/SetJsTest.kt index 6acb7c3886f..aa516f5646c 100644 --- a/libraries/stdlib/test/js/SetJsTest.kt +++ b/libraries/stdlib/test/js/SetJsTest.kt @@ -18,7 +18,8 @@ class ComplexSetJsTest : SetJsTest() { assertEquals(data, set) } - Test override fun constructors() { + @Test + override fun constructors() { doTest() } @@ -32,7 +33,8 @@ class ComplexSetJsTest : SetJsTest() { class PrimitiveSetJsTest : SetJsTest() { override fun createEmptyMutableSet(): MutableSet = HashSet() override fun createEmptyMutableSetWithNullableValues(): MutableSet = HashSet() - Test override fun constructors() { + @Test + override fun constructors() { HashSet() HashSet(3) HashSet(3, 0.5f) @@ -42,7 +44,8 @@ class PrimitiveSetJsTest : SetJsTest() { assertEquals(data, set) } - Test fun compareBehavior() { + @Test + fun compareBehavior() { val specialJsStringSet = HashSet() specialJsStringSet.add("kotlin") compare(genericHashSetOf("kotlin"), specialJsStringSet) { setBehavior() } @@ -57,7 +60,8 @@ class PrimitiveSetJsTest : SetJsTest() { class LinkedHashSetJsTest : SetJsTest() { override fun createEmptyMutableSet(): MutableSet = LinkedHashSet() override fun createEmptyMutableSetWithNullableValues(): MutableSet = LinkedHashSet() - Test override fun constructors() { + @Test + override fun constructors() { LinkedHashSet() LinkedHashSet(3) LinkedHashSet(3, 0.5f) @@ -74,24 +78,28 @@ abstract class SetJsTest { val SPECIAL_NAMES = arrayOf("__proto__", "constructor", "toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable") - Test fun size() { + @Test + fun size() { assertEquals(2, data.size()) assertEquals(0, empty.size()) } - Test fun isEmpty() { + @Test + fun isEmpty() { assertFalse(data.isEmpty()) assertTrue(empty.isEmpty()) } - Test fun equals() { + @Test + fun equals() { assertNotEquals(createEmptyMutableSet(), data) assertNotEquals(data, empty) assertEquals(createEmptyMutableSet(), empty) assertEquals(createTestMutableSetReversed(), data) } - Test fun contains() { + @Test + fun contains() { assertTrue(data.contains("foo")) assertTrue(data.contains("bar")) assertFalse(data.contains("baz")) @@ -102,7 +110,8 @@ abstract class SetJsTest { assertFalse(empty.contains(1)) } - Test fun iterator() { + @Test + fun iterator() { var result = "" for (e in data) { result += e @@ -111,14 +120,16 @@ abstract class SetJsTest { assertTrue(result == "foobar" || result == "barfoo") } - Test fun containsAll() { + @Test + fun containsAll() { assertTrue(data.containsAll(arrayListOf("foo", "bar"))) assertTrue(data.containsAll(arrayListOf())) assertFalse(data.containsAll(arrayListOf("foo", "bar", "baz"))) assertFalse(data.containsAll(arrayListOf("baz"))) } - Test fun add() { + @Test + fun add() { val data = createTestMutableSet() assertTrue(data.add("baz")) assertEquals(3, data.size()) @@ -127,7 +138,8 @@ abstract class SetJsTest { assertTrue(data.containsAll(arrayListOf("foo", "bar", "baz"))) } - Test fun remove() { + @Test + fun remove() { val data = createTestMutableSet() assertTrue(data.remove("foo")) assertEquals(1, data.size()) @@ -136,7 +148,8 @@ abstract class SetJsTest { assertTrue(data.contains("bar")) } - Test fun addAll() { + @Test + fun addAll() { val data = createTestMutableSet() assertTrue(data.addAll(arrayListOf("foo", "bar", "baz", "boo"))) assertEquals(4, data.size()) @@ -145,7 +158,8 @@ abstract class SetJsTest { assertTrue(data.containsAll(arrayListOf("foo", "bar", "baz", "boo"))) } - Test fun removeAll() { + @Test + fun removeAll() { val data = createTestMutableSet() assertFalse(data.removeAll(arrayListOf("baz"))) assertTrue(data.containsAll(arrayListOf("foo", "bar"))) @@ -161,7 +175,8 @@ abstract class SetJsTest { assertTrue(data.isEmpty()) } - Test fun retainAll() { + @Test + fun retainAll() { val data1 = createTestMutableSet() assertTrue(data1.retainAll(arrayListOf("baz"))) assertTrue(data1.isEmpty()) @@ -172,7 +187,8 @@ abstract class SetJsTest { assertEquals(1, data2.size()) } - Test fun clear() { + @Test + fun clear() { val data = createTestMutableSet() data.clear() assertTrue(data.isEmpty()) @@ -181,19 +197,22 @@ abstract class SetJsTest { assertTrue(data.isEmpty()) } - Test fun specialNamesNotContainsInEmptySet() { + @Test + fun specialNamesNotContainsInEmptySet() { for (element in SPECIAL_NAMES) { assertFalse(empty.contains(element), "unexpected element: $element") } } - Test fun specialNamesNotContainsInNonEmptySet() { + @Test + fun specialNamesNotContainsInNonEmptySet() { for (element in SPECIAL_NAMES) { assertFalse(data.contains(element), "unexpected element: $element") } } - Test fun putAndGetSpecialNamesToSet() { + @Test + fun putAndGetSpecialNamesToSet() { val s = createTestMutableSet() for (element in SPECIAL_NAMES) { @@ -209,7 +228,8 @@ abstract class SetJsTest { abstract fun constructors() - Test fun nullAsValue() { + @Test + fun nullAsValue() { val set = createEmptyMutableSetWithNullableValues() assertTrue(set.isEmpty(), "Set should be empty") diff --git a/libraries/stdlib/test/js/SimpleTest.kt b/libraries/stdlib/test/js/SimpleTest.kt index 9fd68c1d805..dfed65de5cd 100644 --- a/libraries/stdlib/test/js/SimpleTest.kt +++ b/libraries/stdlib/test/js/SimpleTest.kt @@ -11,7 +11,7 @@ class SimpleTest { assertEquals("hello world!", message) } - test fun cheese() { + @test fun cheese() { val name = "world" val message = "bye $name!" assertEquals("bye world!", message) diff --git a/libraries/stdlib/test/js/javautilCollectionsTest.kt b/libraries/stdlib/test/js/javautilCollectionsTest.kt index 500f15e4ef6..72360e8e060 100644 --- a/libraries/stdlib/test/js/javautilCollectionsTest.kt +++ b/libraries/stdlib/test/js/javautilCollectionsTest.kt @@ -14,23 +14,23 @@ class JavautilCollectionsTest { val MAX_ELEMENT = 9 val COMPARATOR = comparator { x: Int, y: Int -> if (x > y) 1 else if (x < y) -1 else 0 } - test fun maxWithComparator() { + @test fun maxWithComparator() { assertEquals(MAX_ELEMENT, Collections.max(TEST_LIST, COMPARATOR)) } - test fun sort() { + @test fun sort() { val list = TEST_LIST.toArrayList() Collections.sort(list) assertEquals(SORTED_TEST_LIST, list) } - test fun sortWithComparator() { + @test fun sortWithComparator() { val list = TEST_LIST.toArrayList() Collections.sort(list, COMPARATOR) assertEquals(SORTED_TEST_LIST, list) } - test fun collectionToArray() { + @test fun collectionToArray() { val array = TEST_LIST.toTypedArray() assertEquals(array.toList(), TEST_LIST) } diff --git a/libraries/stdlib/test/language/BitwiseOperationsTest.kt b/libraries/stdlib/test/language/BitwiseOperationsTest.kt index 6f2d976e3d1..544fc6c53bc 100644 --- a/libraries/stdlib/test/language/BitwiseOperationsTest.kt +++ b/libraries/stdlib/test/language/BitwiseOperationsTest.kt @@ -4,31 +4,31 @@ import kotlin.test.* import org.junit.Test as test class BitwiseOperationsTest { - test fun orForInt() { + @test fun orForInt() { assertEquals(3, 2 or 1) } - test fun andForInt() { + @test fun andForInt() { assertEquals(0, 1 and 0) } - test fun xorForInt() { + @test fun xorForInt() { assertEquals(1, 2 xor 3) } - test fun shlForInt() { + @test fun shlForInt() { assertEquals(4, 1 shl 2) } - test fun shrForInt() { + @test fun shrForInt() { assertEquals(1, 2 shr 1) } - test fun ushrForInt() { + @test fun ushrForInt() { assertEquals(2147483647, -1 ushr 1) } - test fun invForInt() { + @test fun invForInt() { assertEquals(0, (-1).inv()) } } \ No newline at end of file diff --git a/libraries/stdlib/test/language/RangeIterationJVMTest.kt b/libraries/stdlib/test/language/RangeIterationJVMTest.kt index 13886cebb69..72c4675e720 100644 --- a/libraries/stdlib/test/language/RangeIterationJVMTest.kt +++ b/libraries/stdlib/test/language/RangeIterationJVMTest.kt @@ -34,7 +34,7 @@ public class RangeIterationJVMTest { assertEquals(expectedElements, sequence.toList()) } - test fun infiniteSteps() { + @test fun infiniteSteps() { doTest(0.0..5.0 step j.Double.POSITIVE_INFINITY, 0.0, 5.0, j.Double.POSITIVE_INFINITY, listOf(0.0)) doTest(0.0.toFloat()..5.0.toFloat() step j.Float.POSITIVE_INFINITY, 0.0.toFloat(), 5.0.toFloat(), j.Float.POSITIVE_INFINITY, listOf(0.0.toFloat())) @@ -43,7 +43,7 @@ public class RangeIterationJVMTest { listOf(5.0.toFloat())) } - test fun nanEnds() { + @test fun nanEnds() { doTest(j.Double.NaN..5.0, j.Double.NaN, 5.0, 1.0, listOf()) doTest(j.Float.NaN.toFloat()..5.0.toFloat(), j.Float.NaN, 5.0.toFloat(), 1.0.toFloat(), listOf()) doTest(j.Double.NaN downTo 0.0, j.Double.NaN, 0.0, -1.0, listOf()) @@ -60,7 +60,7 @@ public class RangeIterationJVMTest { doTest(j.Float.NaN downTo j.Float.NaN, j.Float.NaN, j.Float.NaN, -1.0.toFloat(), listOf()) } - test fun maxValueToMaxValue() { + @test fun maxValueToMaxValue() { doTest(MaxI..MaxI, MaxI, MaxI, 1, listOf(MaxI)) doTest(MaxB..MaxB, MaxB, MaxB, 1, listOf(MaxB)) doTest(MaxS..MaxS, MaxS, MaxS, 1, listOf(MaxS)) @@ -69,7 +69,7 @@ public class RangeIterationJVMTest { doTest(MaxC..MaxC, MaxC, MaxC, 1, listOf(MaxC)) } - test fun maxValueMinusTwoToMaxValue() { + @test fun maxValueMinusTwoToMaxValue() { doTest((MaxI - 2)..MaxI, MaxI - 2, MaxI, 1, listOf(MaxI - 2, MaxI - 1, MaxI)) doTest((MaxB - 2).toByte()..MaxB, (MaxB - 2).toByte(), MaxB, 1, listOf((MaxB - 2).toByte(), (MaxB - 1).toByte(), MaxB)) doTest((MaxS - 2).toShort()..MaxS, (MaxS - 2).toShort(), MaxS, 1, listOf((MaxS - 2).toShort(), (MaxS - 1).toShort(), MaxS)) @@ -78,7 +78,7 @@ public class RangeIterationJVMTest { doTest((MaxC - 2)..MaxC, (MaxC - 2), MaxC, 1, listOf((MaxC - 2), (MaxC - 1), MaxC)) } - test fun maxValueToMinValue() { + @test fun maxValueToMinValue() { doTest(MaxI..MinI, MaxI, MinI, 1, listOf()) doTest(MaxB..MinB, MaxB, MinB, 1, listOf()) doTest(MaxS..MinS, MaxS, MinS, 1, listOf()) @@ -87,7 +87,7 @@ public class RangeIterationJVMTest { doTest(MaxC..MinC, MaxC, MinC, 1, listOf()) } - test fun progressionMaxValueToMaxValue() { + @test fun progressionMaxValueToMaxValue() { doTest(MaxI..MaxI step 1, MaxI, MaxI, 1, listOf(MaxI)) doTest(MaxB..MaxB step 1, MaxB, MaxB, 1, listOf(MaxB)) doTest(MaxS..MaxS step 1, MaxS, MaxS, 1, listOf(MaxS)) @@ -96,7 +96,7 @@ public class RangeIterationJVMTest { doTest(MaxC..MaxC step 1, MaxC, MaxC, 1, listOf(MaxC)) } - test fun progressionMaxValueMinusTwoToMaxValue() { + @test fun progressionMaxValueMinusTwoToMaxValue() { doTest((MaxI - 2)..MaxI step 2, MaxI - 2, MaxI, 2, listOf(MaxI - 2, MaxI)) doTest((MaxB - 2).toByte()..MaxB step 2, (MaxB - 2).toByte(), MaxB, 2, listOf((MaxB - 2).toByte(), MaxB)) doTest((MaxS - 2).toShort()..MaxS step 2, (MaxS - 2).toShort(), MaxS, 2, listOf((MaxS - 2).toShort(), MaxS)) @@ -105,7 +105,7 @@ public class RangeIterationJVMTest { doTest((MaxC - 2)..MaxC step 2, (MaxC - 2), MaxC, 2, listOf((MaxC - 2), MaxC)) } - test fun progressionMaxValueToMinValue() { + @test fun progressionMaxValueToMinValue() { doTest(MaxI..MinI step 1, MaxI, MinI, 1, listOf()) doTest(MaxB..MinB step 1, MaxB, MinB, 1, listOf()) doTest(MaxS..MinS step 1, MaxS, MinS, 1, listOf()) @@ -114,7 +114,7 @@ public class RangeIterationJVMTest { doTest(MaxC..MinC step 1, MaxC, MinC, 1, listOf()) } - test fun progressionMinValueToMinValue() { + @test fun progressionMinValueToMinValue() { doTest(MinI..MinI step 1, MinI, MinI, 1, listOf(MinI)) doTest(MinB..MinB step 1, MinB, MinB, 1, listOf(MinB)) doTest(MinS..MinS step 1, MinS, MinS, 1, listOf(MinS)) @@ -123,7 +123,7 @@ public class RangeIterationJVMTest { doTest(MinC..MinC step 1, MinC, MinC, 1, listOf(MinC)) } - test fun inexactToMaxValue() { + @test fun inexactToMaxValue() { doTest((MaxI - 5)..MaxI step 3, MaxI - 5, MaxI, 3, listOf(MaxI - 5, MaxI - 2)) doTest((MaxB - 5).toByte()..MaxB step 3, (MaxB - 5).toByte(), MaxB, 3, listOf((MaxB - 5).toByte(), (MaxB - 2).toByte())) doTest((MaxS - 5).toShort()..MaxS step 3, (MaxS - 5).toShort(), MaxS, 3, listOf((MaxS - 5).toShort(), (MaxS - 2).toShort())) @@ -132,7 +132,7 @@ public class RangeIterationJVMTest { doTest((MaxC - 5)..MaxC step 3, (MaxC - 5), MaxC, 3, listOf((MaxC - 5), (MaxC - 2))) } - test fun progressionDownToMinValue() { + @test fun progressionDownToMinValue() { doTest((MinI + 2) downTo MinI step 1, MinI + 2, MinI, -1, listOf(MinI + 2, MinI + 1, MinI)) doTest((MinB + 2).toByte() downTo MinB step 1, (MinB + 2).toByte(), MinB, -1, listOf((MinB + 2).toByte(), (MinB + 1).toByte(), MinB)) doTest((MinS + 2).toShort() downTo MinS step 1, (MinS + 2).toShort(), MinS, -1, listOf((MinS + 2).toShort(), (MinS + 1).toShort(), MinS)) @@ -141,7 +141,7 @@ public class RangeIterationJVMTest { doTest((MinC + 2) downTo MinC step 1, (MinC + 2), MinC, -1, listOf((MinC + 2), (MinC + 1), MinC)) } - test fun inexactDownToMinValue() { + @test fun inexactDownToMinValue() { doTest((MinI + 5) downTo MinI step 3, MinI + 5, MinI, -3, listOf(MinI + 5, MinI + 2)) doTest((MinB + 5).toByte() downTo MinB step 3, (MinB + 5).toByte(), MinB, -3, listOf((MinB + 5).toByte(), (MinB + 2).toByte())) doTest((MinS + 5).toShort() downTo MinS step 3, (MinS + 5).toShort(), MinS, -3, listOf((MinS + 5).toShort(), (MinS + 2).toShort())) diff --git a/libraries/stdlib/test/language/RangeIterationTest.kt b/libraries/stdlib/test/language/RangeIterationTest.kt index a963799a312..875f7d0a2c2 100644 --- a/libraries/stdlib/test/language/RangeIterationTest.kt +++ b/libraries/stdlib/test/language/RangeIterationTest.kt @@ -22,7 +22,7 @@ public class RangeIterationTest { assertEquals(expectedElements, sequence.toList()) } - test fun emptyConstant() { + @test fun emptyConstant() { doTest(IntRange.EMPTY, 1, 0, 1, listOf()) doTest(ByteRange.EMPTY, 1.toByte(), 0.toByte(), 1, listOf()) doTest(ShortRange.EMPTY, 1.toShort(), 0.toShort(), 1, listOf()) @@ -34,7 +34,7 @@ public class RangeIterationTest { doTest(FloatRange.EMPTY, 1.0.toFloat(), 0.0.toFloat(), 1.0.toFloat(), listOf()) } - test fun emptyRange() { + @test fun emptyRange() { doTest(10..5, 10, 5, 1, listOf()) doTest(10.toByte()..(-5).toByte(), 10.toByte(), (-5).toByte(), 1, listOf()) doTest(10.toShort()..(-5).toShort(), 10.toShort(), (-5).toShort(), 1, listOf()) @@ -46,7 +46,7 @@ public class RangeIterationTest { doTest(5.0.toFloat()..-1.0.toFloat(), 5.0.toFloat(), -1.0.toFloat(), 1.toFloat(), listOf()) } - test fun oneElementRange() { + @test fun oneElementRange() { doTest(5..5, 5, 5, 1, listOf(5)) doTest(5.toByte()..5.toByte(), 5.toByte(), 5.toByte(), 1, listOf(5.toByte())) doTest(5.toShort()..5.toShort(), 5.toShort(), 5.toShort(), 1, listOf(5.toShort())) @@ -58,7 +58,7 @@ public class RangeIterationTest { doTest(5.0.toFloat()..5.0.toFloat(), 5.0.toFloat(), 5.0.toFloat(), 1.toFloat(), listOf(5.0.toFloat())) } - test fun simpleRange() { + @test fun simpleRange() { doTest(3..9, 3, 9, 1, listOf(3, 4, 5, 6, 7, 8, 9)) doTest(3.toByte()..9.toByte(), 3.toByte(), 9.toByte(), 1, listOf(3, 4, 5, 6, 7, 8, 9)) doTest(3.toShort()..9.toShort(), 3.toShort(), 9.toShort(), 1, listOf(3, 4, 5, 6, 7, 8, 9)) @@ -72,7 +72,7 @@ public class RangeIterationTest { } - test fun simpleRangeWithNonConstantEnds() { + @test fun simpleRangeWithNonConstantEnds() { doTest((1 + 2)..(10 - 1), 3, 9, 1, listOf(3, 4, 5, 6, 7, 8, 9)) doTest((1.toByte() + 2.toByte()).toByte()..(10.toByte() - 1.toByte()).toByte(), 3.toByte(), 9.toByte(), 1, listOf(3, 4, 5, 6, 7, 8, 9)) doTest((1.toShort() + 2.toShort()).toShort()..(10.toShort() - 1.toShort()).toShort(), 3.toShort(), 9.toShort(), 1, listOf(3, 4, 5, 6, 7, 8, 9)) @@ -85,7 +85,7 @@ public class RangeIterationTest { listOf(3.0.toFloat(), 4.0.toFloat(), 5.0.toFloat(), 6.0.toFloat(), 7.0.toFloat(), 8.0.toFloat(), 9.0.toFloat())) } - test fun openRange() { + @test fun openRange() { doTest(1 until 5, 1, 4, 1, listOf(1, 2, 3, 4)) doTest(1.toByte() until 5.toByte(), 1.toByte(), 4.toByte(), 1, listOf(1, 2, 3, 4)) doTest(1.toShort() until 5.toShort(), 1.toShort(), 4.toShort(), 1, listOf(1, 2, 3, 4)) @@ -94,7 +94,7 @@ public class RangeIterationTest { } - test fun emptyDownto() { + @test fun emptyDownto() { doTest(5 downTo 10, 5, 10, -1, listOf()) doTest(5.toByte() downTo 10.toByte(), 5.toByte(), 10.toByte(), -1, listOf()) doTest(5.toShort() downTo 10.toShort(), 5.toShort(), 10.toShort(), -1, listOf()) @@ -106,7 +106,7 @@ public class RangeIterationTest { doTest(-1.0.toFloat() downTo 5.0.toFloat(), -1.0.toFloat(), 5.0.toFloat(), -1.0.toFloat(), listOf()) } - test fun oneElementDownTo() { + @test fun oneElementDownTo() { doTest(5 downTo 5, 5, 5, -1, listOf(5)) doTest(5.toByte() downTo 5.toByte(), 5.toByte(), 5.toByte(), -1, listOf(5.toByte())) doTest(5.toShort() downTo 5.toShort(), 5.toShort(), 5.toShort(), -1, listOf(5.toShort())) @@ -118,7 +118,7 @@ public class RangeIterationTest { doTest(5.0.toFloat() downTo 5.0.toFloat(), 5.0.toFloat(), 5.0.toFloat(), -1.0.toFloat(), listOf(5.0.toFloat())) } - test fun simpleDownTo() { + @test fun simpleDownTo() { doTest(9 downTo 3, 9, 3, -1, listOf(9, 8, 7, 6, 5, 4, 3)) doTest(9.toByte() downTo 3.toByte(), 9.toByte(), 3.toByte(), -1, listOf(9, 8, 7, 6, 5, 4, 3)) doTest(9.toShort() downTo 3.toShort(), 9.toShort(), 3.toShort(), -1, listOf(9, 8, 7, 6, 5, 4, 3)) @@ -132,7 +132,7 @@ public class RangeIterationTest { } - test fun simpleSteppedRange() { + @test fun simpleSteppedRange() { doTest(3..9 step 2, 3, 9, 2, listOf(3, 5, 7, 9)) doTest(3.toByte()..9.toByte() step 2, 3.toByte(), 9.toByte(), 2, listOf(3, 5, 7, 9)) doTest(3.toShort()..9.toShort() step 2, 3.toShort(), 9.toShort(), 2, listOf(3, 5, 7, 9)) @@ -145,7 +145,7 @@ public class RangeIterationTest { listOf(4.0.toFloat(), 4.5.toFloat(), 5.0.toFloat(), 5.5.toFloat(), 6.0.toFloat())) } - test fun simpleSteppedDownTo() { + @test fun simpleSteppedDownTo() { doTest(9 downTo 3 step 2, 9, 3, -2, listOf(9, 7, 5, 3)) doTest(9.toByte() downTo 3.toByte() step 2, 9.toByte(), 3.toByte(), -2, listOf(9, 7, 5, 3)) doTest(9.toShort() downTo 3.toShort() step 2, 9.toShort(), 3.toShort(), -2, listOf(9, 7, 5, 3)) @@ -160,7 +160,7 @@ public class RangeIterationTest { // 'inexact' means last element is not equal to sequence end - test fun inexactSteppedRange() { + @test fun inexactSteppedRange() { doTest(3..8 step 2, 3, 8, 2, listOf(3, 5, 7)) doTest(3.toByte()..8.toByte() step 2, 3.toByte(), 8.toByte(), 2, listOf(3, 5, 7)) doTest(3.toShort()..8.toShort() step 2, 3.toShort(), 8.toShort(), 2, listOf(3, 5, 7)) @@ -174,7 +174,7 @@ public class RangeIterationTest { } // 'inexact' means last element is not equal to sequence end - test fun inexactSteppedDownTo() { + @test fun inexactSteppedDownTo() { doTest(8 downTo 3 step 2, 8, 3, -2, listOf(8, 6, 4)) doTest(8.toByte() downTo 3.toByte() step 2, 8.toByte(), 3.toByte(), -2, listOf(8, 6, 4)) doTest(8.toShort() downTo 3.toShort() step 2, 8.toShort(), 3.toShort(), -2, listOf(8, 6, 4)) @@ -188,7 +188,7 @@ public class RangeIterationTest { } - test fun reversedEmptyRange() { + @test fun reversedEmptyRange() { doTest((5..3).reversed(), 3, 5, -1, listOf()) doTest((5.toByte()..3.toByte()).reversed(), 3.toByte(), 5.toByte(), -1, listOf()) doTest((5.toShort()..3.toShort()).reversed(), 3.toShort(), 5.toShort(), -1, listOf()) @@ -200,7 +200,7 @@ public class RangeIterationTest { doTest((5.0.toFloat()..3.0.toFloat()).reversed(), 3.0.toFloat(), 5.0.toFloat(), -1.toFloat(), listOf()) } - test fun reversedEmptyBackSequence() { + @test fun reversedEmptyBackSequence() { doTest((3 downTo 5).reversed(), 5, 3, 1, listOf()) doTest((3.toByte() downTo 5.toByte()).reversed(), 5.toByte(), 3.toByte(), 1, listOf()) doTest((3.toShort() downTo 5.toShort()).reversed(), 5.toShort(), 3.toShort(), 1, listOf()) @@ -212,7 +212,7 @@ public class RangeIterationTest { doTest((3.0.toFloat() downTo 5.0.toFloat()).reversed(), 5.0.toFloat(), 3.0.toFloat(), 1.toFloat(), listOf()) } - test fun reversedRange() { + @test fun reversedRange() { doTest((3..5).reversed(), 5, 3, -1, listOf(5, 4, 3)) doTest((3.toByte()..5.toByte()).reversed(), 5.toByte(), 3.toByte(), -1, listOf(5, 4, 3)) doTest((3.toShort()..5.toShort()).reversed(), 5.toShort(), 3.toShort(), -1, listOf(5, 4, 3)) @@ -225,7 +225,7 @@ public class RangeIterationTest { listOf(5.0.toFloat(), 4.0.toFloat(), 3.0.toFloat())) } - test fun reversedBackSequence() { + @test fun reversedBackSequence() { doTest((5 downTo 3).reversed(), 3, 5, 1, listOf(3, 4, 5)) doTest((5.toByte() downTo 3.toByte()).reversed(), 3.toByte(), 5.toByte(), 1, listOf(3, 4, 5)) doTest((5.toShort() downTo 3.toShort()).reversed(), 3.toShort(), 5.toShort(), 1, listOf(3, 4, 5)) @@ -238,7 +238,7 @@ public class RangeIterationTest { listOf(3.0.toFloat(), 4.0.toFloat(), 5.0.toFloat())) } - test fun reversedSimpleSteppedRange() { + @test fun reversedSimpleSteppedRange() { doTest((3..9 step 2).reversed(), 9, 3, -2, listOf(9, 7, 5, 3)) doTest((3.toByte()..9.toByte() step 2).reversed(), 9.toByte(), 3.toByte(), -2, listOf(9, 7, 5, 3)) doTest((3.toShort()..9.toShort() step 2).reversed(), 9.toShort(), 3.toShort(), -2, listOf(9, 7, 5, 3)) @@ -252,7 +252,7 @@ public class RangeIterationTest { } // 'inexact' means last element is not equal to sequence end - test fun reversedInexactSteppedDownTo() { + @test fun reversedInexactSteppedDownTo() { doTest((8 downTo 3 step 2).reversed(), 3, 8, 2, listOf(3, 5, 7)) doTest((8.toByte() downTo 3.toByte() step 2).reversed(), 3.toByte(), 8.toByte(), 2, listOf(3, 5, 7)) doTest((8.toShort() downTo 3.toShort() step 2).reversed(), 3.toShort(), 8.toShort(), 2, listOf(3, 5, 7)) diff --git a/libraries/stdlib/test/language/RangeJVMTest.kt b/libraries/stdlib/test/language/RangeJVMTest.kt index ffb991f3271..287ab6612af 100644 --- a/libraries/stdlib/test/language/RangeJVMTest.kt +++ b/libraries/stdlib/test/language/RangeJVMTest.kt @@ -7,14 +7,14 @@ import kotlin.test.* public class RangeJVMTest { - test fun doubleRange() { + @test fun doubleRange() { val range = -1.0..3.14159265358979 assertFalse(jDouble.NEGATIVE_INFINITY in range) assertFalse(jDouble.POSITIVE_INFINITY in range) assertFalse(jDouble.NaN in range) } - test fun floatRange() { + @test fun floatRange() { val range = -1.0f..3.14159f assertFalse(jFloat.NEGATIVE_INFINITY in range) assertFalse(jFloat.POSITIVE_INFINITY in range) @@ -22,7 +22,7 @@ public class RangeJVMTest { assertFalse(jFloat.NaN in range) } - test fun illegalProgressionCreation() { + @test fun illegalProgressionCreation() { fun assertFailsWithIllegalArgument(f: () -> Unit) = assertFailsWith(IllegalArgumentException::class, block = f) // create Progression explicitly with increment = 0 assertFailsWithIllegalArgument { IntProgression(0, 5, 0) } diff --git a/libraries/stdlib/test/language/RangeTest.kt b/libraries/stdlib/test/language/RangeTest.kt index cb1816f2028..0a428b1c96f 100644 --- a/libraries/stdlib/test/language/RangeTest.kt +++ b/libraries/stdlib/test/language/RangeTest.kt @@ -4,7 +4,7 @@ import kotlin.test.* import org.junit.Test as test public class RangeTest { - test fun intRange() { + @test fun intRange() { val range = -5..9 assertFalse(-1000 in range) assertFalse(-6 in range) @@ -36,7 +36,7 @@ public class RangeTest { assertTrue(fails { 1 until Int.MIN_VALUE } is IllegalArgumentException) } - test fun byteRange() { + @test fun byteRange() { val range = (-5).toByte()..9.toByte() assertFalse((-100).toByte() in range) assertFalse((-6).toByte() in range) @@ -70,7 +70,7 @@ public class RangeTest { } - test fun shortRange() { + @test fun shortRange() { val range = (-5).toShort()..9.toShort() assertFalse((-1000).toShort() in range) assertFalse((-6).toShort() in range) @@ -102,7 +102,7 @@ public class RangeTest { assertTrue(fails { 0.toShort() until Short.MIN_VALUE } is IllegalArgumentException) } - test fun longRange() { + @test fun longRange() { val range = -5L..9L assertFalse(-10000000L in range) assertFalse(-6L in range) @@ -135,7 +135,7 @@ public class RangeTest { } - test fun charRange() { + @test fun charRange() { val range = 'c'..'w' assertFalse('0' in range) assertFalse('b' in range) @@ -159,7 +159,7 @@ public class RangeTest { assertTrue(fails { 'A' until '\u0000' } is IllegalArgumentException) } - test fun doubleRange() { + @test fun doubleRange() { val range = -1.0..3.14159265358979 assertFalse(-1e200 in range) assertFalse(-100.0 in range) @@ -185,7 +185,7 @@ public class RangeTest { assertTrue(1.toFloat() in range) } - test fun floatRange() { + @test fun floatRange() { val range = -1.0f..3.14159f assertFalse(-1e30f in range) assertFalse(-100.0f in range) @@ -213,7 +213,7 @@ public class RangeTest { assertFalse(Double.MAX_VALUE in range) } - test fun isEmpty() { + @test fun isEmpty() { assertTrue((2..1).isEmpty()) assertTrue((2L..0L).isEmpty()) assertTrue((1.toShort()..-1.toShort()).isEmpty()) @@ -232,7 +232,7 @@ public class RangeTest { assertTrue(("range".."progression").isEmpty()) } - test fun emptyEquals() { + @test fun emptyEquals() { assertTrue(IntRange.EMPTY == IntRange.EMPTY) assertEquals(IntRange.EMPTY, IntRange.EMPTY) assertEquals(0L..42L, 0L..42L) @@ -259,7 +259,7 @@ public class RangeTest { assertFalse(("aa".."bb") == ("aaa".."bbb")) } - test fun emptyHashCode() { + @test fun emptyHashCode() { assertEquals((0..42).hashCode(), (0..42).hashCode()) assertEquals((1.23..4.56).hashCode(), (1.23..4.56).hashCode()) @@ -279,7 +279,7 @@ public class RangeTest { assertEquals(("range".."progression").hashCode(), ("hashcode".."equals").hashCode()) } - test fun comparableRange() { + @test fun comparableRange() { val range = "island".."isle" assertFalse("apple" in range) assertFalse("icicle" in range) diff --git a/libraries/stdlib/test/language/StringExpressionExampleTest.kt b/libraries/stdlib/test/language/StringExpressionExampleTest.kt index 4d2d68fdd73..58d78882408 100644 --- a/libraries/stdlib/test/language/StringExpressionExampleTest.kt +++ b/libraries/stdlib/test/language/StringExpressionExampleTest.kt @@ -41,7 +41,7 @@ val EXPECTED = """ class StringExpressionExampleTest { val customer = Customer("James", arrayListOf(Product("Beer", 1.99), Product("Wine", 5.99))) - test fun testExpressions(): Unit { + @test fun testExpressions(): Unit { assertEquals(EXPECTED, customerTemplate(customer)) } } \ No newline at end of file diff --git a/libraries/stdlib/test/numbers/CoercionTest.kt b/libraries/stdlib/test/numbers/CoercionTest.kt index 7c9368d8f80..c8ee596a606 100644 --- a/libraries/stdlib/test/numbers/CoercionTest.kt +++ b/libraries/stdlib/test/numbers/CoercionTest.kt @@ -17,7 +17,8 @@ class CoercionTest { val n3 = n coerceIn 2..5 } - Test fun coercionsInt() { + @Test + fun coercionsInt() { expect(5) { 5.coerceAtLeast(1) } expect(5) { 1.coerceAtLeast(5) } expect(1) { 5.coerceAtMost(1) } @@ -39,7 +40,8 @@ class CoercionTest { fails { 1.coerceIn(1..0) } } - Test fun coercionsLong() { + @Test + fun coercionsLong() { expect(5L) { 5L.coerceAtLeast(1L) } expect(5L) { 1L.coerceAtLeast(5L) } expect(1L) { 5L.coerceAtMost(1L) } @@ -62,7 +64,8 @@ class CoercionTest { } - Test fun coercionsDouble() { + @Test + fun coercionsDouble() { expect(5.0) { 5.0.coerceAtLeast(1.0) } expect(5.0) { 1.0.coerceAtLeast(5.0) } expect(1.0) { 5.0.coerceAtMost(1.0) } @@ -84,7 +87,8 @@ class CoercionTest { fails { 1.0.coerceIn(1.0..0.0) } } - Test fun coercionsComparable() { + @Test + fun coercionsComparable() { val v = 0..10 map { ComparableNumber(it) } expect(5) { v[5].coerceAtLeast(v[1]).value } diff --git a/libraries/stdlib/test/numbers/NumbersTest.kt b/libraries/stdlib/test/numbers/NumbersTest.kt index c3d4eb51138..1aa3766807e 100644 --- a/libraries/stdlib/test/numbers/NumbersTest.kt +++ b/libraries/stdlib/test/numbers/NumbersTest.kt @@ -6,7 +6,7 @@ import kotlin.test.* class NumbersTest { - test fun intMinMaxValues() { + @test fun intMinMaxValues() { assertTrue(Int.MIN_VALUE < 0) assertTrue(Int.MAX_VALUE > 0) @@ -16,7 +16,7 @@ class NumbersTest { // expect(Int.MAX_VALUE) { Int.MIN_VALUE - 1 } } - test fun longMinMaxValues() { + @test fun longMinMaxValues() { assertTrue(Long.MIN_VALUE < 0) assertTrue(Long.MAX_VALUE > 0) // overflow behavior @@ -24,7 +24,7 @@ class NumbersTest { expect(Long.MAX_VALUE) { Long.MIN_VALUE - 1 } } - test fun shortMinMaxValues() { + @test fun shortMinMaxValues() { assertTrue(Short.MIN_VALUE < 0) assertTrue(Short.MAX_VALUE > 0) // overflow behavior @@ -32,7 +32,7 @@ class NumbersTest { expect(Short.MAX_VALUE) { (Short.MIN_VALUE - 1).toShort() } } - test fun byteMinMaxValues() { + @test fun byteMinMaxValues() { assertTrue(Byte.MIN_VALUE < 0) assertTrue(Byte.MAX_VALUE > 0) // overflow behavior @@ -40,7 +40,7 @@ class NumbersTest { expect(Byte.MAX_VALUE) { (Byte.MIN_VALUE - 1).toByte() } } - test fun doubleMinMaxValues() { + @test fun doubleMinMaxValues() { assertTrue(Double.MIN_VALUE > 0) assertTrue(Double.MAX_VALUE > 0) // overflow behavior @@ -49,7 +49,7 @@ class NumbersTest { expect(0.0) { Double.MIN_VALUE / 2 } } - test fun floatMinMaxValues() { + @test fun floatMinMaxValues() { assertTrue(Float.MIN_VALUE > 0) assertTrue(Float.MAX_VALUE > 0) // overflow behavior @@ -58,7 +58,7 @@ class NumbersTest { expect(0.0F) { Float.MIN_VALUE / 2.0F } } - test fun doubleProperties() { + @test fun doubleProperties() { for (value in listOf(1.0, 0.0, Double.MIN_VALUE, Double.MAX_VALUE)) doTestNumber(value) for (value in listOf(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY)) @@ -66,7 +66,7 @@ class NumbersTest { doTestNumber(Double.NaN, isNaN = true) } - test fun floatProperties() { + @test fun floatProperties() { for (value in listOf(1.0F, 0.0F, Float.MAX_VALUE, Float.MIN_VALUE)) doTestNumber(value) for (value in listOf(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY)) diff --git a/libraries/stdlib/test/properties/PropertiesTest.kt b/libraries/stdlib/test/properties/PropertiesTest.kt index cd0ae96dd2c..4b604fbd41b 100644 --- a/libraries/stdlib/test/properties/PropertiesTest.kt +++ b/libraries/stdlib/test/properties/PropertiesTest.kt @@ -35,7 +35,7 @@ class MyChangeListener : ChangeListener { class PropertiesTest { - test fun testModel() { + @test fun testModel() { val c = Customer() c.name = "James" c.city = "Mells" diff --git a/libraries/stdlib/test/properties/delegation/DelegationTest.kt b/libraries/stdlib/test/properties/delegation/DelegationTest.kt index 4930b7e8b07..f8bcd715668 100644 --- a/libraries/stdlib/test/properties/delegation/DelegationTest.kt +++ b/libraries/stdlib/test/properties/delegation/DelegationTest.kt @@ -5,7 +5,7 @@ import kotlin.test.* import kotlin.properties.* class NotNullVarTest() { - test fun doTest() { + @test fun doTest() { NotNullVarTestGeneric("a", "b").doTest() } } @@ -27,7 +27,7 @@ class ObservablePropertyInChangeSupportTest: ChangeSupport() { var b by property(init = 2) var c by property(3) - test fun doTest() { + @test fun doTest() { var result = false addChangeListener("b", object: ChangeListener { public override fun onPropertyChange(event: ChangeEvent) { @@ -54,7 +54,7 @@ class ObservablePropertyTest { assertEquals(new, b, "New value has already been set") }) - test fun doTest() { + @test fun doTest() { b = 4 assertTrue(b == 4, "fail: b != 4") assertTrue(result, "fail: result should be true") @@ -72,7 +72,7 @@ class VetoablePropertyTest { result }) - test fun doTest() { + @test fun doTest() { val firstValue = A(true) b = firstValue assertTrue(b == firstValue, "fail1: b should be firstValue = A(true)") diff --git a/libraries/stdlib/test/properties/delegation/MapAccessorsTest.kt b/libraries/stdlib/test/properties/delegation/MapAccessorsTest.kt index ebc1b72111c..276cfee5547 100644 --- a/libraries/stdlib/test/properties/delegation/MapAccessorsTest.kt +++ b/libraries/stdlib/test/properties/delegation/MapAccessorsTest.kt @@ -18,7 +18,7 @@ class ValByMapExtensionsTest { val x: Double by genericMap - test fun doTest() { + @test fun doTest() { assertEquals("all", a) assertEquals("bar", b) assertEquals("code", c) @@ -42,7 +42,7 @@ class VarByMapExtensionsTest { var a2: String by map2.withDefault { "empty" } //var x: Int by map2 // prohibited by type system - test fun doTest() { + @test fun doTest() { assertEquals("all", a) assertEquals(null, b) assertEquals(1, c) diff --git a/libraries/stdlib/test/properties/delegation/MapDelegationTest.kt b/libraries/stdlib/test/properties/delegation/MapDelegationTest.kt index 17f455f753f..4de5a6f8989 100644 --- a/libraries/stdlib/test/properties/delegation/MapDelegationTest.kt +++ b/libraries/stdlib/test/properties/delegation/MapDelegationTest.kt @@ -14,7 +14,7 @@ class MapValWithDifferentTypesTest() { val c by Delegates.mapVal(map) val d by Delegates.mapVal(map) - test fun doTest() { + @test fun doTest() { assertTrue(a == "a", "fail at 'a'") assertTrue(b == 1, "fail at 'b'") assertTrue(c == B(1), "fail at 'c'") @@ -29,7 +29,7 @@ class MapVarWithDifferentTypesTest() { var c by Delegates.mapVar(map) var d by Delegates.mapVar(map) - test fun doTest() { + @test fun doTest() { a = "aa" b = 11 c = B(11) @@ -48,7 +48,7 @@ class MapNullableKeyTest { val map = hashMapOf(null to "null") var a by FixedMapVar(map, key = { desc -> null }, default = {ref, desc -> null}) - test fun doTest() { + @test fun doTest() { assertTrue(a == "null", "fail at 'a'") a = "foo" assertTrue(a == "foo", "fail at 'a' after set") @@ -61,7 +61,7 @@ class MapPropertyStringTest() { var b by Delegates.mapVar(map) val c by Delegates.mapVal(map) - test fun doTest() { + @test fun doTest() { b = "newB" assertTrue(a == "a", "fail at 'a'") assertTrue(b == "newB", "fail at 'b'") @@ -75,7 +75,7 @@ class MapValWithDefaultTest() { val b: String by FixedMapVal(map, default = { ref: MapValWithDefaultTest, desc: String -> "bDefault" }, key = {"b"}) val c: String by FixedMapVal(map, default = { ref: MapValWithDefaultTest, desc: String -> "cDefault" }, key = { desc -> desc.name }) - test fun doTest() { + @test fun doTest() { assertTrue(a == "aDefault", "fail at 'a'") assertTrue(b == "bDefault", "fail at 'b'") assertTrue(c == "cDefault", "fail at 'c'") @@ -88,7 +88,7 @@ class MapVarWithDefaultTest() { var b: String by FixedMapVar(map, default = {ref: Any?, desc: String -> "bDefault" }, key = {"b"}) var c: String by FixedMapVar(map, default = {ref: Any?, desc: String -> "cDefault" }, key = { desc -> desc.name }) - test fun doTest() { + @test fun doTest() { assertTrue(a == "aDefault", "fail at 'a'") assertTrue(b == "bDefault", "fail at 'b'") assertTrue(c == "cDefault", "fail at 'c'") @@ -106,7 +106,7 @@ class MapPropertyKeyTest() { val a by FixedMapVal(map, key = {"a"}) var b by FixedMapVar(map, key = {"b"}) - test fun doTest() { + @test fun doTest() { b = "c" assertTrue(a == "a", "fail at 'a'") assertTrue(b == "c", "fail at 'b'") @@ -118,7 +118,7 @@ class MapPropertyFunctionTest() { val a by FixedMapVal(map, { desc -> "${desc.name}Desc" }) var b by FixedMapVar(map, { desc -> "${desc.name}Desc" }) - test fun doTest() { + @test fun doTest() { b = "c" assertTrue(a == "a", "fail at 'a'") assertTrue(b == "c", "fail at 'b' after set") @@ -141,7 +141,7 @@ class MapPropertyCustomTest() { val a by mapVal var b by mapVar - test fun doTest() { + @test fun doTest() { b = "newB" assertTrue(a == "a", "fail at 'a'") assertTrue(b == "newB", "fail at 'b' after set") @@ -167,7 +167,7 @@ class MapPropertyCustomWithDefaultTest() { val a by mapValWithDefault var b by mapVarWithDefault - test fun doTest() { + @test fun doTest() { assertTrue(a == "default", "fail at 'a'") assertTrue(b == "default", "fail at 'b'") b = "c" diff --git a/libraries/stdlib/test/properties/delegation/lazy/LazyValuesTest.kt b/libraries/stdlib/test/properties/delegation/lazy/LazyValuesTest.kt index f814632f153..1a490a87d4e 100644 --- a/libraries/stdlib/test/properties/delegation/lazy/LazyValuesTest.kt +++ b/libraries/stdlib/test/properties/delegation/lazy/LazyValuesTest.kt @@ -11,19 +11,19 @@ class LazyValTest { ++result } - test fun doTest() { + @test fun doTest() { a assertTrue(a == 1, "fail: initializer should be invoked only once") } } class SynchronizedLazyValTest { - volatile var result = 0 + @Volatile var result = 0 val a by lazy(this) { ++result } - test fun doTest() { + @test fun doTest() { synchronized(this) { // thread { a } // not available in js // TODO: Make this test JVM-only result = 1 @@ -40,7 +40,7 @@ class UnsafeLazyValTest { ++result } - test fun doTest() { + @test fun doTest() { a assertTrue(a == 1, "fail: initializer should be invoked only once") } @@ -53,7 +53,7 @@ class NullableLazyValTest { val a: Int? by lazy { resultA++; null} val b by lazy { foo() } - test fun doTest() { + @test fun doTest() { a b @@ -76,7 +76,7 @@ class UnsafeNullableLazyValTest { val a: Int? by lazy(LazyThreadSafetyMode.NONE) { resultA++; null} val b by lazy(LazyThreadSafetyMode.NONE) { foo() } - test fun doTest() { + @test fun doTest() { a b @@ -98,7 +98,7 @@ class UnsafeLazyValDeprecatedTest { ++result } - test fun doTest() { + @test fun doTest() { a assertTrue(a == 1, "fail: initializer should be invoked only once") } @@ -110,7 +110,7 @@ class BlockingLazyValDeprecatedTest { ++result } - test fun doTest() { + @test fun doTest() { a assertTrue(a == 1, "fail: initializer should be invoked only once") } @@ -123,7 +123,7 @@ class UnsafeNullableLazyValDeprecatedTest { val a: Int? by Delegates.lazy { resultA++; null} val b by Delegates.lazy { foo() } - test fun doTest() { + @test fun doTest() { a b @@ -146,7 +146,7 @@ class BlockingNullableLazyValDeprecatedTest { val a: Int? by Delegates.blockingLazy { resultA++; null} val b by Delegates.blockingLazy { foo() } - test fun doTest() { + @test fun doTest() { a b @@ -166,7 +166,7 @@ class IdentityEqualsIsUsedToUnescapeLazyValTest { var equalsCalled = 0 val a by lazy { ClassWithCustomEquality { equalsCalled++ } } - test fun doTest() { + @test fun doTest() { a a assertTrue(equalsCalled == 0, "fail: equals called $equalsCalled times.") diff --git a/libraries/stdlib/test/test/TestJVMTest.kt b/libraries/stdlib/test/test/TestJVMTest.kt index 2af9d5584c9..3e878cfe84c 100644 --- a/libraries/stdlib/test/test/TestJVMTest.kt +++ b/libraries/stdlib/test/test/TestJVMTest.kt @@ -25,7 +25,8 @@ class TestJVMTest { override fun toString() = "actual" } - Test fun assertEqualsMessage() { + @Test + fun assertEqualsMessage() { expectAssertion( { msg -> assertNotNull(msg); msg!! assertTrue { msg.contains(expected.toString()) } @@ -41,7 +42,8 @@ class TestJVMTest { } , { assertEquals(expected, actual, message) }) } - Test fun assertNotEqualsMessage() { + @Test + fun assertNotEqualsMessage() { expectAssertion( { msg -> assertNotNull(msg); msg!! assertTrue { msg.contains(actual.toString()) } @@ -56,7 +58,8 @@ class TestJVMTest { } - Test fun assertTrueMessage() { + @Test + fun assertTrueMessage() { expectAssertion( { msg -> assertNotNull(msg) }, { assertTrue(false) }) expectAssertion( { msg -> assertNotNull(msg) }, { assertTrue { false } }) expectAssertion( { msg -> assertNotNull(msg) }, { assertTrue(null) { false } }) @@ -64,7 +67,8 @@ class TestJVMTest { expectAssertion( { msg -> msg!!.contains(message)}, { assertTrue(message) { false }}) } - Test fun assertFalseMessage() { + @Test + fun assertFalseMessage() { expectAssertion( { msg -> assertNotNull(msg) }, { assertFalse(true) }) expectAssertion( { msg -> assertNotNull(msg) }, { assertFalse { true } }) expectAssertion( { msg -> assertNotNull(msg) }, { assertFalse(null) { true } }) @@ -72,12 +76,14 @@ class TestJVMTest { expectAssertion( { msg -> assertTrue(msg!!.contains(message)) }, { assertFalse(message) { true }}) } - Test fun assertNotNullMessage() { + @Test + fun assertNotNullMessage() { expectAssertion( { msg -> msg!! }, { assertNotNull(null) }) expectAssertion( { msg -> assertTrue(msg!!.contains(message)) }, { assertNotNull(null, message)}) } - Test fun assertNullMessage() { + @Test + fun assertNullMessage() { expectAssertion( { msg -> msg!! }, { assertNull(actual) }) expectAssertion( { msg -> msg!! assertTrue(msg.contains(message)) diff --git a/libraries/stdlib/test/text/CharJVMTest.kt b/libraries/stdlib/test/text/CharJVMTest.kt index 198f6cd215e..af4bf883a63 100644 --- a/libraries/stdlib/test/text/CharJVMTest.kt +++ b/libraries/stdlib/test/text/CharJVMTest.kt @@ -5,7 +5,7 @@ import org.junit.Test as test class CharJVMTest { - test fun getCategory() { + @test fun getCategory() { assertEquals(CharCategory.DECIMAL_DIGIT_NUMBER, '7'.category()) assertEquals(CharCategory.CURRENCY_SYMBOL, '$'.category()) assertEquals(CharCategory.LOWERCASE_LETTER, 'a'.category()) diff --git a/libraries/stdlib/test/text/RegexJVMTest.kt b/libraries/stdlib/test/text/RegexJVMTest.kt index 634b4451c65..f77953f5dde 100644 --- a/libraries/stdlib/test/text/RegexJVMTest.kt +++ b/libraries/stdlib/test/text/RegexJVMTest.kt @@ -7,7 +7,7 @@ import org.junit.Test as test class RegexJVMTest { - test fun matchGroups() { + @test fun matchGroups() { val input = "1a 2b 3c" val regex = "(\\d)(\\w)".toRegex() diff --git a/libraries/stdlib/test/text/RegexTest.kt b/libraries/stdlib/test/text/RegexTest.kt index 5e74ab486ca..52c85b00e54 100644 --- a/libraries/stdlib/test/text/RegexTest.kt +++ b/libraries/stdlib/test/text/RegexTest.kt @@ -7,7 +7,7 @@ import org.junit.Test as test class RegexTest { - test fun matchResult() { + @test fun matchResult() { val p = "\\d+".toRegex() val input = "123 456 789" @@ -35,12 +35,12 @@ class RegexTest { assertEquals(null, noMatch) } - test fun matchIgnoreCase() { + @test fun matchIgnoreCase() { for (input in listOf("ascii", "shrödinger")) assertTrue(input.toUpperCase().matches(input.toLowerCase().toRegex(RegexOption.IGNORE_CASE))) } - test fun matchSequence() { + @test fun matchSequence() { val input = "123 456 789" val pattern = "\\d+".toRegex() @@ -54,7 +54,7 @@ class RegexTest { assertEquals(listOf(0..2, 4..6, 8..10), matches.map { it.range }.toList()) } - test fun matchAllSequence() { + @test fun matchAllSequence() { val input = "test" val pattern = ".*".toRegex() val matches = pattern.matchAll(input).toList() @@ -63,7 +63,7 @@ class RegexTest { assertEquals(2, matches.size()) } - test fun matchGroups() { + @test fun matchGroups() { val input = "1a 2b 3c" val pattern = "(\\d)(\\w)".toRegex() @@ -79,7 +79,7 @@ class RegexTest { assertEquals("b", m2.groups[2]?.value) } - test fun matchOptionalGroup() { + @test fun matchOptionalGroup() { val pattern = "(hi)|(bye)".toRegex(RegexOption.IGNORE_CASE) val m1 = pattern.match("Hi!")!! @@ -93,19 +93,19 @@ class RegexTest { assertEquals("bye", m2.groups[2]?.value) } - test fun matchMultiline() { + @test fun matchMultiline() { val regex = "^[a-z]*$".toRegex(setOf(RegexOption.IGNORE_CASE, RegexOption.MULTILINE)) val matchedValues = regex.matchAll("test\n\nLine").map { it.value }.toList() assertEquals(listOf("test", "", "Line"), matchedValues) } - test fun escapeLiteral() { + @test fun escapeLiteral() { val literal = """[-\/\\^$*+?.()|[\]{}]""" assertTrue(Regex.fromLiteral(literal).matches(literal)) assertTrue(Regex.escape(literal).toRegex().matches(literal)) } - test fun replace() { + @test fun replace() { val input = "123-456" val pattern = "(\\d+)".toRegex() assertEquals("(123)-(456)", pattern.replace(input, "($1)")) @@ -114,14 +114,14 @@ class RegexTest { assertEquals("X-456", pattern.replaceFirst(input, "X")) } - test fun replaceEvaluator() { + @test fun replaceEvaluator() { val input = "/12/456/7890/" val pattern = "\\d+".toRegex() assertEquals("/2/3/4/", pattern.replace(input, { it.value.length().toString() } )) } - test fun split() { + @test fun split() { val input = """ some ${"\t"} word split diff --git a/libraries/stdlib/test/text/StringBuilderTest.kt b/libraries/stdlib/test/text/StringBuilderTest.kt index 90677c70e42..723ac114c05 100644 --- a/libraries/stdlib/test/text/StringBuilderTest.kt +++ b/libraries/stdlib/test/text/StringBuilderTest.kt @@ -5,7 +5,7 @@ import org.junit.Test as test class StringBuilderTest { - test fun stringBuild() { + @test fun stringBuild() { val s = StringBuilder { append("a") append(true) @@ -13,13 +13,13 @@ class StringBuilderTest { assertEquals("atrue", s) } - test fun appendMany() { + @test fun appendMany() { assertEquals("a1", StringBuilder().append("a", "1").toString()) assertEquals("a1", StringBuilder().append("a", 1).toString()) assertEquals("a1", StringBuilder().append("a", StringBuilder().append("1")).toString()) } - test fun append() { + @test fun append() { // this test is needed for JS implementation assertEquals("em", StringBuilder { append("element", 2, 4) diff --git a/libraries/stdlib/test/text/StringJVMTest.kt b/libraries/stdlib/test/text/StringJVMTest.kt index 760316e8662..205031bbcf2 100644 --- a/libraries/stdlib/test/text/StringJVMTest.kt +++ b/libraries/stdlib/test/text/StringJVMTest.kt @@ -6,7 +6,7 @@ import kotlin.test.* import org.junit.Test as test class StringJVMTest { - test fun stringBuilderIterator() { + @test fun stringBuilderIterator() { var sum = 0 val sb = StringBuilder() for(c in "239") @@ -19,7 +19,7 @@ class StringJVMTest { assertTrue(sum == 14) } - test fun orEmpty() { + @test fun orEmpty() { val s: String? = "hey" val ns: String? = null @@ -27,25 +27,25 @@ class StringJVMTest { assertEquals("", ns.orEmpty()) } - test fun toShort() { + @test fun toShort() { assertEquals(77.toShort(), "77".toShort()) } - test fun toInt() { + @test fun toInt() { assertEquals(77, "77".toInt()) } - test fun toLong() { + @test fun toLong() { assertEquals(77.toLong(), "77".toLong()) } - test fun count() { + @test fun count() { val text = "hello there\tfoo\nbar" val whitespaceCount = text.count { it.isWhitespace() } assertEquals(3, whitespaceCount) } - test fun testSplitByChar() { + @test fun testSplitByChar() { val s = "ab\n[|^$&\\]^cd" var list = s.split('b'); assertEquals(2, list.size()) @@ -59,7 +59,7 @@ class StringJVMTest { assertEquals(s, list[0]) } - test fun testSplitByPattern() { + @test fun testSplitByPattern() { val s = "ab1cd2def3" val isDigit = "\\d".toRegex() assertEquals(listOf("ab", "cd", "def", ""), s.split(isDigit)) @@ -73,7 +73,7 @@ class StringJVMTest { } } - test fun repeat() { + @test fun repeat() { fails{ "foo".repeat(-1) } assertEquals("", "foo".repeat(0)) assertEquals("foo", "foo".repeat(1)) @@ -81,24 +81,24 @@ class StringJVMTest { assertEquals("foofoofoo", "foo".repeat(3)) } - test fun filter() { + @test fun filter() { assertEquals("acdca", "abcdcba".filter { !it.equals('b') }) assertEquals("1234", "a1b2c3d4".filter { it.isDigit() }) } - test fun filterNot() { + @test fun filterNot() { assertEquals("acdca", "abcdcba".filterNot { it.equals('b') }) assertEquals("abcd", "a1b2c3d4".filterNot { it.isDigit() }) } - test fun forEach() { + @test fun forEach() { val data = "abcd1234" var count = 0 data.forEach{ count++ } assertEquals(data.length(), count) } - test fun all() { + @test fun all() { val data = "AbCd" assertTrue { data.all { it.isJavaLetter() } @@ -108,7 +108,7 @@ class StringJVMTest { } } - test fun any() { + @test fun any() { val data = "a1bc" assertTrue { data.any() { it.isDigit() } @@ -118,33 +118,33 @@ class StringJVMTest { } } - test fun joinTo() { + @test fun joinTo() { val data = "kotlin".toList() val sb = StringBuilder() data.joinTo(sb, "^", "<", ">") assertEquals("", sb.toString()) } - test fun find() { + @test fun find() { val data = "a1b2c3" assertEquals('1', data.first { it.isDigit() }) assertNull(data.firstOrNull { it.isUpperCase() }) } - test fun findNot() { + @test fun findNot() { val data = "1a2b3c" assertEquals('a', data.filterNot { it.isDigit() }.firstOrNull()) assertNull(data.filterNot { it.isJavaLetterOrDigit() }.firstOrNull()) } - test fun partition() { + @test fun partition() { val data = "a1b2c3" val pair = data.partition { it.isDigit() } assertEquals("123", pair.first, "pair.first") assertEquals("abc", pair.second, "pair.second") } - test fun map() { + @test fun map() { assertEquals(arrayListOf('a', 'b', 'c'), "abc".map({ it })) assertEquals(arrayListOf(true, false, true), "AbC".map({ it.isUpperCase() })) @@ -154,7 +154,7 @@ class StringJVMTest { assertEquals(arrayListOf(97, 98, 99), "abc".map({ it.toInt() })) } - test fun mapTo() { + @test fun mapTo() { val result1 = arrayListOf() val return1 = "abc".mapTo(result1, { it }) assertEquals(result1, return1) @@ -176,14 +176,14 @@ class StringJVMTest { assertEquals(arrayListOf(97, 98, 99), result4) } - test fun flatMap() { + @test fun flatMap() { val data = "abcd" val result = data.flatMap { listOf(it) } assertEquals(data.length(), result.count()) assertEquals(data.toCharList(), result) } - test fun fold() { + @test fun fold() { // calculate number of digits in the string val data = "a1b2c3def" val result = data.fold(0, { digits, c -> if(c.isDigit()) digits + 1 else digits } ) @@ -196,7 +196,7 @@ class StringJVMTest { assertEquals(data, data.fold("", { s, c -> s + c })) } - test fun foldRight() { + @test fun foldRight() { // calculate number of digits in the string val data = "a1b2c3def" val result = data.foldRight(0, { c, digits -> if(c.isDigit()) digits + 1 else digits }) @@ -209,7 +209,7 @@ class StringJVMTest { assertEquals(data, data.foldRight("", { s, c -> "" + s + c })) } - test fun reduce() { + @test fun reduce() { // get the smallest character(by char value) assertEquals('a', "bacfd".reduce { v, c -> if (v > c) c else v }) @@ -218,7 +218,7 @@ class StringJVMTest { } } - test fun reduceRight() { + @test fun reduceRight() { // get the smallest character(by char value) assertEquals('a', "bacfd".reduceRight { c, v -> if (v > c) c else v }) @@ -227,7 +227,7 @@ class StringJVMTest { } } - test fun groupBy() { + @test fun groupBy() { // group characters by their case val data = "abAbaABcD" val result = data.groupBy { it.isLowerCase() } @@ -235,7 +235,7 @@ class StringJVMTest { assertEquals(listOf('a','b','b','a','c'), result.get(true)) } - test fun joinToString() { + @test fun joinToString() { val data = "abcd".toList() val result = data.joinToString("_", "(", ")") assertEquals("(a_b_c_d)", result) @@ -249,7 +249,7 @@ class StringJVMTest { assertEquals("A, 1, /, B", result3) } - test fun join() { + @test fun join() { val data = "abcd".map { it.toString() } val result = data.join("_", "(", ")") assertEquals("(a_b_c_d)", result) @@ -259,14 +259,14 @@ class StringJVMTest { assertEquals("[v-e-r-y-l-o-n-g-s-t-r-oops]", result2) } - test fun dropWhile() { + @test fun dropWhile() { val data = "ab1cd2" assertEquals("1cd2", data.dropWhile { it.isJavaLetter() }) assertEquals("", data.dropWhile { true }) assertEquals("ab1cd2", data.dropWhile { false }) } - test fun drop() { + @test fun drop() { val data = "abcd1234" assertEquals("d1234", data.drop(3)) fails { @@ -275,14 +275,14 @@ class StringJVMTest { assertEquals("", data.drop(data.length() + 5)) } - test fun takeWhile() { + @test fun takeWhile() { val data = "ab1cd2" assertEquals("ab", data.takeWhile { it.isJavaLetter() }) assertEquals("", data.takeWhile { false }) assertEquals("ab1cd2", data.takeWhile { true }) } - test fun take() { + @test fun take() { val data = "abcd1234" assertEquals("abc", data.take(3)) fails { @@ -291,7 +291,7 @@ class StringJVMTest { assertEquals(data, data.take(data.length() + 42)) } - test fun formatter() { + @test fun formatter() { assertEquals("12", "%d%d".format(1, 2)) assertEquals("1,234,567.890", "%,.3f".format(Locale.ENGLISH, 1234567.890)) @@ -299,14 +299,14 @@ class StringJVMTest { assertEquals("1 234 567,890", "%,.3f".format(Locale("fr"), 1234567.890)) } - test fun toByteArrayEncodings() { + @test fun toByteArrayEncodings() { val s = "hello" val defaultCharset = java.nio.charset.Charset.defaultCharset()!! assertEquals(String(s.toByteArray()), String(s.toByteArray(defaultCharset))) assertEquals(String(s.toByteArray()), String(s.toByteArray(defaultCharset.name()))) } - test fun testReplaceAllClosure() { + @test fun testReplaceAllClosure() { val s = "test123zzz" val result = s.replace("\\d+".toRegex()) { mr -> "[" + mr.value + "]" @@ -314,7 +314,7 @@ class StringJVMTest { assertEquals("test[123]zzz", result) } - test fun testReplaceAllClosureAtStart() { + @test fun testReplaceAllClosureAtStart() { val s = "123zzz" val result = s.replace("\\d+".toRegex()) { mr -> "[" + mr.value + "]" @@ -322,7 +322,7 @@ class StringJVMTest { assertEquals("[123]zzz", result) } - test fun testReplaceAllClosureAtEnd() { + @test fun testReplaceAllClosureAtEnd() { val s = "test123" val result = s.replace("\\d+".toRegex()) { mr -> "[" + mr.value + "]" @@ -330,7 +330,7 @@ class StringJVMTest { assertEquals("test[123]", result) } - test fun testReplaceAllClosureEmpty() { + @test fun testReplaceAllClosureEmpty() { val s = "" val result = s.replace("\\d+".toRegex()) { mr -> "x" @@ -339,7 +339,7 @@ class StringJVMTest { } - test fun slice() { + @test fun slice() { val iter = listOf(4, 3, 0, 1) val builder = StringBuilder() @@ -360,7 +360,7 @@ class StringJVMTest { } - test fun orderIgnoringCase() { + @test fun orderIgnoringCase() { val list = listOf("Beast", "Ast", "asterisk") assertEquals(listOf("Ast", "Beast", "asterisk"), list.sort()) assertEquals(listOf("Ast", "asterisk", "Beast"), list.sortBy(String.CASE_INSENSITIVE_ORDER)) diff --git a/libraries/stdlib/test/text/StringTest.kt b/libraries/stdlib/test/text/StringTest.kt index e37b8339489..661be46f68b 100644 --- a/libraries/stdlib/test/text/StringTest.kt +++ b/libraries/stdlib/test/text/StringTest.kt @@ -11,7 +11,7 @@ class IsEmptyCase(val value: String?, val isNull: Boolean = false, val isEmpty: class StringTest { - test fun isEmptyAndBlank() { + @test fun isEmptyAndBlank() { val cases = listOf( IsEmptyCase(null, isNull = true), @@ -32,7 +32,7 @@ class StringTest { } } - test fun startsWithString() { + @test fun startsWithString() { assertTrue("abcd".startsWith("ab")) assertTrue("abcd".startsWith("abcd")) assertTrue("abcd".startsWith("a")) @@ -46,7 +46,7 @@ class StringTest { assertTrue("abcd".startsWith("aB", ignoreCase = true)) } - test fun endsWithString() { + @test fun endsWithString() { assertTrue("abcd".endsWith("d")) assertTrue("abcd".endsWith("abcd")) assertFalse("abcd".endsWith("b")) @@ -57,7 +57,7 @@ class StringTest { assertTrue("".endsWith("")) } - test fun startsWithChar() { + @test fun startsWithChar() { assertTrue("abcd".startsWith('a')) assertFalse("abcd".startsWith('b')) assertFalse("abcd".startsWith('A', ignoreCase = false)) @@ -65,7 +65,7 @@ class StringTest { assertFalse("".startsWith('a')) } - test fun endsWithChar() { + @test fun endsWithChar() { assertTrue("abcd".endsWith('d')) assertFalse("abcd".endsWith('b')) assertFalse("strö".endsWith('Ö', ignoreCase = false)) @@ -73,7 +73,7 @@ class StringTest { assertFalse("".endsWith('a')) } - test fun commonPrefix() { + @test fun commonPrefix() { assertEquals("", "".commonPrefixWith("")) assertEquals("", "any".commonPrefixWith("")) assertEquals("", "".commonPrefixWith("any")) @@ -90,7 +90,7 @@ class StringTest { } - test fun commonSuffix() { + @test fun commonSuffix() { assertEquals("", "".commonSuffixWith("")) assertEquals("", "any".commonSuffixWith("")) assertEquals("", "".commonSuffixWith("any")) @@ -106,14 +106,14 @@ class StringTest { assertEquals("$dth54", "d$dth54".commonSuffixWith("s$dth54")) } - test fun capitalize() { + @test fun capitalize() { assertEquals("A", "A".capitalize()) assertEquals("A", "a".capitalize()) assertEquals("Abcd", "abcd".capitalize()) assertEquals("Abcd", "Abcd".capitalize()) } - test fun decapitalize() { + @test fun decapitalize() { assertEquals("a", "A".decapitalize()) assertEquals("a", "a".decapitalize()) assertEquals("abcd", "abcd".decapitalize()) @@ -121,7 +121,7 @@ class StringTest { assertEquals("uRL", "URL".decapitalize()) } - test fun slice() { + @test fun slice() { val iter = listOf(4, 3, 0, 1) // abcde // 01234 @@ -130,19 +130,19 @@ class StringTest { assertEquals("edab", "abcde".slice(iter)) } - test fun reverse() { + @test fun reverse() { assertEquals("dcba", "abcd".reversed()) assertEquals("4321", "1234".reversed()) assertEquals("", "".reversed()) } - test fun indices() { + @test fun indices() { assertEquals(0..4, "abcde".indices) assertEquals(0..0, "a".indices) assertTrue("".indices.isEmpty()) } - test fun replaceRange() { + @test fun replaceRange() { val s = "sample text" assertEquals("sa??e text", s.replaceRange(2, 5, "??")) assertEquals("sa?? text", s.replaceRange(2..5, "??")) @@ -157,7 +157,7 @@ class StringTest { assertEquals("??", s.replaceRange(s.indices, "??")) } - test fun removeRange() { + @test fun removeRange() { val s = "sample text" assertEquals("sae text", s.removeRange(2, 5)) assertEquals("sa text", s.removeRange(2..5)) @@ -172,7 +172,7 @@ class StringTest { assertEquals(s.replaceRange(2..5, ""), s.removeRange(2..5)) } - test fun substringDelimited() { + @test fun substringDelimited() { val s = "-1,22,3+" // chars assertEquals("22,3+", s.substringAfter(',')) @@ -196,7 +196,7 @@ class StringTest { } - test fun replaceDelimited() { + @test fun replaceDelimited() { val s = "/user/folder/file.extension" // chars assertEquals("/user/folder/file.doc", s.replaceAfter('.', "doc")) @@ -219,14 +219,14 @@ class StringTest { assertEquals("xxx", s.replaceBeforeLast("=", "/new/path", "xxx")) } - test fun stringIterator() { + @test fun stringIterator() { var sum = 0 for(c in "239") sum += (c.toInt() - '0'.toInt()) assertTrue(sum == 14) } - test fun trimStart() { + @test fun trimStart() { assertEquals("", "".trimStart()) assertEquals("a", "a".trimStart()) assertEquals("a", " a".trimStart()) @@ -245,7 +245,7 @@ class StringTest { assertEquals("123a", "ab123a".trimStart { it < '0' || it > '9' }) // TODO: Use !it.isDigit when available in JS } - test fun trimEnd() { + @test fun trimEnd() { assertEquals("", "".trimEnd()) assertEquals("a", "a".trimEnd()) assertEquals("a", "a ".trimEnd()) @@ -264,7 +264,7 @@ class StringTest { assertEquals("ab123", "ab123a".trimEnd { it < '0' || it > '9' }) // TODO: Use !it.isDigit when available in JS } - test fun trimStartAndEnd() { + @test fun trimStartAndEnd() { val examples = arrayOf("a", " a ", " a ", @@ -293,7 +293,7 @@ class StringTest { } } - test fun padStart() { + @test fun padStart() { assertEquals("s", "s".padStart(0)) assertEquals("s", "s".padStart(1)) assertEquals(" ", "".padStart(2)) @@ -303,7 +303,7 @@ class StringTest { } } - test fun padEnd() { + @test fun padEnd() { assertEquals("s", "s".padEnd(0)) assertEquals("s", "s".padEnd(1)) assertEquals(" ", "".padEnd(2)) @@ -313,21 +313,21 @@ class StringTest { } } - test fun removePrefix() { + @test fun removePrefix() { assertEquals("fix", "prefix".removePrefix("pre"), "Removes prefix") assertEquals("prefix", "preprefix".removePrefix("pre"), "Removes prefix once") assertEquals("sample", "sample".removePrefix("value")) assertEquals("sample", "sample".removePrefix("")) } - test fun removeSuffix() { + @test fun removeSuffix() { assertEquals("suf", "suffix".removeSuffix("fix"), "Removes suffix") assertEquals("suffix", "suffixfix".removeSuffix("fix"), "Removes suffix once") assertEquals("sample", "sample".removeSuffix("value")) assertEquals("sample", "sample".removeSuffix("")) } - test fun removeSurrounding() { + @test fun removeSurrounding() { assertEquals("value", "".removeSurrounding("<", ">")) assertEquals("", "<>".removeSurrounding("<", ">"), "Removes surrounding once") assertEquals(""), "Only removes surrounding when both prefix and suffix present") @@ -353,7 +353,7 @@ class StringTest { */ - test fun split() { + @test fun split() { assertEquals(listOf(""), "".split(";")) assertEquals(listOf("test"), "test".split(*charArrayOf()), "empty list of delimiters, none matched -> entire string returned") assertEquals(listOf("test"), "test".split(*arrayOf()), "empty list of delimiters, none matched -> entire string returned") @@ -368,7 +368,7 @@ class StringTest { assertEquals(listOf("", "", "b", "b", "", ""), "abba".split("a", "")) } - test fun splitToLines() { + @test fun splitToLines() { val string = "first line\rsecond line\nthird line\r\nlast line" assertEquals(listOf("first line", "second line", "third line", "last line"), string.lines()) @@ -378,7 +378,7 @@ class StringTest { } - test fun indexOfAnyChar() { + @test fun indexOfAnyChar() { val string = "abracadabra" val chars = charArrayOf('d', 'b') assertEquals(1, string.indexOfAny(chars)) @@ -392,7 +392,7 @@ class StringTest { assertEquals(-1, string.indexOfAny(charArrayOf())) } - test fun indexOfAnyCharIgnoreCase() { + @test fun indexOfAnyCharIgnoreCase() { val string = "abraCadabra" val chars = charArrayOf('B', 'c') assertEquals(1, string.indexOfAny(chars, ignoreCase = true)) @@ -404,7 +404,7 @@ class StringTest { assertEquals(-1, string.lastIndexOfAny(chars, startIndex = 0, ignoreCase = true)) } - test fun indexOfAnyString() { + @test fun indexOfAnyString() { val string = "abracadabra" val substrings = listOf("rac", "ra") assertEquals(2, string.indexOfAny(substrings)) @@ -421,7 +421,7 @@ class StringTest { assertEquals(-1, string.indexOfAny(listOf())) } - test fun indexOfAnyStringIgnoreCase() { + @test fun indexOfAnyStringIgnoreCase() { val string = "aBraCadaBrA" val substrings = listOf("rAc", "Ra") @@ -434,7 +434,7 @@ class StringTest { assertEquals(-1, string.lastIndexOfAny(substrings, startIndex = 1, ignoreCase = true)) } - test fun findAnyOfStrings() { + @test fun findAnyOfStrings() { val string = "abracadabra" val substrings = listOf("rac", "ra") assertEquals(2 to "rac", string.findAnyOf(substrings)) @@ -451,7 +451,7 @@ class StringTest { assertEquals(null, string.findAnyOf(listOf())) } - test fun findAnyOfStringsIgnoreCase() { + @test fun findAnyOfStringsIgnoreCase() { val string = "aBraCadaBrA" val substrings = listOf("rAc", "Ra") @@ -464,7 +464,7 @@ class StringTest { assertEquals(null, string.findLastAnyOf(substrings, startIndex = 1, ignoreCase = true)) } - test fun indexOfChar() { + @test fun indexOfChar() { val string = "bcedef" assertEquals(-1, string.indexOf('a')) assertEquals(2, string.indexOf('e')) @@ -480,7 +480,7 @@ class StringTest { } - test fun indexOfCharIgnoreCase() { + @test fun indexOfCharIgnoreCase() { val string = "bCEdef" assertEquals(-1, string.indexOf('a', ignoreCase = true)) assertEquals(2, string.indexOf('E', ignoreCase = true)) @@ -496,7 +496,7 @@ class StringTest { } } - test fun indexOfString() { + @test fun indexOfString() { val string = "bceded" for (index in string.indices) assertEquals(index, string.indexOf("", index)) @@ -505,7 +505,7 @@ class StringTest { assertEquals(-1, string.indexOf("abcdefgh")) } - test fun indexOfStringIgnoreCase() { + @test fun indexOfStringIgnoreCase() { val string = "bceded" for (index in string.indices) assertEquals(index, string.indexOf("", index, ignoreCase = true)) @@ -515,7 +515,7 @@ class StringTest { } - test fun contains() { + @test fun contains() { assertTrue("pl" in "sample") assertFalse("PL" in "sample") assertTrue("sömple".contains("Ö", ignoreCase = true)) @@ -528,13 +528,13 @@ class StringTest { assertTrue("sömple".contains('Ö', ignoreCase = true)) } - test fun equalsIgnoreCase() { + @test fun equalsIgnoreCase() { assertFalse("sample".equals("Sample", ignoreCase = false)) assertTrue("sample".equals("Sample", ignoreCase = true)) } - test fun replace() { + @test fun replace() { val input = "abbAb" assertEquals("abb${'$'}b", input.replace('A', '$')) assertEquals("/bb/b", input.replace('A', '/', ignoreCase = true)) @@ -545,7 +545,7 @@ class StringTest { assertEquals("-a-b-b-A-b-", input.replace("", "-")) } - test fun replaceFirst() { + @test fun replaceFirst() { val input = "AbbabA" assertEquals("Abb${'$'}bA", input.replaceFirst('a','$')) assertEquals("${'$'}bbabA", input.replaceFirst('a','$', ignoreCase = true)) @@ -558,7 +558,7 @@ class StringTest { assertEquals("-test", "test".replaceFirst("", "-")) } - test fun trimMargin() { + @test fun trimMargin() { // WARNING // DO NOT REFORMAT AS TESTS MAY FAIL DUE TO INDENTATION CHANGE @@ -605,7 +605,7 @@ class StringTest { assertEquals("\u0000|ABC", "${"\u0000"}|ABC".trimMargin()) } - test fun trimIndent() { + @test fun trimIndent() { // WARNING // DO NOT REFORMAT AS TESTS MAY FAIL DUE TO INDENTATION CHANGE @@ -669,7 +669,7 @@ ${" "} assertEquals(1, deindented.lines().count { it.isEmpty() }) } - test fun testIndent() { + @test fun testIndent() { assertEquals(" ABC\n 123", "ABC\n123".prependIndent(" ")) assertEquals(" ABC\n \n 123", "ABC\n\n123".prependIndent(" ")) assertEquals(" ABC\n \n 123", "ABC\n \n123".prependIndent(" ")) diff --git a/libraries/stdlib/test/text/StringUtilTest.kt b/libraries/stdlib/test/text/StringUtilTest.kt index a24fbb455f7..3dc5d263e8e 100644 --- a/libraries/stdlib/test/text/StringUtilTest.kt +++ b/libraries/stdlib/test/text/StringUtilTest.kt @@ -5,7 +5,7 @@ import kotlin.test.* import org.junit.Test as test class StringUtilTest() { - test fun toPattern() { + @test fun toPattern() { val re = """foo""".toPattern() val list = re.split("hellofoobar").toList() assertEquals(listOf("hello", "bar"), list) diff --git a/libraries/stdlib/test/utils/LazyJVMTest.kt b/libraries/stdlib/test/utils/LazyJVMTest.kt index 4d89588937c..9925f11a40d 100644 --- a/libraries/stdlib/test/utils/LazyJVMTest.kt +++ b/libraries/stdlib/test/utils/LazyJVMTest.kt @@ -8,7 +8,7 @@ import org.junit.Test as test class LazyJVMTest { - test fun lazyInitializationForcedOnSerialization() { + @test fun lazyInitializationForcedOnSerialization() { for(mode in listOf(LazyThreadSafetyMode.SYNCHRONIZED, LazyThreadSafetyMode.NONE)) { val lazy = lazy(mode) { "initialized" } assertFalse(lazy.isInitialized()) diff --git a/libraries/stdlib/test/utils/LazyTest.kt b/libraries/stdlib/test/utils/LazyTest.kt index 1e2ff510c56..e54966b16d6 100644 --- a/libraries/stdlib/test/utils/LazyTest.kt +++ b/libraries/stdlib/test/utils/LazyTest.kt @@ -6,7 +6,7 @@ import org.junit.Test as test class LazyTest { - test fun initializationCalledOnce() { + @test fun initializationCalledOnce() { var callCount = 0 val lazyInt = lazy { ++callCount } @@ -20,7 +20,7 @@ class LazyTest { assertEquals(1, callCount) } - test fun alreadyInitialized() { + @test fun alreadyInitialized() { val lazyInt = lazyOf(1) assertTrue(lazyInt.isInitialized()) @@ -28,7 +28,7 @@ class LazyTest { } - test fun lazyToString() { + @test fun lazyToString() { var callCount = 0 val lazyInt = lazy { ++callCount } diff --git a/libraries/stdlib/test/utils/TODOTest.kt b/libraries/stdlib/test/utils/TODOTest.kt index 4dba42a87d5..04ceff12aa1 100644 --- a/libraries/stdlib/test/utils/TODOTest.kt +++ b/libraries/stdlib/test/utils/TODOTest.kt @@ -37,7 +37,7 @@ class TODOTest { } - test fun usage() { + @test fun usage() { val inst = PartiallyImplementedClass() assertNotImplemented { inst.prop } diff --git a/libraries/stdlib/validator/src/test/kotlin/NoInternalVisibilityInStdLibTest.kt b/libraries/stdlib/validator/src/test/kotlin/NoInternalVisibilityInStdLibTest.kt index 5f3bfb74026..3dc128dfdbb 100644 --- a/libraries/stdlib/validator/src/test/kotlin/NoInternalVisibilityInStdLibTest.kt +++ b/libraries/stdlib/validator/src/test/kotlin/NoInternalVisibilityInStdLibTest.kt @@ -107,16 +107,19 @@ class NoInternalVisibilityInStdLibTest { } } - Before fun setUp() { + @Before + fun setUp() { disposable = Disposer.newDisposable() } - After fun tearDown() { + @After + fun tearDown() { Disposer.dispose(disposable!!) disposable = null } - Test fun testJvmStdlib() { + @Test + fun testJvmStdlib() { doTest(ANALYZE_PACKAGE_ROOTS_FOR_JVM, ADDITIONALLY_REQUIRED_PACKAGES_FOR_JVM) { val configuration = CompilerConfiguration() configuration.addKotlinSourceRoot("../src/kotlin") @@ -134,7 +137,8 @@ class NoInternalVisibilityInStdLibTest { } } - Test fun testJsStdlibJar() { + @Test + fun testJsStdlibJar() { doTest(ANALYZE_PACKAGE_ROOTS_FOR_JS, ADDITIONALLY_REQUIRED_PACKAGES_FOR_JS) { val configuration = CompilerConfiguration() val environment = KotlinCoreEnvironment.createForProduction(disposable!!, configuration, EnvironmentConfigFiles.JS_CONFIG_FILES) diff --git a/libraries/tools/kotlin-annotation-processing/src/test/kotlin/org/jetbrains/kotlin/annotation/AnnotationListParseTest.kt b/libraries/tools/kotlin-annotation-processing/src/test/kotlin/org/jetbrains/kotlin/annotation/AnnotationListParseTest.kt index 906c3c6d2a9..23585bea9ff 100644 --- a/libraries/tools/kotlin-annotation-processing/src/test/kotlin/org/jetbrains/kotlin/annotation/AnnotationListParseTest.kt +++ b/libraries/tools/kotlin-annotation-processing/src/test/kotlin/org/jetbrains/kotlin/annotation/AnnotationListParseTest.kt @@ -8,31 +8,44 @@ import java.io.IOException public class AnnotationListParseTest { - Test fun testAnnotatedGettersSetters() = doTest("annotatedGettersSetters") + @Test + fun testAnnotatedGettersSetters() = doTest("annotatedGettersSetters") - Test fun testAnnotationInSameFile() = doTest("annotationInSameFile") + @Test + fun testAnnotationInSameFile() = doTest("annotationInSameFile") - Test fun testAnonymousClasses() = doTest("anonymousClasses") + @Test + fun testAnonymousClasses() = doTest("anonymousClasses") - Test fun testClassAnnotations() = doTest("classAnnotations") + @Test + fun testClassAnnotations() = doTest("classAnnotations") - Test fun testConstructors() = doTest("constructors") + @Test + fun testConstructors() = doTest("constructors") - Test fun testDefaultPackage() = doTest("defaultPackage") + @Test + fun testDefaultPackage() = doTest("defaultPackage") - Test fun testFieldAnnotations() = doTest("fieldAnnotations") + @Test + fun testFieldAnnotations() = doTest("fieldAnnotations") - Test fun testLocalClasses() = doTest("localClasses") + @Test + fun testLocalClasses() = doTest("localClasses") - Test fun testMethodAnnotations() = doTest("methodAnnotations") + @Test + fun testMethodAnnotations() = doTest("methodAnnotations") - Test fun testNestedClasses() = doTest("nestedClasses") + @Test + fun testNestedClasses() = doTest("nestedClasses") - Test fun testPlatformStatic() = doTest("platformStatic") + @Test + fun testPlatformStatic() = doTest("platformStatic") - Test fun testSimple() = doTest("simple") + @Test + fun testSimple() = doTest("simple") - Test fun testDeclarations() = doTest("classDeclarations") + @Test + fun testDeclarations() = doTest("classDeclarations") private val resourcesRootFile = File("src/test/resources/parse") diff --git a/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt b/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt index 64bc464d25e..637c500c014 100644 --- a/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt +++ b/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt @@ -286,7 +286,7 @@ public open class Kotlin2JsCompile() : AbstractKotlinCompile ExtraPropertiesExtension.getOrNull(id: String): T? { try { - @suppress("UNCHECKED_CAST") + @Suppress("UNCHECKED_CAST") return get(id) as? T } catch (e: ExtraPropertiesExtension.UnknownPropertyException) { @@ -295,7 +295,7 @@ private fun ExtraPropertiesExtension.getOrNull(id: String): T? { } fun getAnnotations(project: Project, logger: Logger): Collection { - @suppress("UNCHECKED_CAST") + @Suppress("UNCHECKED_CAST") val annotations = project.getExtensions().getByName(DEFAULT_ANNOTATIONS) as Collection if (!annotations.isEmpty()) { diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt index f50f3efe9ef..75b7a4ff28c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt @@ -19,11 +19,13 @@ abstract class BaseGradleIT { private val resourcesRootFile = File("src/test/resources") private var workingDir = File(".") - Before fun setUp() { + @Before + fun setUp() { workingDir = Files.createTempDir() } - After fun tearDown() { + @After + fun tearDown() { deleteRecursively(workingDir) } diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/BasicKotlinGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/BasicKotlinGradlePluginIT.kt index fdb9c2d5a1f..c3d9b796260 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/BasicKotlinGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/BasicKotlinGradlePluginIT.kt @@ -7,7 +7,8 @@ import org.junit.Ignore class SimpleKotlinGradleIT : BaseGradleIT() { - Test fun testSimpleCompile() { + @Test + fun testSimpleCompile() { val project = Project("simpleProject", "1.12") project.build("compileDeployKotlin", "build") { @@ -22,7 +23,8 @@ class SimpleKotlinGradleIT : BaseGradleIT() { } } - Test fun testSuppressWarningsAndVersionInVerboseMode() { + @Test + fun testSuppressWarningsAndVersionInVerboseMode() { val project = Project("suppressWarningsAndVersion", "1.6") project.build("build") { @@ -38,7 +40,8 @@ class SimpleKotlinGradleIT : BaseGradleIT() { } } - Test fun testSuppressWarningsAndVersionInNonVerboseMode() { + @Test + fun testSuppressWarningsAndVersionInNonVerboseMode() { val project = Project("suppressWarningsAndVersion", "1.6", minLogLevel = LogLevel.INFO) project.build("build") { @@ -54,39 +57,45 @@ class SimpleKotlinGradleIT : BaseGradleIT() { } } - Test fun testKotlinCustomDirectory() { + @Test + fun testKotlinCustomDirectory() { Project("customSrcDir", "1.6").build("build") { assertSuccessful() } } - Test fun testKotlinCustomModuleName() { + @Test + fun testKotlinCustomModuleName() { Project("moduleNameCustom", "1.6").build("build") { assertSuccessful() assertContains("args.moduleName = myTestName") } } - Test fun testKotlinDefaultModuleName() { + @Test + fun testKotlinDefaultModuleName() { Project("moduleNameDefault", "1.6").build("build") { assertSuccessful() assertContains("args.moduleName = moduleNameDefault-compileKotlin") } } - Test fun testAdvancedOptions() { + @Test + fun testAdvancedOptions() { Project("advancedOptions", "1.6").build("build") { assertSuccessful() } } - Test fun testKotlinExtraJavaSrc() { + @Test + fun testKotlinExtraJavaSrc() { Project("additionalJavaSrc", "1.6").build("build") { assertSuccessful() } } - Test fun testGradleSubplugin() { + @Test + fun testGradleSubplugin() { val project = Project("kotlinGradleSubplugin", "1.6") project.build("compileKotlin", "build") { diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt index 60305f441a3..9af242e0996 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt @@ -5,7 +5,8 @@ import org.jetbrains.kotlin.gradle.BaseGradleIT.Project class Kotlin2JsGradlePluginIT : BaseGradleIT() { - Test fun testBuildAndClean() { + @Test + fun testBuildAndClean() { val project = Project("kotlin2JsProject", "1.6") project.build("build", "-Pkotlin.gradle.noThreadTest=true") { @@ -62,7 +63,8 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() { } } - Test fun testNoOutputFileFails() { + @Test + fun testNoOutputFileFails() { val project = Project("kotlin2JsNoOutputFileProject", "1.6") project.build("build") { assertFailed() diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinAndroidGradleIT.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinAndroidGradleIT.kt index 68e09442e5a..91e277694eb 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinAndroidGradleIT.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinAndroidGradleIT.kt @@ -4,10 +4,11 @@ import org.junit.Test import org.junit.Ignore import org.jetbrains.kotlin.gradle.BaseGradleIT.Project -Ignore("Requires Android SDK") +@Ignore("Requires Android SDK") class KotlinAndroidGradleIT: BaseGradleIT() { - Test fun testSimpleCompile() { + @Test + fun testSimpleCompile() { val project = Project("AndroidProject", "2.3") project.build("build") { @@ -53,7 +54,8 @@ class KotlinAndroidGradleIT: BaseGradleIT() { } } - Test fun testModuleNameAndroid() { + @Test + fun testModuleNameAndroid() { val project = Project("AndroidProject", "2.3") project.build("build") { diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt index 8a0fac51061..eaa9c6cb759 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt @@ -5,7 +5,8 @@ import org.junit.Test class KotlinGradleIT: BaseGradleIT() { - Test fun testCrossCompile() { + @Test + fun testCrossCompile() { val project = Project("kotlinJavaProject", "1.6") project.build("compileDeployKotlin", "build") { @@ -20,7 +21,8 @@ class KotlinGradleIT: BaseGradleIT() { } } - Test fun testKotlinOnlyCompile() { + @Test + fun testKotlinOnlyCompile() { val project = Project("kotlinProject", "1.6") project.build("build") { @@ -38,7 +40,8 @@ class KotlinGradleIT: BaseGradleIT() { // For corresponding documentation, see https://docs.gradle.org/current/userguide/gradle_daemon.html // Setting user.variant to different value implies a new daemon process will be created. // In order to stop daemon process, special exit task is used ( System.exit(0) ). - Test fun testKotlinOnlyDaemonMemory() { + @Test + fun testKotlinOnlyDaemonMemory() { val project = Project("kotlinProject", "2.4") val VARIANT_CONSTANT = "ForTest" val userVariantArg = "-Duser.variant=$VARIANT_CONSTANT" @@ -74,7 +77,8 @@ class KotlinGradleIT: BaseGradleIT() { } } - Test fun testKotlinClasspath() { + @Test + fun testKotlinClasspath() { Project("classpathTest", "1.6").build("build") { assertSuccessful() assertReportExists() @@ -82,7 +86,8 @@ class KotlinGradleIT: BaseGradleIT() { } } - Test fun testMultiprojectPluginClasspath() { + @Test + fun testMultiprojectPluginClasspath() { Project("multiprojectClassPathTest", "1.6").build("build") { assertSuccessful() assertReportExists("subproject") @@ -90,7 +95,8 @@ class KotlinGradleIT: BaseGradleIT() { } } - Test fun testKotlinInJavaRoot() { + @Test + fun testKotlinInJavaRoot() { Project("kotlinInJavaRoot", "1.6").build("build") { assertSuccessful() assertReportExists() @@ -98,7 +104,8 @@ class KotlinGradleIT: BaseGradleIT() { } } - Test fun testKaptSimple() { + @Test + fun testKaptSimple() { val project = Project("kaptSimple", "1.12") project.build("build") { @@ -117,7 +124,8 @@ class KotlinGradleIT: BaseGradleIT() { } } - Test fun testKaptStubs() { + @Test + fun testKaptStubs() { val project = Project("kaptStubs", "1.12") project.build("build") { @@ -136,7 +144,8 @@ class KotlinGradleIT: BaseGradleIT() { } } - Test fun testKaptArguments() { + @Test + fun testKaptArguments() { Project("kaptArguments", "1.12").build("build") { assertSuccessful() assertContains("kapt: Using class file stubs") @@ -149,7 +158,8 @@ class KotlinGradleIT: BaseGradleIT() { } } - Test fun testKaptInheritedAnnotations() { + @Test + fun testKaptInheritedAnnotations() { Project("kaptInheritedAnnotations", "1.12").build("build") { assertSuccessful() assertFileExists("build/generated/source/kapt/main/TestClassGenerated.java") @@ -159,7 +169,8 @@ class KotlinGradleIT: BaseGradleIT() { } } - Test fun testKaptOutputKotlinCode() { + @Test + fun testKaptOutputKotlinCode() { Project("kaptOutputKotlinCode", "1.12").build("build") { assertSuccessful() assertContains("kapt: Using class file stubs") diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/classpathTest/src/test/kotlin/tests.kt b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/classpathTest/src/test/kotlin/tests.kt index d8a2e6e6523..6e9eb5e69b8 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/classpathTest/src/test/kotlin/tests.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/classpathTest/src/test/kotlin/tests.kt @@ -4,7 +4,7 @@ import org.testng.Assert.* import org.testng.annotations.Test as test class TestSource() { - test fun f() { + @test fun f() { assertEquals(box(), "OK") } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kotlinJavaProject/src/test/kotlin/tests.kt b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kotlinJavaProject/src/test/kotlin/tests.kt index e631927f0ff..1a7a3a23b80 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kotlinJavaProject/src/test/kotlin/tests.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kotlinJavaProject/src/test/kotlin/tests.kt @@ -8,7 +8,7 @@ import org.testng.annotations.BeforeMethod import org.testng.annotations.Test as test class TestSource() { - test fun f() { + @test fun f() { val example : KotlinGreetingJoiner = KotlinGreetingJoiner(Greeter("Hi")) example.addName("Harry") example.addName("Ron") diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kotlinProject/src/test/kotlin/tests.kt b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kotlinProject/src/test/kotlin/tests.kt index e631927f0ff..1a7a3a23b80 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kotlinProject/src/test/kotlin/tests.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kotlinProject/src/test/kotlin/tests.kt @@ -8,7 +8,7 @@ import org.testng.annotations.BeforeMethod import org.testng.annotations.Test as test class TestSource() { - test fun f() { + @test fun f() { val example : KotlinGreetingJoiner = KotlinGreetingJoiner(Greeter("Hi")) example.addName("Harry") example.addName("Ron") diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/moduleNameCustom/src/test/kotlin/tests.kt b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/moduleNameCustom/src/test/kotlin/tests.kt index 75a947b67c2..d38eecc5828 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/moduleNameCustom/src/test/kotlin/tests.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/moduleNameCustom/src/test/kotlin/tests.kt @@ -4,7 +4,7 @@ import org.testng.Assert.assertTrue import org.testng.annotations.Test as test class TestSource() { - test fun f() { + @test fun f() { assertTrue(isModuleFileExists(), "Kotlin module file should exists") } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/moduleNameDefault/src/test/kotlin/tests.kt b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/moduleNameDefault/src/test/kotlin/tests.kt index 161441e4756..d44a02d6b95 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/moduleNameDefault/src/test/kotlin/tests.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/moduleNameDefault/src/test/kotlin/tests.kt @@ -4,7 +4,7 @@ import org.testng.Assert.assertTrue import org.testng.annotations.Test as test class TestSource() { - test fun f() { + @test fun f() { assertTrue(isModuleFileExists(), "Kotlin module file should exists") } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/multiprojectClassPathTest/subproject/src/test/kotlin/tests.kt b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/multiprojectClassPathTest/subproject/src/test/kotlin/tests.kt index d8a2e6e6523..6e9eb5e69b8 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/multiprojectClassPathTest/subproject/src/test/kotlin/tests.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/multiprojectClassPathTest/subproject/src/test/kotlin/tests.kt @@ -4,7 +4,7 @@ import org.testng.Assert.* import org.testng.annotations.Test as test class TestSource() { - test fun f() { + @test fun f() { assertEquals(box(), "OK") } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/simpleProject/src/test/kotlin/tests.kt b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/simpleProject/src/test/kotlin/tests.kt index e631927f0ff..1a7a3a23b80 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/simpleProject/src/test/kotlin/tests.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/simpleProject/src/test/kotlin/tests.kt @@ -8,7 +8,7 @@ import org.testng.annotations.BeforeMethod import org.testng.annotations.Test as test class TestSource() { - test fun f() { + @test fun f() { val example : KotlinGreetingJoiner = KotlinGreetingJoiner(Greeter("Hi")) example.addName("Harry") example.addName("Ron") diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt index 02ed05aa445..7fd938caead 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt @@ -54,7 +54,7 @@ fun specialJVM(): List { only(ArraysOfObjects, InvariantArraysOfObjects, ArraysOfPrimitives) doc { "Returns new array which is a copy of range of original array." } returns("SELF") - annotations(InvariantArraysOfObjects) { """platformName("mutableCopyOfRange")"""} + annotations(InvariantArraysOfObjects) { """@JvmName("mutableCopyOfRange")"""} body { "return Arrays.copyOfRange(this, fromIndex, toIndex)" } @@ -64,7 +64,7 @@ fun specialJVM(): List { only(ArraysOfObjects, InvariantArraysOfObjects, ArraysOfPrimitives) doc { "Returns new array which is a copy of the original array." } returns("SELF") - annotations(InvariantArraysOfObjects) { """platformName("mutableCopyOf")"""} + annotations(InvariantArraysOfObjects) { """@JvmName("mutableCopyOf")"""} body { "return Arrays.copyOf(this, size())" }