Add samples for contentToString and contentDeepToString array operations
This commit is contained in:
@@ -5191,6 +5191,8 @@ public fun <T> Array<out T>.contentDeepHashCode(): Int {
|
||||
*
|
||||
* If any of arrays contains itself on any nesting level that reference
|
||||
* is rendered as `"[...]"` to prevent recursion.
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentDeepToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@library("arrayDeepToString")
|
||||
@@ -5380,6 +5382,8 @@ public fun CharArray.contentHashCode(): Int {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@library("arrayToString")
|
||||
@@ -5389,6 +5393,8 @@ public fun <T> Array<out T>.contentToString(): String {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@library("arrayToString")
|
||||
@@ -5398,6 +5404,8 @@ public fun ByteArray.contentToString(): String {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@library("arrayToString")
|
||||
@@ -5407,6 +5415,8 @@ public fun ShortArray.contentToString(): String {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@library("arrayToString")
|
||||
@@ -5416,6 +5426,8 @@ public fun IntArray.contentToString(): String {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@library("arrayToString")
|
||||
@@ -5425,6 +5437,8 @@ public fun LongArray.contentToString(): String {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@library("arrayToString")
|
||||
@@ -5434,6 +5448,8 @@ public fun FloatArray.contentToString(): String {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@library("arrayToString")
|
||||
@@ -5443,6 +5459,8 @@ public fun DoubleArray.contentToString(): String {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@library("arrayToString")
|
||||
@@ -5452,6 +5470,8 @@ public fun BooleanArray.contentToString(): String {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@library("arrayToString")
|
||||
|
||||
@@ -2826,6 +2826,8 @@ public header fun <T> Array<out T>.contentDeepHashCode(): Int
|
||||
*
|
||||
* If any of arrays contains itself on any nesting level that reference
|
||||
* is rendered as `"[...]"` to prevent recursion.
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentDeepToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public header fun <T> Array<out T>.contentDeepToString(): String
|
||||
@@ -2949,54 +2951,72 @@ public header fun CharArray.contentHashCode(): Int
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public header fun <T> Array<out T>.contentToString(): String
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public header fun ByteArray.contentToString(): String
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public header fun ShortArray.contentToString(): String
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public header fun IntArray.contentToString(): String
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public header fun LongArray.contentToString(): String
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public header fun FloatArray.contentToString(): String
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public header fun DoubleArray.contentToString(): String
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public header fun BooleanArray.contentToString(): String
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public header fun CharArray.contentToString(): String
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package samples.collections
|
||||
|
||||
import samples.*
|
||||
import kotlin.test.*
|
||||
|
||||
|
||||
@RunWith(Enclosed::class)
|
||||
class Arrays {
|
||||
|
||||
class ContentOperations {
|
||||
|
||||
@Sample
|
||||
fun contentToString() {
|
||||
val array = arrayOf("apples", "oranges", "lime")
|
||||
|
||||
assertPrints(array.contentToString(), "[apples, oranges, lime]")
|
||||
}
|
||||
|
||||
@Sample
|
||||
fun contentDeepToString() {
|
||||
val matrix = arrayOf(
|
||||
intArrayOf(3, 7, 9),
|
||||
intArrayOf(0, 1, 0),
|
||||
intArrayOf(2, 4, 8)
|
||||
)
|
||||
|
||||
assertPrints(matrix.contentDeepToString(), "[[3, 7, 9], [0, 1, 0], [2, 4, 8]]")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5188,6 +5188,8 @@ public inline fun <T> Array<out T>.contentDeepHashCode(): Int {
|
||||
*
|
||||
* If any of arrays contains itself on any nesting level that reference
|
||||
* is rendered as `"[...]"` to prevent recursion.
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentDeepToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@@ -5368,6 +5370,8 @@ public inline fun CharArray.contentHashCode(): Int {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@@ -5377,6 +5381,8 @@ public inline fun <T> Array<out T>.contentToString(): String {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@@ -5386,6 +5392,8 @@ public inline fun ByteArray.contentToString(): String {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@@ -5395,6 +5403,8 @@ public inline fun ShortArray.contentToString(): String {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@@ -5404,6 +5414,8 @@ public inline fun IntArray.contentToString(): String {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@@ -5413,6 +5425,8 @@ public inline fun LongArray.contentToString(): String {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@@ -5422,6 +5436,8 @@ public inline fun FloatArray.contentToString(): String {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@@ -5431,6 +5447,8 @@ public inline fun DoubleArray.contentToString(): String {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@@ -5440,6 +5458,8 @@ public inline fun BooleanArray.contentToString(): String {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the contents of the specified array as if it is [List].
|
||||
*
|
||||
* @sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
|
||||
@@ -93,7 +93,13 @@ fun arrays(): List<GenericFunction> {
|
||||
only(ArraysOfObjects, ArraysOfPrimitives)
|
||||
since("1.1")
|
||||
inline(Platform.JVM, Inline.Only)
|
||||
doc { "Returns a string representation of the contents of the specified array as if it is [List]." }
|
||||
doc {
|
||||
"""
|
||||
Returns a string representation of the contents of the specified array as if it is [List].
|
||||
|
||||
@sample samples.collections.Arrays.ContentOperations.contentToString
|
||||
"""
|
||||
}
|
||||
returns("String")
|
||||
body(Platform.JVM) { "return java.util.Arrays.toString(this)" }
|
||||
annotations(Platform.JS, """@library("arrayToString")""")
|
||||
@@ -111,6 +117,8 @@ fun arrays(): List<GenericFunction> {
|
||||
|
||||
If any of arrays contains itself on any nesting level that reference
|
||||
is rendered as `"[...]"` to prevent recursion.
|
||||
|
||||
@sample samples.collections.Arrays.ContentOperations.contentDeepToString
|
||||
"""
|
||||
}
|
||||
returns("String")
|
||||
|
||||
Reference in New Issue
Block a user