From 79b94919a79fdcf2a8bda678d3d89f1a570c66e3 Mon Sep 17 00:00:00 2001 From: kotlin-samples-pusher-bot Date: Wed, 27 Nov 2024 16:03:55 +0000 Subject: [PATCH] test(samples): add new samples --- .../returns/f206fec7c8363fb88375dfb7798755ac.1.kt | 6 +++--- .../returns/f206fec7c8363fb88375dfb7798755ac.2.kt | 6 +++--- .../returns/f206fec7c8363fb88375dfb7798755ac.3.kt | 10 +++++----- .../returns/f206fec7c8363fb88375dfb7798755ac.4.kt | 12 +++++++----- .../returns/f206fec7c8363fb88375dfb7798755ac.5.kt | 15 --------------- 5 files changed, 18 insertions(+), 31 deletions(-) delete mode 100644 src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.5.kt diff --git a/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.1.kt b/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.1.kt index 72e327700..c004373fe 100644 --- a/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.1.kt +++ b/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.1.kt @@ -1,10 +1,10 @@ //sampleStart fun foo() { - listOf(1, 2, 3, 4, 5).forEach { - if (it == 3) return // non-local return directly to the caller of foo() + listOf(1, 2, 3, 4, 5).forEach lit@{ + if (it == 3) return@lit // local return to the caller of the lambda - the forEach loop print(it) } - println("this point is unreachable") + print(" done with explicit label") } //sampleEnd diff --git a/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.2.kt b/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.2.kt index c004373fe..c391945e8 100644 --- a/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.2.kt +++ b/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.2.kt @@ -1,10 +1,10 @@ //sampleStart fun foo() { - listOf(1, 2, 3, 4, 5).forEach lit@{ - if (it == 3) return@lit // local return to the caller of the lambda - the forEach loop + listOf(1, 2, 3, 4, 5).forEach { + if (it == 3) return@forEach // local return to the caller of the lambda - the forEach loop print(it) } - print(" done with explicit label") + print(" done with implicit label") } //sampleEnd diff --git a/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.3.kt b/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.3.kt index c391945e8..3fcab7cd1 100644 --- a/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.3.kt +++ b/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.3.kt @@ -1,10 +1,10 @@ //sampleStart fun foo() { - listOf(1, 2, 3, 4, 5).forEach { - if (it == 3) return@forEach // local return to the caller of the lambda - the forEach loop - print(it) - } - print(" done with implicit label") + listOf(1, 2, 3, 4, 5).forEach(fun(value: Int) { + if (value == 3) return // local return to the caller of the anonymous function - the forEach loop + print(value) + }) + print(" done with anonymous function") } //sampleEnd diff --git a/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.4.kt b/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.4.kt index 3fcab7cd1..9683e1f17 100644 --- a/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.4.kt +++ b/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.4.kt @@ -1,10 +1,12 @@ //sampleStart fun foo() { - listOf(1, 2, 3, 4, 5).forEach(fun(value: Int) { - if (value == 3) return // local return to the caller of the anonymous function - the forEach loop - print(value) - }) - print(" done with anonymous function") + run loop@{ + listOf(1, 2, 3, 4, 5).forEach { + if (it == 3) return@loop // non-local return from the lambda passed to run + print(it) + } + } + print(" done with nested loop") } //sampleEnd diff --git a/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.5.kt b/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.5.kt deleted file mode 100644 index 9683e1f17..000000000 --- a/src/test/resources/test-compile-data/jvm/kotlin-web-site/returns/f206fec7c8363fb88375dfb7798755ac.5.kt +++ /dev/null @@ -1,15 +0,0 @@ -//sampleStart -fun foo() { - run loop@{ - listOf(1, 2, 3, 4, 5).forEach { - if (it == 3) return@loop // non-local return from the lambda passed to run - print(it) - } - } - print(" done with nested loop") -} -//sampleEnd - -fun main() { - foo() -} \ No newline at end of file