Add samples for contentToString and contentDeepToString array operations
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user