diff --git a/README.md b/README.md index bbd8726b42..274ca66961 100644 --- a/README.md +++ b/README.md @@ -217,6 +217,12 @@ The `develop` branch is pushed to `master` during release. * Full release procedure checklist is [here](RELEASE.md). * Steps for contributing new integration modules are explained [here](integration/README.md#Contributing). +* Use [Knit](https://github.com/Kotlin/kotlinx-knit/blob/master/README.md) for updates to documentation: + * In project root directory run `./gradlew knit`. + * Commit updated documents and examples together with other changes. +* Use [Binary Compatibility Validator](https://github.com/Kotlin/binary-compatibility-validator/blob/master/README.md) for updates to public API: + * In project root directory run `./gradlew apiDump`. + * Commit updated API index together with other changes. diff --git a/build.gradle b/build.gradle index e03179dddb..e020937751 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ import org.jetbrains.kotlin.konan.target.HostManager @@ -9,7 +9,7 @@ def rootModule = "kotlinx.coroutines" def coreModule = "kotlinx-coroutines-core" // Not applicable for Kotlin plugin def sourceless = ['kotlinx.coroutines', 'site', 'kotlinx-coroutines-bom'] -def internal = ['kotlinx.coroutines', 'site', 'benchmarks', 'knit', 'js-stub', 'stdlib-stubs'] +def internal = ['kotlinx.coroutines', 'site', 'benchmarks', 'js-stub', 'stdlib-stubs'] // Not published def unpublished = internal + ['example-frontend-js', 'android-unit-tests'] @@ -41,7 +41,16 @@ buildscript { } } - if (build_snapshot_train || atomicfu_version.endsWith("-SNAPSHOT")) { + // Determine if any project dependency is using a snapshot version + ext.using_snapshot_version = build_snapshot_train + rootProject.properties.each { key, value -> + if (key.endsWith("_version") && value instanceof String && value.endsWith("-SNAPSHOT")) { + println("NOTE: USING SNAPSHOT VERSION: $key=$value") + ext.using_snapshot_version=true + } + } + + if (using_snapshot_version) { repositories { mavenLocal() maven { url "https://oss.sonatype.org/content/repositories/snapshots" } @@ -67,6 +76,7 @@ buildscript { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfu_version" + classpath "org.jetbrains.kotlinx:kotlinx-knit:$knit_version" classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version" classpath "org.jetbrains.kotlinx:binary-compatibility-validator:$binary_compatibility_validator_version" @@ -102,7 +112,7 @@ allprojects { kotlin_version = rootProject.properties['kotlin_snapshot_version'] } - if (build_snapshot_train || atomicfu_version.endsWith("-SNAPSHOT") || lincheck_version.endsWith("-SNAPSHOT")) { + if (using_snapshot_version) { repositories { mavenLocal() maven { url "https://oss.sonatype.org/content/repositories/snapshots" } @@ -122,7 +132,7 @@ allprojects { apply plugin: "binary-compatibility-validator" apiValidation { - ignoredProjects += ["stdlib-stubs", "benchmarks", "knit", "site", + ignoredProjects += ["stdlib-stubs", "benchmarks", "site", "kotlinx-coroutines-bom", "android-unit-tests", "js-stub"] ignoredPackages += "kotlinx.coroutines.internal" } @@ -136,9 +146,7 @@ allprojects { * google should be first in the repository list because some of the play services * transitive dependencies was removed from jcenter, thus breaking gradle dependency resolution */ - if (projectName == "kotlinx-coroutines-play-services") { - google() - } + google() jcenter() maven { url "https://kotlin.bintray.com/kotlin-dev" @@ -251,7 +259,7 @@ configure(subprojects.findAll { !unpublished.contains(it.name) }) { tasks.withType(dokka.getClass()) { externalDocumentationLink { url = new URL(core_docs_url) - packageListUrl = new URL("file://$core_docs_file") + packageListUrl = new File(core_docs_file).toURI().toURL() } } } @@ -267,3 +275,14 @@ task deploy(dependsOn: getTasksByName("publish", true) + getTasksByName("publish apply plugin: 'base' clean.dependsOn gradle.includedBuilds.collect { it.task(':clean') } + +// --------------- Knit configuration --------------- + +apply plugin: 'kotlinx-knit' + +knit { + siteRoot = "https://kotlin.github.io/kotlinx.coroutines" + moduleRoots = [".", "integration", "reactive", "ui"] +} + +knitPrepare.dependsOn getTasksByName("dokka", true) \ No newline at end of file diff --git a/docs/basics.md b/docs/basics.md index 6c3c0caa78..c5e931c58a 100644 --- a/docs/basics.md +++ b/docs/basics.md @@ -1,20 +1,4 @@ - - - + **Table of contents** @@ -30,8 +14,7 @@ class BasicsGuideTest { * [Coroutines ARE light-weight](#coroutines-are-light-weight) * [Global coroutines are like daemon threads](#global-coroutines-are-like-daemon-threads) - - + ## Coroutine Basics @@ -142,7 +125,7 @@ fun main() = runBlocking { // start main coroutine -> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-02b.kt). +> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-03.kt). @@ -396,7 +379,7 @@ fun main() = runBlocking { -> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-07.kt). +> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-09.kt). You can run and see that it prints three lines and terminates: diff --git a/docs/cancellation-and-timeouts.md b/docs/cancellation-and-timeouts.md index ef4a9c9e09..b51c45c941 100644 --- a/docs/cancellation-and-timeouts.md +++ b/docs/cancellation-and-timeouts.md @@ -1,20 +1,5 @@ - -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.$$1$$2 ---> - - **Table of contents** @@ -27,7 +12,7 @@ class CancellationTimeOutsGuideTest { * [Run non-cancellable block](#run-non-cancellable-block) * [Timeout](#timeout) - + ## Cancellation and Timeouts diff --git a/docs/channels.md b/docs/channels.md index 5550759702..1d41774971 100644 --- a/docs/channels.md +++ b/docs/channels.md @@ -1,20 +1,5 @@ - -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.$$1$$2 ---> - - **Table of contents** @@ -31,7 +16,7 @@ class ChannelsGuideTest { * [Channels are fair](#channels-are-fair) * [Ticker channels](#ticker-channels) - + ## Channels diff --git a/docs/compatibility.md b/docs/compatibility.md index e56fc1be15..8dafae7293 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -1,9 +1,3 @@ - - * [Compatibility](#compatibility) @@ -19,7 +13,7 @@ * [Gradle](#gradle) * [Maven](#maven) - + ## Compatibility This document describes the compatibility policy of `kotlinx.coroutines` library since version 1.0.0 and semantics of compatibility-specific annotations. diff --git a/docs/composing-suspending-functions.md b/docs/composing-suspending-functions.md index 0cd02762ee..6a95d7585e 100644 --- a/docs/composing-suspending-functions.md +++ b/docs/composing-suspending-functions.md @@ -1,20 +1,4 @@ - - - + **Table of contents** @@ -27,7 +11,7 @@ class ComposingGuideTest { * [Async-style functions](#async-style-functions) * [Structured concurrency with async](#structured-concurrency-with-async) - + ## Composing Suspending Functions diff --git a/docs/coroutine-context-and-dispatchers.md b/docs/coroutine-context-and-dispatchers.md index 558b039744..e379842443 100644 --- a/docs/coroutine-context-and-dispatchers.md +++ b/docs/coroutine-context-and-dispatchers.md @@ -1,20 +1,4 @@ - - - + **Table of contents** @@ -33,7 +17,7 @@ class DispatchersGuideTest { * [Coroutine scope](#coroutine-scope) * [Thread-local data](#thread-local-data) - + ## Coroutine Context and Dispatchers diff --git a/docs/debugging.md b/docs/debugging.md index e2c7ec1e07..d3caa9aee6 100644 --- a/docs/debugging.md +++ b/docs/debugging.md @@ -9,8 +9,7 @@ * [Debug agent](#debug-agent) * [Debug agent and Android](#debug-agent-and-android) - - + ## Debugging coroutines Debugging asynchronous programs is challenging, because multiple concurrent coroutines are typically working at the same time. diff --git a/docs/exception-handling.md b/docs/exception-handling.md index 178f528ae2..08e63ea994 100644 --- a/docs/exception-handling.md +++ b/docs/exception-handling.md @@ -1,20 +1,5 @@ - -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.$$1$$2 ---> - - **Table of contents** @@ -29,7 +14,7 @@ class ExceptionsGuideTest { * [Supervision scope](#supervision-scope) * [Exceptions in supervised coroutines](#exceptions-in-supervised-coroutines) - + ## Exception Handling @@ -260,7 +245,6 @@ to leak to its exception handler. diff --git a/docs/flow.md b/docs/flow.md index ce4e80f1bb..705f338b20 100644 --- a/docs/flow.md +++ b/docs/flow.md @@ -1,20 +1,4 @@ - - - + **Table of contents** @@ -60,7 +44,7 @@ class FlowGuideTest { * [Launching flow](#launching-flow) * [Flow and Reactive Streams](#flow-and-reactive-streams) - + ## Asynchronous Flow diff --git a/docs/knit.code.include b/docs/knit.code.include new file mode 100644 index 0000000000..42f2b50e81 --- /dev/null +++ b/docs/knit.code.include @@ -0,0 +1,6 @@ +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +// This file was automatically generated from ${file.name} by Knit tool. Do not edit. +package ${knit.package}.${knit.name} \ No newline at end of file diff --git a/docs/knit.properties b/docs/knit.properties new file mode 100644 index 0000000000..ab2508a114 --- /dev/null +++ b/docs/knit.properties @@ -0,0 +1,22 @@ +# +# Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. +# + +knit.package=kotlinx.coroutines.guide +knit.dir=../kotlinx-coroutines-core/jvm/test/guide/ +knit.pattern=example-[a-zA-Z0-9-]+-##\\.kt +knit.include=knit.code.include + +test.package=kotlinx.coroutines.guide.test +test.dir=../kotlinx-coroutines-core/jvm/test/guide/test/ +test.template=knit.test.template + +# Various test validation modes and their corresponding methods from TestUtil +test.mode.=verifyLines +test.mode.STARTS_WITH=verifyLinesStartWith +test.mode.ARBITRARY_TIME=verifyLinesArbitraryTime +test.mode.FLEXIBLE_TIME=verifyLinesFlexibleTime +test.mode.FLEXIBLE_THREAD=verifyLinesFlexibleThread +test.mode.LINES_START_UNORDERED=verifyLinesStartUnordered +test.mode.LINES_START=verifyLinesStart +test.mode.EXCEPTION=verifyExceptions \ No newline at end of file diff --git a/docs/knit.test.template b/docs/knit.test.template new file mode 100644 index 0000000000..a912555a43 --- /dev/null +++ b/docs/knit.test.template @@ -0,0 +1,27 @@ +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +// This file was automatically generated from ${file.name} by Knit tool. Do not edit. +package ${test.package} + +import org.junit.Test + +class ${test.name} { +<#list cases as case><#assign method = test["mode.${case.param}"]!"custom"> + @Test + fun test${case.name}() { + test("${case.name}") { ${case.knit.package}.${case.knit.name}.main() }<#if method != "custom">.${method}( +<#list case.lines as line> + "${line?j_string}"<#sep>, + + ) +<#else>.also { lines -> + check(${case.param}) + } + + } +<#sep> + + +} \ No newline at end of file diff --git a/docs/select-expression.md b/docs/select-expression.md index f36fa09b6b..5809e7b93e 100644 --- a/docs/select-expression.md +++ b/docs/select-expression.md @@ -1,21 +1,4 @@ - - - - + **Table of contents** @@ -28,9 +11,7 @@ class SelectGuideTest { * [Selecting deferred values](#selecting-deferred-values) * [Switch over a channel of deferred values](#switch-over-a-channel-of-deferred-values) - - - + ## Select Expression (experimental) diff --git a/docs/shared-mutable-state-and-concurrency.md b/docs/shared-mutable-state-and-concurrency.md index 30d7334e6c..1a3c406472 100644 --- a/docs/shared-mutable-state-and-concurrency.md +++ b/docs/shared-mutable-state-and-concurrency.md @@ -1,20 +1,5 @@ - - - + + **Table of contents** @@ -28,7 +13,7 @@ class SharedStateGuideTest { * [Mutual exclusion](#mutual-exclusion) * [Actors](#actors) - + ## Shared mutable state and concurrency diff --git a/gradle.properties b/gradle.properties index b693ededcd..38fdeb03d9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # -# Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. +# Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. # # Kotlin @@ -10,6 +10,7 @@ kotlin_version=1.3.61 # Dependencies junit_version=4.12 atomicfu_version=0.14.1 +knit_version=0.1.2 html_version=0.6.8 lincheck_version=2.5.3 dokka_version=0.9.16-rdev-2-mpp-hacks diff --git a/integration/kotlinx-coroutines-play-services/build.gradle b/integration/kotlinx-coroutines-play-services/build.gradle index 61201faeb7..eb554866ed 100644 --- a/integration/kotlinx-coroutines-play-services/build.gradle +++ b/integration/kotlinx-coroutines-play-services/build.gradle @@ -1,32 +1,43 @@ +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +import org.gradle.api.artifacts.transform.* + import java.nio.file.Files -import java.nio.file.NoSuchFileException import java.util.zip.ZipEntry import java.util.zip.ZipFile -/* - * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - ext.tasks_version = '16.0.1' -def attr = Attribute.of("artifactType", String.class) -configurations { - aar { - attributes { attribute(attr, ArtifactTypeDefinition.JAR_TYPE) } - sourceSets.main.compileClasspath += it - sourceSets.test.compileClasspath += it - sourceSets.test.runtimeClasspath += it +def artifactType = Attribute.of("artifactType", String) +def unpackedAar = Attribute.of("unpackedAar", Boolean) + +configurations.all { + afterEvaluate { + if (canBeResolved) { + attributes.attribute(unpackedAar, true) // request all AARs to be unpacked + } } } dependencies { - registerTransform { - from.attribute(attr, "aar") - to.attribute(attr, "jar") - artifactTransform(ExtractJars.class) + attributesSchema { + attribute(unpackedAar) + } + + artifactTypes { + aar { + attributes.attribute(unpackedAar, false) + } } - aar("com.google.android.gms:play-services-tasks:$tasks_version") { + registerTransform(UnpackAar) { + from.attribute(unpackedAar, false).attribute(artifactType, "aar") + to.attribute(unpackedAar, true).attribute(artifactType, "jar") + } + + api("com.google.android.gms:play-services-tasks:$tasks_version") { exclude group: 'com.android.support' } } @@ -37,48 +48,32 @@ tasks.withType(dokka.getClass()) { // This is workaround for missing package list in Google API packageListUrl = projectDir.toPath().resolve("package.list").toUri().toURL() } - - afterEvaluate { - classpath += project.configurations.aar.files - } } -class ExtractJars extends ArtifactTransform { - @Override - List transform(File input) { - unzip(input) - - List jars = new ArrayList<>() - outputDirectory.traverse(nameFilter: ~/.*\.jar/) { jars += it } +abstract class UnpackAar implements TransformAction { + @InputArtifact + abstract Provider getInputArtifact() - return jars - } - - private void unzip(File zipFile) { - ZipFile zip + @Override + void transform(TransformOutputs outputs) { + ZipFile zip = new ZipFile(inputArtifact.get().asFile) try { - zip = new ZipFile(zipFile) for (entry in zip.entries()) { - unzipEntryTo(zip, entry) + if (!entry.isDirectory() && entry.name.endsWith(".jar")) { + unzipEntryTo(zip, entry, outputs.file(entry.name)) + } } } finally { - if (zip != null) zip.close() + zip.close() } } - private void unzipEntryTo(ZipFile zip, ZipEntry entry) { - File output = new File(outputDirectory, entry.name) - if (entry.isDirectory()) { - output.mkdirs() - } else { - InputStream stream - try { - stream = zip.getInputStream(entry) - Files.copy(stream, output.toPath()) - } catch (NoSuchFileException ignored) { - } finally { - if (stream != null) stream.close() - } + private static void unzipEntryTo(ZipFile zip, ZipEntry entry, File output) { + InputStream stream = zip.getInputStream(entry) + try { + Files.copy(stream, output.toPath()) + } finally { + stream.close() } } } diff --git a/integration/kotlinx-coroutines-play-services/test/TaskTest.kt b/integration/kotlinx-coroutines-play-services/test/TaskTest.kt index b87a295449..0f125ac98c 100644 --- a/integration/kotlinx-coroutines-play-services/test/TaskTest.kt +++ b/integration/kotlinx-coroutines-play-services/test/TaskTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ package kotlinx.coroutines.tasks @@ -61,7 +61,7 @@ class TaskTest : TestBase() { @Test fun testThrowingAsTask() { - val deferred = GlobalScope.async { + val deferred = GlobalScope.async { throw TestException("Fail") } diff --git a/knit/README.md b/knit/README.md deleted file mode 100644 index ca0560fa6c..0000000000 --- a/knit/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Knit - -This is a very simple tool that produces Kotlin source example files from a markdown document that includes -snippets of Kotlin code in its body. It is used to produce examples for -[coroutines guide](../docs/coroutines-guide.md) and other markdown documents. -It also includes links to the documentation web site into the documents. - -## Usage - -* In project root directory do: - * Run `./gradlew knit` -* Commit updated documents and examples - diff --git a/knit/build.gradle b/knit/build.gradle deleted file mode 100644 index 0410d5d268..0000000000 --- a/knit/build.gradle +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -apply plugin: "application" - -sourceSets { - main.kotlin.srcDirs = ['src'] - main.java.srcDirs = ['src'] - main.resources.srcDirs = ['resources'] -} - -FileTree mdFiles = fileTree(project.rootDir) { - include '**/*.md' - exclude '**/build/**' - exclude '**/.gradle/**' - exclude '**/node_modules/**' -} - -mainClassName = "KnitKt" - -run.dependsOn rootProject.getTasksByName("dokka", true) -run.args = mdFiles -run.workingDir = project.rootDir - -task knit(dependsOn: run) diff --git a/knit/resources/knit.properties b/knit/resources/knit.properties deleted file mode 100644 index 146c182339..0000000000 --- a/knit/resources/knit.properties +++ /dev/null @@ -1,9 +0,0 @@ -# -# Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. -# - -site.root=https://kotlin.github.io/kotlinx.coroutines - -module.roots=. integration reactive ui -module.marker=build.gradle -module.docs=build/dokka \ No newline at end of file diff --git a/knit/src/Knit.kt b/knit/src/Knit.kt deleted file mode 100644 index 30dd678fd1..0000000000 --- a/knit/src/Knit.kt +++ /dev/null @@ -1,598 +0,0 @@ -/* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -import java.io.* -import java.util.* -import kotlin.properties.* - -// --- props in knit.properties - -val knitProperties = ClassLoader.getSystemClassLoader() - .getResource("knit.properties").openStream().use { Properties().apply { load(it) } } - -val siteRoot = knitProperties.getProperty("site.root")!! -val moduleRoots = knitProperties.getProperty("module.roots").split(" ") -val moduleMarker = knitProperties.getProperty("module.marker")!! -val moduleDocs = knitProperties.getProperty("module.docs")!! - -// --- markdown syntax - -const val DIRECTIVE_START = "" - -const val TOC_DIRECTIVE = "TOC" -const val TOC_REF_DIRECTIVE = "TOC_REF" -const val KNIT_DIRECTIVE = "KNIT" -const val INCLUDE_DIRECTIVE = "INCLUDE" -const val CLEAR_DIRECTIVE = "CLEAR" -const val TEST_DIRECTIVE = "TEST" - -const val KNIT_AUTONUMBER_PLACEHOLDER = '#' -const val KNIT_AUTONUMBER_REGEX = "([0-9a-z]+)" - -const val TEST_OUT_DIRECTIVE = "TEST_OUT" - -const val MODULE_DIRECTIVE = "MODULE" -const val INDEX_DIRECTIVE = "INDEX" - -const val CODE_START = "```kotlin" -const val CODE_END = "```" - -const val SAMPLE_START = "//sampleStart" -const val SAMPLE_END = "//sampleEnd" - -const val TEST_START = "```text" -const val TEST_END = "```" - -const val SECTION_START = "##" - -const val PACKAGE_PREFIX = "package " -const val STARTS_WITH_PREDICATE = "STARTS_WITH" -const val ARBITRARY_TIME_PREDICATE = "ARBITRARY_TIME" -const val FLEXIBLE_TIME_PREDICATE = "FLEXIBLE_TIME" -const val FLEXIBLE_THREAD_PREDICATE = "FLEXIBLE_THREAD" -const val LINES_START_UNORDERED_PREDICATE = "LINES_START_UNORDERED" -const val EXCEPTION_MODE = "EXCEPTION" -const val LINES_START_PREDICATE = "LINES_START" - -val API_REF_REGEX = Regex("(^|[ \\](])\\[([A-Za-z0-9_().]+)]($|[^\\[(])") -val LINK_DEF_REGEX = Regex("^\\[([A-Za-z0-9_().]+)]: .*") - -val tocRefMap = HashMap>() -val fileSet = HashSet() -val fileQueue = ArrayDeque() - -fun main(args: Array) { - if (args.isEmpty()) { - println("Usage: Knit ") - return - } - args.map { File(it) }.toCollection(fileQueue) - fileQueue.toCollection(fileSet) - while (!fileQueue.isEmpty()) { - if (!knit(fileQueue.removeFirst())) System.exit(1) // abort on first error with error exit code - } -} - -fun knit(markdownFile: File): Boolean { - println("*** Reading $markdownFile") - val tocLines = arrayListOf() - var knitRegex: Regex? = null - var knitAutonumberGroup = 0 - var knitAutonumberDigits = 0 - var knitAutonumberIndex = 1 - val includes = arrayListOf() - val codeLines = arrayListOf() - val testLines = arrayListOf() - var testOut: String? = null - val testOutLines = arrayListOf() - var lastPgk: String? = null - val files = mutableSetOf() - val allApiRefs = arrayListOf() - val remainingApiRefNames = mutableSetOf() - var moduleName: String by Delegates.notNull() - var docsRoot: String by Delegates.notNull() - var retryKnitLater = false - val tocRefs = ArrayList().also { tocRefMap[markdownFile] = it } - // read markdown file - val markdown = markdownFile.withMarkdownTextReader { - mainLoop@ while (true) { - val inLine = readLine() ?: break - val directive = directive(inLine) - if (directive != null && markdownPart == MarkdownPart.TOC) { - markdownPart = MarkdownPart.POST_TOC - postTocText += inLine - } - when (directive?.name) { - TOC_DIRECTIVE -> { - requireSingleLine(directive) - require(directive.param.isEmpty()) { "$TOC_DIRECTIVE directive must not have parameters" } - require(markdownPart == MarkdownPart.PRE_TOC) { "Only one TOC directive is supported" } - markdownPart = MarkdownPart.TOC - } - TOC_REF_DIRECTIVE -> { - requireSingleLine(directive) - require(!directive.param.isEmpty()) { "$TOC_REF_DIRECTIVE directive must include reference file path" } - val refPath = directive.param - val refFile = File(markdownFile.parent, refPath.replace('/', File.separatorChar)) - require(fileSet.contains(refFile)) { "Referenced file $refFile is missing from the processed file set" } - val toc = tocRefMap[refFile] - if (toc == null) { - retryKnitLater = true // put this file at the end of the queue and retry later - } else { - val lines = toc.map { (levelPrefix, name, ref) -> - "$levelPrefix [$name]($refPath#$ref)" - } - if (!replaceUntilNextDirective(lines)) error("Unexpected end of file after $TOC_REF_DIRECTIVE") - } - } - KNIT_DIRECTIVE -> { - requireSingleLine(directive) - require(!directive.param.isEmpty()) { "$KNIT_DIRECTIVE directive must include regex parameter" } - require(knitRegex == null) { "Only one KNIT directive is supported"} - var str = directive.param - val i = str.indexOf(KNIT_AUTONUMBER_PLACEHOLDER) - if (i >= 0) { - val j = str.lastIndexOf(KNIT_AUTONUMBER_PLACEHOLDER) - knitAutonumberDigits = j - i + 1 - require(str.substring(i, j + 1) == KNIT_AUTONUMBER_PLACEHOLDER.toString().repeat(knitAutonumberDigits)) { - "$KNIT_DIRECTIVE can only use a contiguous range of '$KNIT_AUTONUMBER_PLACEHOLDER' for auto-numbering" - } - knitAutonumberGroup = str.substring(0, i).count { it == '(' } + 2 // note: it does not understand escaped open braces - str = str.substring(0, i) + KNIT_AUTONUMBER_REGEX + str.substring(j + 1) - } - knitRegex = Regex("\\((" + str + ")\\)") - continue@mainLoop - } - INCLUDE_DIRECTIVE -> { - if (directive.param.isEmpty()) { - require(!directive.singleLine) { "$INCLUDE_DIRECTIVE directive without parameters must not be single line" } - readUntilTo(DIRECTIVE_END, codeLines) - } else { - val include = Include(Regex(directive.param)) - if (directive.singleLine) { - include.lines += codeLines - codeLines.clear() - } else { - readUntilTo(DIRECTIVE_END, include.lines) - } - includes += include - } - continue@mainLoop - } - CLEAR_DIRECTIVE -> { - requireSingleLine(directive) - require(directive.param.isEmpty()) { "$CLEAR_DIRECTIVE directive must not have parameters" } - codeLines.clear() - continue@mainLoop - } - TEST_OUT_DIRECTIVE -> { - require(!directive.param.isEmpty()) { "$TEST_OUT_DIRECTIVE directive must include file name parameter" } - flushTestOut(markdownFile.parentFile, testOut, testOutLines) - testOut = directive.param - readUntil(DIRECTIVE_END).forEach { testOutLines += it } - } - TEST_DIRECTIVE -> { - require(lastPgk != null) { "'$PACKAGE_PREFIX' prefix was not found in emitted code"} - require(testOut != null) { "$TEST_OUT_DIRECTIVE directive was not specified" } - val predicate = directive.param - if (testLines.isEmpty()) { - if (directive.singleLine) { - require(!predicate.isEmpty()) { "$TEST_OUT_DIRECTIVE must be preceded by $TEST_START block or contain test predicate"} - } else - testLines += readUntil(DIRECTIVE_END) - } else { - requireSingleLine(directive) - } - makeTest(testOutLines, lastPgk!!, testLines, predicate) - testLines.clear() - } - MODULE_DIRECTIVE -> { - requireSingleLine(directive) - moduleName = directive.param - docsRoot = findModuleRootDir(moduleName) + "/" + moduleDocs + "/" + moduleName - } - INDEX_DIRECTIVE -> { - requireSingleLine(directive) - val indexLines = processApiIndex("$siteRoot/$moduleName", docsRoot, directive.param, remainingApiRefNames) - ?: throw IllegalArgumentException("Failed to load index for ${directive.param}") - if (!replaceUntilNextDirective(indexLines)) error("Unexpected end of file after $INDEX_DIRECTIVE") - } - } - if (inLine.startsWith(CODE_START)) { - require(testOut == null || testLines.isEmpty()) { "Previous test was not emitted with $TEST_DIRECTIVE" } - codeLines += "" - readUntilTo(CODE_END, codeLines) { line -> - !line.startsWith(SAMPLE_START) && !line.startsWith(SAMPLE_END) - } - continue@mainLoop - } - if (inLine.startsWith(TEST_START)) { - require(testOut == null || testLines.isEmpty()) { "Previous test was not emitted with $TEST_DIRECTIVE" } - readUntilTo(TEST_END, testLines) - continue@mainLoop - } - if (inLine.startsWith(SECTION_START) && markdownPart == MarkdownPart.POST_TOC) { - val i = inLine.indexOf(' ') - require(i >= 2) { "Invalid section start" } - val name = inLine.substring(i + 1).trim() - val levelPrefix = " ".repeat(i - 2) + "*" - val sectionRef = makeSectionRef(name) - tocLines += "$levelPrefix [$name](#$sectionRef)" - tocRefs += TocRef(levelPrefix, name, sectionRef) - continue@mainLoop - } - val linkDefMatch = LINK_DEF_REGEX.matchEntire(inLine) - if (linkDefMatch != null) { - val name = linkDefMatch.groups[1]!!.value - remainingApiRefNames -= name - } else { - for (match in API_REF_REGEX.findAll(inLine)) { - val apiRef = ApiRef(lineNumber, match.groups[2]!!.value) - allApiRefs += apiRef - remainingApiRefNames += apiRef.name - } - } - knitRegex?.find(inLine)?.let knitRegexMatch@{ knitMatch -> - val fileName = knitMatch.groups[1]!!.value - if (knitAutonumberDigits != 0) { - val numGroup = knitMatch.groups[knitAutonumberGroup]!! - val num = knitAutonumberIndex.toString().padStart(knitAutonumberDigits, '0') - if (numGroup.value != num) { // update and retry with this line if a different number - val r = numGroup.range - val newLine = inLine.substring(0, r.first) + num + inLine.substring(r.last + 1) - updateLineAndRetry(newLine) - return@knitRegexMatch - } - } - knitAutonumberIndex++ - val file = File(markdownFile.parentFile, fileName) - require(files.add(file)) { "Duplicate file: $file"} - println("Knitting $file ...") - val outLines = arrayListOf() - for (include in includes) { - val includeMatch = include.regex.matchEntire(fileName) ?: continue - include.lines.forEach { includeLine -> - val line = makeReplacements(includeLine, includeMatch) - if (line.startsWith(PACKAGE_PREFIX)) - lastPgk = line.substring(PACKAGE_PREFIX.length).trim() - outLines += line - } - } - for (code in codeLines) { - outLines += code.replace("System.currentTimeMillis()", "currentTimeMillis()") - } - codeLines.clear() - writeLinesIfNeeded(file, outLines) - } - } - } ?: return false // false when failed - // bailout if retry was requested - if (retryKnitLater) { - fileQueue.add(markdownFile) - return true - } - // update markdown file with toc - val newLines = buildList { - addAll(markdown.preTocText) - if (!tocLines.isEmpty()) { - add("") - addAll(tocLines) - add("") - } - addAll(markdown.postTocText) - } - if (newLines != markdown.inText) writeLines(markdownFile, newLines) - // check apiRefs - for (apiRef in allApiRefs) { - if (apiRef.name in remainingApiRefNames) { - println("WARNING: $markdownFile: ${apiRef.line}: Broken reference to [${apiRef.name}]") - } - } - // write test output - flushTestOut(markdownFile.parentFile, testOut, testOutLines) - return true -} - -data class TocRef(val levelPrefix: String, val name: String, val ref: String) - -fun makeTest(testOutLines: MutableList, pgk: String, test: List, predicate: String) { - val funName = buildString { - var cap = true - for (c in pgk) { - if (c == '.') { - cap = true - } else { - append(if (cap) c.toUpperCase() else c) - cap = false - } - } - } - testOutLines += "" - testOutLines += " @Test" - testOutLines += " fun test$funName() {" - val prefix = " test(\"$funName\") { $pgk.main() }" - when (predicate) { - "" -> makeTestLines(testOutLines, prefix, "verifyLines", test) - STARTS_WITH_PREDICATE -> makeTestLines(testOutLines, prefix, "verifyLinesStartWith", test) - ARBITRARY_TIME_PREDICATE -> makeTestLines(testOutLines, prefix, "verifyLinesArbitraryTime", test) - FLEXIBLE_TIME_PREDICATE -> makeTestLines(testOutLines, prefix, "verifyLinesFlexibleTime", test) - FLEXIBLE_THREAD_PREDICATE -> makeTestLines(testOutLines, prefix, "verifyLinesFlexibleThread", test) - LINES_START_UNORDERED_PREDICATE -> makeTestLines(testOutLines, prefix, "verifyLinesStartUnordered", test) - EXCEPTION_MODE -> makeTestLines(testOutLines, prefix, "verifyExceptions", test) - LINES_START_PREDICATE -> makeTestLines(testOutLines, prefix, "verifyLinesStart", test) - else -> { - testOutLines += "$prefix.also { lines ->" - testOutLines += " check($predicate)" - testOutLines += " }" - } - } - testOutLines += " }" -} - -private fun makeTestLines(testOutLines: MutableList, prefix: String, method: String, test: List) { - testOutLines += "$prefix.$method(" - for ((index, testLine) in test.withIndex()) { - val commaOpt = if (index < test.size - 1) "," else "" - val escapedLine = testLine.replace("\"", "\\\"") - testOutLines += " \"$escapedLine\"$commaOpt" - } - testOutLines += " )" -} - -private fun makeReplacements(line: String, match: MatchResult): String { - var result = line - for ((id, group) in match.groups.withIndex()) { - if (group != null) - result = result.replace("\$\$$id", group.value) - } - return result -} - -private fun flushTestOut(parentDir: File?, testOut: String?, testOutLines: MutableList) { - if (testOut == null) return - val file = File(parentDir, testOut) - testOutLines += "}" - writeLinesIfNeeded(file, testOutLines) - testOutLines.clear() -} - -private fun MarkdownTextReader.readUntil(marker: String): List = - arrayListOf().also { readUntilTo(marker, it) } - -private fun MarkdownTextReader.readUntilTo(marker: String, list: MutableList, linePredicate: (String) -> Boolean = { true }) { - while (true) { - val line = readLine() ?: break - if (line.startsWith(marker)) break - if (linePredicate(line)) list += line - } -} - -private inline fun buildList(block: ArrayList.() -> Unit): List { - val result = arrayListOf() - result.block() - return result -} - -private fun requireSingleLine(directive: Directive) { - require(directive.singleLine) { "${directive.name} directive must end on the same line with '$DIRECTIVE_END'" } -} - -fun makeSectionRef(name: String): String = name - .replace(' ', '-') - .replace(".", "") - .replace(",", "") - .replace("(", "") - .replace(")", "") - .replace("`", "") - .toLowerCase() - -class Include(val regex: Regex, val lines: MutableList = arrayListOf()) - -class Directive( - val name: String, - val param: String, - val singleLine: Boolean -) - -fun directive(line: String): Directive? { - if (!line.startsWith(DIRECTIVE_START)) return null - var s = line.substring(DIRECTIVE_START.length).trim() - val singleLine = s.endsWith(DIRECTIVE_END) - if (singleLine) s = s.substring(0, s.length - DIRECTIVE_END.length) - val i = s.indexOf(' ') - val name = if (i < 0) s else s.substring(0, i) - val param = if (i < 0) "" else s.substring(i).trim() - return Directive(name, param, singleLine) -} - -class ApiRef(val line: Int, val name: String) - -enum class MarkdownPart { PRE_TOC, TOC, POST_TOC } - -class MarkdownTextReader(r: Reader) : LineNumberReader(r) { - val inText = arrayListOf() - val preTocText = arrayListOf() - val postTocText = arrayListOf() - var markdownPart: MarkdownPart = MarkdownPart.PRE_TOC - var skip = false - var putBackLine: String? = null - - val outText: MutableList get() = when (markdownPart) { - MarkdownPart.PRE_TOC -> preTocText - MarkdownPart.POST_TOC -> postTocText - else -> throw IllegalStateException("Wrong state: $markdownPart") - } - - override fun readLine(): String? { - putBackLine?.let { - putBackLine = null - return it - } - val line = super.readLine() ?: return null - inText += line - if (!skip && markdownPart != MarkdownPart.TOC) - outText += line - return line - } - - fun updateLineAndRetry(line: String) { - outText.removeAt(outText.lastIndex) - outText += line - putBackLine = line - } - - fun replaceUntilNextDirective(lines: List): Boolean { - skip = true - while (true) { - val skipLine = readLine() ?: return false - if (directive(skipLine) != null) { - putBackLine = skipLine - break - } - } - skip = false - outText += lines - outText += putBackLine!! - return true - } -} - -fun File.withLineNumberReader(factory: (Reader) -> T, block: T.() -> Unit): T? { - val reader = factory(reader()) - reader.use { - try { - it.block() - } catch (e: Exception) { - println("ERROR: ${this@withLineNumberReader}: ${it.lineNumber}: ${e.message}") - return null - } - } - return reader -} - -fun File.withMarkdownTextReader(block: MarkdownTextReader.() -> Unit): MarkdownTextReader? = - withLineNumberReader(::MarkdownTextReader, block) - -fun writeLinesIfNeeded(file: File, outLines: List) { - val oldLines = try { - file.readLines() - } catch (e: IOException) { - emptyList() - } - if (outLines != oldLines) writeLines(file, outLines) -} - -fun writeLines(file: File, lines: List) { - println(" Writing $file ...") - file.parentFile?.mkdirs() - file.printWriter().use { out -> - lines.forEach { out.println(it) } - } -} - -fun findModuleRootDir(name: String): String = - moduleRoots - .map { "$it/$name" } - .firstOrNull { File("$it/$moduleMarker").exists() } - ?: throw IllegalArgumentException("Module $name is not found in any of the module root dirs") - -data class ApiIndexKey( - val docsRoot: String, - val pkg: String -) - -val apiIndexCache: MutableMap>> = HashMap() - -val REF_LINE_REGEX = Regex("([a-zA-z0-9.]+)") -val INDEX_HTML = "/index.html" -val INDEX_MD = "/index.md" -val FUNCTIONS_SECTION_HEADER = "### Functions" - -fun HashMap>.putUnambiguous(key: String, value: String) { - val oldValue = this[key] - if (oldValue != null) { - oldValue.add(value) - put(key, oldValue) - } else { - put(key, mutableListOf(value)) - } -} - -fun loadApiIndex( - docsRoot: String, - path: String, - pkg: String, - namePrefix: String = "" -): Map>? { - val fileName = "$docsRoot/$path$INDEX_MD" - val visited = mutableSetOf() - val map = HashMap>() - var inFunctionsSection = false - File(fileName).withLineNumberReader(::LineNumberReader) { - while (true) { - val line = readLine() ?: break - if (line == FUNCTIONS_SECTION_HEADER) inFunctionsSection = true - val result = REF_LINE_REGEX.matchEntire(line) ?: continue - val link = result.groups[1]!!.value - if (link.startsWith("..")) continue // ignore cross-references - val absLink = "$path/$link" - var name = result.groups[2]!!.value - // a special disambiguation fix for pseudo-constructor functions - if (inFunctionsSection && name[0] in 'A'..'Z') name += "()" - val refName = namePrefix + name - val fqName = "$pkg.$refName" - // Put shorter names for extensions on 3rd party classes (prefix is FQname of those classes) - if (namePrefix != "" && namePrefix[0] in 'a'..'z') { - val i = namePrefix.dropLast(1).lastIndexOf('.') - if (i >= 0) map.putUnambiguous(namePrefix.substring(i + 1) + name, absLink) - map.putUnambiguous(name, absLink) - } - // Disambiguate lower-case names with leading underscore (e.g. Flow class vs flow builder ambiguity) - if (namePrefix == "" && name[0] in 'a'..'z') { - map.putUnambiguous("_$name", absLink) - } - // Always put fully qualified names - map.putUnambiguous(refName, absLink) - map.putUnambiguous(fqName, absLink) - if (link.endsWith(INDEX_HTML)) { - if (visited.add(link)) { - val path2 = path + "/" + link.substring(0, link.length - INDEX_HTML.length) - map += loadApiIndex(docsRoot, path2, pkg, "$refName.") - ?: throw IllegalArgumentException("Failed to parse $docsRoot/$path2") - } - } - } - } ?: return null // return null on failure - return map -} - -fun processApiIndex( - siteRoot: String, - docsRoot: String, - pkg: String, - remainingApiRefNames: MutableSet -): List? { - val key = ApiIndexKey(docsRoot, pkg) - val map = apiIndexCache.getOrPut(key, { - print("Parsing API docs at $docsRoot/$pkg: ") - val result = loadApiIndex(docsRoot, pkg, pkg) ?: return null // null on failure - println("${result.size} definitions") - result - }) - val indexList = arrayListOf() - val it = remainingApiRefNames.iterator() - while (it.hasNext()) { - val refName = it.next() - val refLink = map[refName] ?: continue - if (refLink.size > 1) { - println("INFO: Ambiguous reference to [$refName]: $refLink, taking the shortest one") - } - - val link = refLink.minBy { it.length } - indexList += "[$refName]: $siteRoot/$link" - it.remove() - } - return indexList -} diff --git a/kotlinx-coroutines-core/build.gradle b/kotlinx-coroutines-core/build.gradle index 832321493a..547a12b4c6 100644 --- a/kotlinx-coroutines-core/build.gradle +++ b/kotlinx-coroutines-core/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ apply plugin: 'kotlin-multiplatform' @@ -57,6 +57,7 @@ compileKotlinMetadata { kotlin.sourceSets { jvmTest.dependencies { api "org.jetbrains.kotlinx:lincheck:$lincheck_version" + api "org.jetbrains.kotlinx:kotlinx-knit-test:$knit_version" api "com.esotericsoftware:kryo:4.0.0" implementation project (":android-unit-tests") } diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-basic-01.kt b/kotlinx-coroutines-core/jvm/test/guide/example-basic-01.kt index dcb36af536..15e126149b 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-basic-01.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-basic-01.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.basic01 +// This file was automatically generated from basics.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleBasic01 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-basic-02.kt b/kotlinx-coroutines-core/jvm/test/guide/example-basic-02.kt index 4f1277d4a4..4f178ca6b3 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-basic-02.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-basic-02.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.basic02 +// This file was automatically generated from basics.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleBasic02 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-basic-02b.kt b/kotlinx-coroutines-core/jvm/test/guide/example-basic-02b.kt deleted file mode 100644 index a78840d5e1..0000000000 --- a/kotlinx-coroutines-core/jvm/test/guide/example-basic-02b.kt +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.basic02b - -import kotlinx.coroutines.* - -fun main() = runBlocking { // start main coroutine - GlobalScope.launch { // launch a new coroutine in background and continue - delay(1000L) - println("World!") - } - println("Hello,") // main coroutine continues here immediately - delay(2000L) // delaying for 2 seconds to keep JVM alive -} diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-basic-03.kt b/kotlinx-coroutines-core/jvm/test/guide/example-basic-03.kt index a35e848196..f80113c57f 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-basic-03.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-basic-03.kt @@ -1,17 +1,17 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.basic03 +// This file was automatically generated from basics.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleBasic03 import kotlinx.coroutines.* -fun main() = runBlocking { - val job = GlobalScope.launch { // launch a new coroutine and keep a reference to its Job +fun main() = runBlocking { // start main coroutine + GlobalScope.launch { // launch a new coroutine in background and continue delay(1000L) println("World!") } - println("Hello,") - job.join() // wait until child coroutine completes + println("Hello,") // main coroutine continues here immediately + delay(2000L) // delaying for 2 seconds to keep JVM alive } diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-basic-03s.kt b/kotlinx-coroutines-core/jvm/test/guide/example-basic-03s.kt deleted file mode 100644 index 13cf679ab9..0000000000 --- a/kotlinx-coroutines-core/jvm/test/guide/example-basic-03s.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.basic03s - -import kotlinx.coroutines.* - -fun main() = runBlocking { // this: CoroutineScope - launch { // launch a new coroutine in the scope of runBlocking - delay(1000L) - println("World!") - } - println("Hello,") -} diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-basic-04.kt b/kotlinx-coroutines-core/jvm/test/guide/example-basic-04.kt index 3afa0fe5c7..33c928a008 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-basic-04.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-basic-04.kt @@ -1,27 +1,17 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.basic04 +// This file was automatically generated from basics.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleBasic04 import kotlinx.coroutines.* -fun main() = runBlocking { // this: CoroutineScope - launch { - delay(200L) - println("Task from runBlocking") +fun main() = runBlocking { + val job = GlobalScope.launch { // launch a new coroutine and keep a reference to its Job + delay(1000L) + println("World!") } - - coroutineScope { // Creates a coroutine scope - launch { - delay(500L) - println("Task from nested launch") - } - - delay(100L) - println("Task from coroutine scope") // This line will be printed before the nested launch - } - - println("Coroutine scope is over") // This line is not printed until the nested launch completes + println("Hello,") + job.join() // wait until child coroutine completes } diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-basic-05.kt b/kotlinx-coroutines-core/jvm/test/guide/example-basic-05.kt index e6a911291d..52b490d2b7 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-basic-05.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-basic-05.kt @@ -1,19 +1,16 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.basic05 +// This file was automatically generated from basics.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleBasic05 import kotlinx.coroutines.* -fun main() = runBlocking { - launch { doWorld() } +fun main() = runBlocking { // this: CoroutineScope + launch { // launch a new coroutine in the scope of runBlocking + delay(1000L) + println("World!") + } println("Hello,") } - -// this is your first suspending function -suspend fun doWorld() { - delay(1000L) - println("World!") -} diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-basic-05s.kt b/kotlinx-coroutines-core/jvm/test/guide/example-basic-05s.kt deleted file mode 100644 index 876f9a1aeb..0000000000 --- a/kotlinx-coroutines-core/jvm/test/guide/example-basic-05s.kt +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.basic05s - -import kotlinx.coroutines.* - -fun main(args: Array) = runBlocking { - launchDoWorld() - println("Hello,") -} - -// this is your first suspending function -suspend fun launchDoWorld() = coroutineScope { - launch { - println("World!") - } -} diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-basic-06.kt b/kotlinx-coroutines-core/jvm/test/guide/example-basic-06.kt index 60de941d49..a1b5bc5f23 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-basic-06.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-basic-06.kt @@ -1,17 +1,27 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.basic06 +// This file was automatically generated from basics.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleBasic06 import kotlinx.coroutines.* -fun main() = runBlocking { - repeat(100_000) { // launch a lot of coroutines +fun main() = runBlocking { // this: CoroutineScope + launch { + delay(200L) + println("Task from runBlocking") + } + + coroutineScope { // Creates a coroutine scope launch { - delay(1000L) - print(".") + delay(500L) + println("Task from nested launch") } + + delay(100L) + println("Task from coroutine scope") // This line will be printed before the nested launch } + + println("Coroutine scope is over") // This line is not printed until the nested launch completes } diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-basic-07.kt b/kotlinx-coroutines-core/jvm/test/guide/example-basic-07.kt index 56e785fb7f..32c02b86e5 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-basic-07.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-basic-07.kt @@ -1,18 +1,19 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.basic07 +// This file was automatically generated from basics.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleBasic07 import kotlinx.coroutines.* fun main() = runBlocking { - GlobalScope.launch { - repeat(1000) { i -> - println("I'm sleeping $i ...") - delay(500L) - } - } - delay(1300L) // just quit after delay + launch { doWorld() } + println("Hello,") +} + +// this is your first suspending function +suspend fun doWorld() { + delay(1000L) + println("World!") } diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-basic-08.kt b/kotlinx-coroutines-core/jvm/test/guide/example-basic-08.kt new file mode 100644 index 0000000000..ff11eb70d7 --- /dev/null +++ b/kotlinx-coroutines-core/jvm/test/guide/example-basic-08.kt @@ -0,0 +1,17 @@ +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +// This file was automatically generated from basics.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleBasic08 + +import kotlinx.coroutines.* + +fun main() = runBlocking { + repeat(100_000) { // launch a lot of coroutines + launch { + delay(1000L) + print(".") + } + } +} diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-basic-09.kt b/kotlinx-coroutines-core/jvm/test/guide/example-basic-09.kt new file mode 100644 index 0000000000..9f998b5244 --- /dev/null +++ b/kotlinx-coroutines-core/jvm/test/guide/example-basic-09.kt @@ -0,0 +1,18 @@ +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +// This file was automatically generated from basics.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleBasic09 + +import kotlinx.coroutines.* + +fun main() = runBlocking { + GlobalScope.launch { + repeat(1000) { i -> + println("I'm sleeping $i ...") + delay(500L) + } + } + delay(1300L) // just quit after delay +} diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-cancel-01.kt b/kotlinx-coroutines-core/jvm/test/guide/example-cancel-01.kt index ebf5171e2e..a1b036d91f 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-cancel-01.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-cancel-01.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.cancel01 +// This file was automatically generated from cancellation-and-timeouts.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleCancel01 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-cancel-02.kt b/kotlinx-coroutines-core/jvm/test/guide/example-cancel-02.kt index e3127b41ba..f6dec6e8f4 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-cancel-02.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-cancel-02.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.cancel02 +// This file was automatically generated from cancellation-and-timeouts.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleCancel02 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-cancel-03.kt b/kotlinx-coroutines-core/jvm/test/guide/example-cancel-03.kt index d47ecd9dda..3daaf49b36 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-cancel-03.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-cancel-03.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.cancel03 +// This file was automatically generated from cancellation-and-timeouts.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleCancel03 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-cancel-04.kt b/kotlinx-coroutines-core/jvm/test/guide/example-cancel-04.kt index 45c97851aa..b1b9a9bfd5 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-cancel-04.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-cancel-04.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.cancel04 +// This file was automatically generated from cancellation-and-timeouts.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleCancel04 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-cancel-05.kt b/kotlinx-coroutines-core/jvm/test/guide/example-cancel-05.kt index 9f2cac1c23..9772ae5739 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-cancel-05.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-cancel-05.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.cancel05 +// This file was automatically generated from cancellation-and-timeouts.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleCancel05 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-cancel-06.kt b/kotlinx-coroutines-core/jvm/test/guide/example-cancel-06.kt index f06d1187e4..e1afd057c4 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-cancel-06.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-cancel-06.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.cancel06 +// This file was automatically generated from cancellation-and-timeouts.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleCancel06 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-cancel-07.kt b/kotlinx-coroutines-core/jvm/test/guide/example-cancel-07.kt index e2880c9129..8c57b42903 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-cancel-07.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-cancel-07.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.cancel07 +// This file was automatically generated from cancellation-and-timeouts.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleCancel07 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-channel-01.kt b/kotlinx-coroutines-core/jvm/test/guide/example-channel-01.kt index 36c6db316b..0af1ebd311 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-channel-01.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-channel-01.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.channel01 +// This file was automatically generated from channels.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleChannel01 import kotlinx.coroutines.* import kotlinx.coroutines.channels.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-channel-02.kt b/kotlinx-coroutines-core/jvm/test/guide/example-channel-02.kt index 59f5a76807..33eb7b33dd 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-channel-02.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-channel-02.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.channel02 +// This file was automatically generated from channels.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleChannel02 import kotlinx.coroutines.* import kotlinx.coroutines.channels.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-channel-03.kt b/kotlinx-coroutines-core/jvm/test/guide/example-channel-03.kt index 5c9cfb181f..4a2613be6a 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-channel-03.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-channel-03.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.channel03 +// This file was automatically generated from channels.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleChannel03 import kotlinx.coroutines.* import kotlinx.coroutines.channels.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-channel-04.kt b/kotlinx-coroutines-core/jvm/test/guide/example-channel-04.kt index 4eb6c37d2c..fe39814640 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-channel-04.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-channel-04.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.channel04 +// This file was automatically generated from channels.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleChannel04 import kotlinx.coroutines.* import kotlinx.coroutines.channels.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-channel-05.kt b/kotlinx-coroutines-core/jvm/test/guide/example-channel-05.kt index 8b80764af5..1f129f3739 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-channel-05.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-channel-05.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.channel05 +// This file was automatically generated from channels.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleChannel05 import kotlinx.coroutines.* import kotlinx.coroutines.channels.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-channel-06.kt b/kotlinx-coroutines-core/jvm/test/guide/example-channel-06.kt index 452e056d34..b78fcc90ef 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-channel-06.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-channel-06.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.channel06 +// This file was automatically generated from channels.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleChannel06 import kotlinx.coroutines.* import kotlinx.coroutines.channels.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-channel-07.kt b/kotlinx-coroutines-core/jvm/test/guide/example-channel-07.kt index 9fc852e5c0..84de403dc9 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-channel-07.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-channel-07.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.channel07 +// This file was automatically generated from channels.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleChannel07 import kotlinx.coroutines.* import kotlinx.coroutines.channels.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-channel-08.kt b/kotlinx-coroutines-core/jvm/test/guide/example-channel-08.kt index c9916d4184..eedf1c7a89 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-channel-08.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-channel-08.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.channel08 +// This file was automatically generated from channels.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleChannel08 import kotlinx.coroutines.* import kotlinx.coroutines.channels.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-channel-09.kt b/kotlinx-coroutines-core/jvm/test/guide/example-channel-09.kt index fb293257e8..259f52eb8a 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-channel-09.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-channel-09.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.channel09 +// This file was automatically generated from channels.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleChannel09 import kotlinx.coroutines.* import kotlinx.coroutines.channels.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-channel-10.kt b/kotlinx-coroutines-core/jvm/test/guide/example-channel-10.kt index 43ceea50b3..ce0424471a 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-channel-10.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-channel-10.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.channel10 +// This file was automatically generated from channels.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleChannel10 import kotlinx.coroutines.* import kotlinx.coroutines.channels.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-compose-01.kt b/kotlinx-coroutines-core/jvm/test/guide/example-compose-01.kt index ab9ef608f4..ec20f1e40d 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-compose-01.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-compose-01.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.compose01 +// This file was automatically generated from composing-suspending-functions.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleCompose01 import kotlinx.coroutines.* import kotlin.system.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-compose-02.kt b/kotlinx-coroutines-core/jvm/test/guide/example-compose-02.kt index 9e46c6c48f..9531b5c893 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-compose-02.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-compose-02.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.compose02 +// This file was automatically generated from composing-suspending-functions.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleCompose02 import kotlinx.coroutines.* import kotlin.system.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-compose-03.kt b/kotlinx-coroutines-core/jvm/test/guide/example-compose-03.kt index 1dc2fd9bb2..a61afeab55 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-compose-03.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-compose-03.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.compose03 +// This file was automatically generated from composing-suspending-functions.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleCompose03 import kotlinx.coroutines.* import kotlin.system.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-compose-04.kt b/kotlinx-coroutines-core/jvm/test/guide/example-compose-04.kt index ad0b021488..312dc72b55 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-compose-04.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-compose-04.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.compose04 +// This file was automatically generated from composing-suspending-functions.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleCompose04 import kotlinx.coroutines.* import kotlin.system.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-compose-05.kt b/kotlinx-coroutines-core/jvm/test/guide/example-compose-05.kt index e02f33e0bd..37c4f99e6e 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-compose-05.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-compose-05.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.compose05 +// This file was automatically generated from composing-suspending-functions.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleCompose05 import kotlinx.coroutines.* import kotlin.system.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-compose-06.kt b/kotlinx-coroutines-core/jvm/test/guide/example-compose-06.kt index 1df506e4e8..5ee9e451fb 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-compose-06.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-compose-06.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.compose06 +// This file was automatically generated from composing-suspending-functions.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleCompose06 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-context-01.kt b/kotlinx-coroutines-core/jvm/test/guide/example-context-01.kt index c3a9f5afeb..0a9546057a 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-context-01.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-context-01.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.context01 +// This file was automatically generated from coroutine-context-and-dispatchers.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleContext01 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-context-02.kt b/kotlinx-coroutines-core/jvm/test/guide/example-context-02.kt index d1ec85fa9b..49bfe7efa3 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-context-02.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-context-02.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.context02 +// This file was automatically generated from coroutine-context-and-dispatchers.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleContext02 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-context-03.kt b/kotlinx-coroutines-core/jvm/test/guide/example-context-03.kt index e52976d095..3aaf0b30ad 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-context-03.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-context-03.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.context03 +// This file was automatically generated from coroutine-context-and-dispatchers.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleContext03 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-context-04.kt b/kotlinx-coroutines-core/jvm/test/guide/example-context-04.kt index b4a8a3f821..c5ce5eba7b 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-context-04.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-context-04.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.context04 +// This file was automatically generated from coroutine-context-and-dispatchers.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleContext04 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-context-05.kt b/kotlinx-coroutines-core/jvm/test/guide/example-context-05.kt index 338e3c9d88..3017b04996 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-context-05.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-context-05.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.context05 +// This file was automatically generated from coroutine-context-and-dispatchers.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleContext05 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-context-06.kt b/kotlinx-coroutines-core/jvm/test/guide/example-context-06.kt index b37b06b85c..e23eaf2542 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-context-06.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-context-06.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.context06 +// This file was automatically generated from coroutine-context-and-dispatchers.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleContext06 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-context-07.kt b/kotlinx-coroutines-core/jvm/test/guide/example-context-07.kt index 825f572a34..8037a559c5 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-context-07.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-context-07.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.context07 +// This file was automatically generated from coroutine-context-and-dispatchers.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleContext07 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-context-08.kt b/kotlinx-coroutines-core/jvm/test/guide/example-context-08.kt index 1083d77da4..a34e1aea5c 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-context-08.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-context-08.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.context08 +// This file was automatically generated from coroutine-context-and-dispatchers.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleContext08 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-context-09.kt b/kotlinx-coroutines-core/jvm/test/guide/example-context-09.kt index 386e52544f..6c1121b2a3 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-context-09.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-context-09.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.context09 +// This file was automatically generated from coroutine-context-and-dispatchers.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleContext09 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-context-10.kt b/kotlinx-coroutines-core/jvm/test/guide/example-context-10.kt index 3dde44670e..0256004405 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-context-10.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-context-10.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.context10 +// This file was automatically generated from coroutine-context-and-dispatchers.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleContext10 import kotlin.coroutines.* import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-context-11.kt b/kotlinx-coroutines-core/jvm/test/guide/example-context-11.kt index 4a50d86c0f..e3563171f5 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-context-11.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-context-11.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.context11 +// This file was automatically generated from coroutine-context-and-dispatchers.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleContext11 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-01.kt b/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-01.kt index 4bec14fca3..34d7b68c82 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-01.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-01.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.exceptions01 +// This file was automatically generated from exception-handling.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleExceptions01 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-02.kt b/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-02.kt index 818ab285c8..359eff60e4 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-02.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-02.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.exceptions02 +// This file was automatically generated from exception-handling.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleExceptions02 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-03.kt b/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-03.kt index 2b1e8e62b1..1ad5aef719 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-03.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-03.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.exceptions03 +// This file was automatically generated from exception-handling.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleExceptions03 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-04.kt b/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-04.kt index 02024ce206..e1fc22d725 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-04.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-04.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.exceptions04 +// This file was automatically generated from exception-handling.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleExceptions04 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-05.kt b/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-05.kt index e90606ff2a..e97572aba8 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-05.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-05.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.exceptions05 +// This file was automatically generated from exception-handling.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleExceptions05 import kotlinx.coroutines.exceptions.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-06.kt b/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-06.kt index 636c4a1f5d..eec27840e5 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-06.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-exceptions-06.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.exceptions06 +// This file was automatically generated from exception-handling.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleExceptions06 import kotlinx.coroutines.* import java.io.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-01.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-01.kt index 020f458b44..df14603db0 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-01.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-01.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow01 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow01 fun foo(): List = listOf(1, 2, 3) diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-02.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-02.kt index 66fc1639b5..fcb61b9d1d 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-02.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-02.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow02 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow02 fun foo(): Sequence = sequence { // sequence builder for (i in 1..3) { diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-03.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-03.kt index 393a0fa3a0..ba94b2f8f6 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-03.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-03.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow03 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow03 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-04.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-04.kt index 7bde16cf29..3e3aea0f55 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-04.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-04.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow04 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow04 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-05.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-05.kt index c1e05e2e3c..6d0e451923 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-05.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-05.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow05 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow05 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-06.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-06.kt index 1926983d67..9d9348ea5c 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-06.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-06.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow06 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow06 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-07.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-07.kt index 47ecf20bae..73b1734208 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-07.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-07.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow07 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow07 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-08.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-08.kt index 96aa19c1d5..1e8580c81f 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-08.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-08.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow08 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow08 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-09.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-09.kt index 4af29d93d3..7e2113c401 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-09.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-09.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow09 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow09 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-10.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-10.kt index 47602dab09..61e74a1aa1 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-10.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-10.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow10 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow10 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-11.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-11.kt index a97400626c..513057d10b 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-11.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-11.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow11 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow11 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-12.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-12.kt index 24dc4267ad..54ddf659f3 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-12.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-12.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow12 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow12 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-13.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-13.kt index 5d45946cb9..4feacc6d25 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-13.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-13.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow13 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow13 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-14.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-14.kt index 6628d12601..c0f2320490 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-14.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-14.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow14 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow14 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-15.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-15.kt index 3c1b10a94b..8f0e395ce4 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-15.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-15.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow15 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow15 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-16.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-16.kt index 0698e1bf84..d2f41ff6cc 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-16.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-16.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow16 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow16 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-17.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-17.kt index 86de59a2d0..5db79df185 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-17.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-17.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow17 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow17 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-18.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-18.kt index 597ff78326..3c1a8a1b7c 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-18.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-18.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow18 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow18 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-19.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-19.kt index eff3d8c054..1725276bf8 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-19.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-19.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow19 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow19 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-20.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-20.kt index 0cc3df45ab..bb829d11a0 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-20.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-20.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow20 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow20 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-21.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-21.kt index 5bf0e87074..e0adea60b5 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-21.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-21.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow21 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow21 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-22.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-22.kt index cd8f8b0c5c..9450ce59a9 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-22.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-22.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow22 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow22 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-23.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-23.kt index 742452e414..513fa30450 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-23.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-23.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow23 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow23 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-24.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-24.kt index 32047a93c4..7da20e01a6 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-24.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-24.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow24 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow24 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-25.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-25.kt index 094553095a..e3c2b812cd 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-25.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-25.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow25 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow25 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-26.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-26.kt index 037e253094..e489c3f2ed 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-26.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-26.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow26 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow26 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-27.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-27.kt index 6117cf5c62..f9ef9793cf 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-27.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-27.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow27 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow27 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-28.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-28.kt index 15acb79614..84fc69fd7b 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-28.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-28.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow28 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow28 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-29.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-29.kt index c0497df73c..6c60c5d9d2 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-29.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-29.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow29 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow29 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-30.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-30.kt index 5035efe23c..e21c77fcf3 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-30.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-30.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow30 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow30 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-31.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-31.kt index dfa43db53e..9b2855ef09 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-31.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-31.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow31 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow31 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-32.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-32.kt index f541ab57d9..3ad74ae5f1 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-32.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-32.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow32 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow32 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-33.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-33.kt index 1e291412c3..c0e0ab3d5b 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-33.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-33.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow33 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow33 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-34.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-34.kt index df2cad2025..4b79a73683 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-34.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-34.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow34 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow34 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-35.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-35.kt index a7c6bd2100..928c8bf2e6 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-35.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-35.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow35 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow35 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-flow-36.kt b/kotlinx-coroutines-core/jvm/test/guide/example-flow-36.kt index 9c5a57bf8f..3138464ced 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-flow-36.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-flow-36.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.flow36 +// This file was automatically generated from flow.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleFlow36 import kotlinx.coroutines.* import kotlinx.coroutines.flow.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-select-01.kt b/kotlinx-coroutines-core/jvm/test/guide/example-select-01.kt index 1939e72089..c1a962e60d 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-select-01.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-select-01.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.select01 +// This file was automatically generated from select-expression.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleSelect01 import kotlinx.coroutines.* import kotlinx.coroutines.channels.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-select-02.kt b/kotlinx-coroutines-core/jvm/test/guide/example-select-02.kt index 0e51015105..57fe638297 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-select-02.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-select-02.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.select02 +// This file was automatically generated from select-expression.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleSelect02 import kotlinx.coroutines.* import kotlinx.coroutines.channels.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-select-03.kt b/kotlinx-coroutines-core/jvm/test/guide/example-select-03.kt index 42422378f8..36597dd637 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-select-03.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-select-03.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.select03 +// This file was automatically generated from select-expression.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleSelect03 import kotlinx.coroutines.* import kotlinx.coroutines.channels.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-select-04.kt b/kotlinx-coroutines-core/jvm/test/guide/example-select-04.kt index 2db5170206..4cd9f6d93f 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-select-04.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-select-04.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.select04 +// This file was automatically generated from select-expression.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleSelect04 import kotlinx.coroutines.* import kotlinx.coroutines.selects.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-select-05.kt b/kotlinx-coroutines-core/jvm/test/guide/example-select-05.kt index e03be9da75..464e9b20f3 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-select-05.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-select-05.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.select05 +// This file was automatically generated from select-expression.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleSelect05 import kotlinx.coroutines.* import kotlinx.coroutines.channels.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-supervision-01.kt b/kotlinx-coroutines-core/jvm/test/guide/example-supervision-01.kt index d70b6c9f69..ffd56a8f85 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-supervision-01.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-supervision-01.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.supervision01 +// This file was automatically generated from exception-handling.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleSupervision01 import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-supervision-02.kt b/kotlinx-coroutines-core/jvm/test/guide/example-supervision-02.kt index facc2e0881..dc3a0f2844 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-supervision-02.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-supervision-02.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.supervision02 +// This file was automatically generated from exception-handling.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleSupervision02 import kotlin.coroutines.* import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-supervision-03.kt b/kotlinx-coroutines-core/jvm/test/guide/example-supervision-03.kt index 47c31b9e75..b32a004639 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-supervision-03.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-supervision-03.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.supervision03 +// This file was automatically generated from exception-handling.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleSupervision03 import kotlin.coroutines.* import kotlinx.coroutines.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-sync-01.kt b/kotlinx-coroutines-core/jvm/test/guide/example-sync-01.kt index bd710a49cd..32d4ac4fe9 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-sync-01.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-sync-01.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.sync01 +// This file was automatically generated from shared-mutable-state-and-concurrency.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleSync01 import kotlinx.coroutines.* import kotlin.system.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-sync-02.kt b/kotlinx-coroutines-core/jvm/test/guide/example-sync-02.kt index 813123723a..fb551f8953 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-sync-02.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-sync-02.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.sync02 +// This file was automatically generated from shared-mutable-state-and-concurrency.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleSync02 import kotlinx.coroutines.* import kotlin.system.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-sync-03.kt b/kotlinx-coroutines-core/jvm/test/guide/example-sync-03.kt index 1baf849acd..6c34149c93 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-sync-03.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-sync-03.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.sync03 +// This file was automatically generated from shared-mutable-state-and-concurrency.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleSync03 import kotlinx.coroutines.* import java.util.concurrent.atomic.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-sync-04.kt b/kotlinx-coroutines-core/jvm/test/guide/example-sync-04.kt index e16a8113f0..f94c4a05da 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-sync-04.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-sync-04.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.sync04 +// This file was automatically generated from shared-mutable-state-and-concurrency.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleSync04 import kotlinx.coroutines.* import kotlin.system.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-sync-05.kt b/kotlinx-coroutines-core/jvm/test/guide/example-sync-05.kt index d022961b31..a6a1cdd2a6 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-sync-05.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-sync-05.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.sync05 +// This file was automatically generated from shared-mutable-state-and-concurrency.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleSync05 import kotlinx.coroutines.* import kotlin.system.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-sync-06.kt b/kotlinx-coroutines-core/jvm/test/guide/example-sync-06.kt index fe08f049fd..e6c5f1bad3 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-sync-06.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-sync-06.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.sync06 +// This file was automatically generated from shared-mutable-state-and-concurrency.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleSync06 import kotlinx.coroutines.* import kotlinx.coroutines.sync.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/example-sync-07.kt b/kotlinx-coroutines-core/jvm/test/guide/example-sync-07.kt index 65e2050021..a84e02c849 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/example-sync-07.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/example-sync-07.kt @@ -1,9 +1,9 @@ /* - * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. -package kotlinx.coroutines.guide.sync07 +// This file was automatically generated from shared-mutable-state-and-concurrency.md by Knit tool. Do not edit. +package kotlinx.coroutines.guide.exampleSync07 import kotlinx.coroutines.* import kotlinx.coroutines.channels.* diff --git a/kotlinx-coroutines-core/jvm/test/guide/test/BasicsGuideTest.kt b/kotlinx-coroutines-core/jvm/test/guide/test/BasicsGuideTest.kt index 93b49a6013..7fc57c2ee3 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/test/BasicsGuideTest.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/test/BasicsGuideTest.kt @@ -1,53 +1,56 @@ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +// This file was automatically generated from basics.md by Knit tool. Do not edit. package kotlinx.coroutines.guide.test import org.junit.Test class BasicsGuideTest { - @Test - fun testKotlinxCoroutinesGuideBasic01() { - test("KotlinxCoroutinesGuideBasic01") { kotlinx.coroutines.guide.basic01.main() }.verifyLines( + fun testExampleBasic01() { + test("ExampleBasic01") { kotlinx.coroutines.guide.exampleBasic01.main() }.verifyLines( "Hello,", "World!" ) } @Test - fun testKotlinxCoroutinesGuideBasic02() { - test("KotlinxCoroutinesGuideBasic02") { kotlinx.coroutines.guide.basic02.main() }.verifyLines( + fun testExampleBasic02() { + test("ExampleBasic02") { kotlinx.coroutines.guide.exampleBasic02.main() }.verifyLines( "Hello,", "World!" ) } @Test - fun testKotlinxCoroutinesGuideBasic02b() { - test("KotlinxCoroutinesGuideBasic02b") { kotlinx.coroutines.guide.basic02b.main() }.verifyLines( + fun testExampleBasic03() { + test("ExampleBasic03") { kotlinx.coroutines.guide.exampleBasic03.main() }.verifyLines( "Hello,", "World!" ) } @Test - fun testKotlinxCoroutinesGuideBasic03() { - test("KotlinxCoroutinesGuideBasic03") { kotlinx.coroutines.guide.basic03.main() }.verifyLines( + fun testExampleBasic04() { + test("ExampleBasic04") { kotlinx.coroutines.guide.exampleBasic04.main() }.verifyLines( "Hello,", "World!" ) } @Test - fun testKotlinxCoroutinesGuideBasic03s() { - test("KotlinxCoroutinesGuideBasic03s") { kotlinx.coroutines.guide.basic03s.main() }.verifyLines( + fun testExampleBasic05() { + test("ExampleBasic05") { kotlinx.coroutines.guide.exampleBasic05.main() }.verifyLines( "Hello,", "World!" ) } @Test - fun testKotlinxCoroutinesGuideBasic04() { - test("KotlinxCoroutinesGuideBasic04") { kotlinx.coroutines.guide.basic04.main() }.verifyLines( + fun testExampleBasic06() { + test("ExampleBasic06") { kotlinx.coroutines.guide.exampleBasic06.main() }.verifyLines( "Task from coroutine scope", "Task from runBlocking", "Task from nested launch", @@ -56,23 +59,23 @@ class BasicsGuideTest { } @Test - fun testKotlinxCoroutinesGuideBasic05() { - test("KotlinxCoroutinesGuideBasic05") { kotlinx.coroutines.guide.basic05.main() }.verifyLines( + fun testExampleBasic07() { + test("ExampleBasic07") { kotlinx.coroutines.guide.exampleBasic07.main() }.verifyLines( "Hello,", "World!" ) } @Test - fun testKotlinxCoroutinesGuideBasic06() { - test("KotlinxCoroutinesGuideBasic06") { kotlinx.coroutines.guide.basic06.main() }.also { lines -> + fun testExampleBasic08() { + test("ExampleBasic08") { kotlinx.coroutines.guide.exampleBasic08.main() }.also { lines -> check(lines.size == 1 && lines[0] == ".".repeat(100_000)) } } @Test - fun testKotlinxCoroutinesGuideBasic07() { - test("KotlinxCoroutinesGuideBasic07") { kotlinx.coroutines.guide.basic07.main() }.verifyLines( + fun testExampleBasic09() { + test("ExampleBasic09") { kotlinx.coroutines.guide.exampleBasic09.main() }.verifyLines( "I'm sleeping 0 ...", "I'm sleeping 1 ...", "I'm sleeping 2 ..." diff --git a/kotlinx-coroutines-core/jvm/test/guide/test/CancellationTimeOutsGuideTest.kt b/kotlinx-coroutines-core/jvm/test/guide/test/CancellationGuideTest.kt similarity index 60% rename from kotlinx-coroutines-core/jvm/test/guide/test/CancellationTimeOutsGuideTest.kt rename to kotlinx-coroutines-core/jvm/test/guide/test/CancellationGuideTest.kt index 83bca486cd..a2e91de82d 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/test/CancellationTimeOutsGuideTest.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/test/CancellationGuideTest.kt @@ -1,13 +1,16 @@ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +// This file was automatically generated from cancellation-and-timeouts.md by Knit tool. Do not edit. package kotlinx.coroutines.guide.test import org.junit.Test -class CancellationTimeOutsGuideTest { - +class CancellationGuideTest { @Test - fun testKotlinxCoroutinesGuideCancel01() { - test("KotlinxCoroutinesGuideCancel01") { kotlinx.coroutines.guide.cancel01.main() }.verifyLines( + fun testExampleCancel01() { + test("ExampleCancel01") { kotlinx.coroutines.guide.exampleCancel01.main() }.verifyLines( "job: I'm sleeping 0 ...", "job: I'm sleeping 1 ...", "job: I'm sleeping 2 ...", @@ -17,8 +20,8 @@ class CancellationTimeOutsGuideTest { } @Test - fun testKotlinxCoroutinesGuideCancel02() { - test("KotlinxCoroutinesGuideCancel02") { kotlinx.coroutines.guide.cancel02.main() }.verifyLines( + fun testExampleCancel02() { + test("ExampleCancel02") { kotlinx.coroutines.guide.exampleCancel02.main() }.verifyLines( "job: I'm sleeping 0 ...", "job: I'm sleeping 1 ...", "job: I'm sleeping 2 ...", @@ -30,8 +33,8 @@ class CancellationTimeOutsGuideTest { } @Test - fun testKotlinxCoroutinesGuideCancel03() { - test("KotlinxCoroutinesGuideCancel03") { kotlinx.coroutines.guide.cancel03.main() }.verifyLines( + fun testExampleCancel03() { + test("ExampleCancel03") { kotlinx.coroutines.guide.exampleCancel03.main() }.verifyLines( "job: I'm sleeping 0 ...", "job: I'm sleeping 1 ...", "job: I'm sleeping 2 ...", @@ -41,8 +44,8 @@ class CancellationTimeOutsGuideTest { } @Test - fun testKotlinxCoroutinesGuideCancel04() { - test("KotlinxCoroutinesGuideCancel04") { kotlinx.coroutines.guide.cancel04.main() }.verifyLines( + fun testExampleCancel04() { + test("ExampleCancel04") { kotlinx.coroutines.guide.exampleCancel04.main() }.verifyLines( "job: I'm sleeping 0 ...", "job: I'm sleeping 1 ...", "job: I'm sleeping 2 ...", @@ -53,8 +56,8 @@ class CancellationTimeOutsGuideTest { } @Test - fun testKotlinxCoroutinesGuideCancel05() { - test("KotlinxCoroutinesGuideCancel05") { kotlinx.coroutines.guide.cancel05.main() }.verifyLines( + fun testExampleCancel05() { + test("ExampleCancel05") { kotlinx.coroutines.guide.exampleCancel05.main() }.verifyLines( "job: I'm sleeping 0 ...", "job: I'm sleeping 1 ...", "job: I'm sleeping 2 ...", @@ -66,8 +69,8 @@ class CancellationTimeOutsGuideTest { } @Test - fun testKotlinxCoroutinesGuideCancel06() { - test("KotlinxCoroutinesGuideCancel06") { kotlinx.coroutines.guide.cancel06.main() }.verifyLinesStartWith( + fun testExampleCancel06() { + test("ExampleCancel06") { kotlinx.coroutines.guide.exampleCancel06.main() }.verifyLinesStartWith( "I'm sleeping 0 ...", "I'm sleeping 1 ...", "I'm sleeping 2 ...", @@ -76,8 +79,8 @@ class CancellationTimeOutsGuideTest { } @Test - fun testKotlinxCoroutinesGuideCancel07() { - test("KotlinxCoroutinesGuideCancel07") { kotlinx.coroutines.guide.cancel07.main() }.verifyLines( + fun testExampleCancel07() { + test("ExampleCancel07") { kotlinx.coroutines.guide.exampleCancel07.main() }.verifyLines( "I'm sleeping 0 ...", "I'm sleeping 1 ...", "I'm sleeping 2 ...", diff --git a/kotlinx-coroutines-core/jvm/test/guide/test/ChannelsGuideTest.kt b/kotlinx-coroutines-core/jvm/test/guide/test/ChannelsGuideTest.kt index a747c98487..209d439663 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/test/ChannelsGuideTest.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/test/ChannelsGuideTest.kt @@ -1,13 +1,16 @@ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +// This file was automatically generated from channels.md by Knit tool. Do not edit. package kotlinx.coroutines.guide.test import org.junit.Test class ChannelsGuideTest { - @Test - fun testKotlinxCoroutinesGuideChannel01() { - test("KotlinxCoroutinesGuideChannel01") { kotlinx.coroutines.guide.channel01.main() }.verifyLines( + fun testExampleChannel01() { + test("ExampleChannel01") { kotlinx.coroutines.guide.exampleChannel01.main() }.verifyLines( "1", "4", "9", @@ -18,8 +21,8 @@ class ChannelsGuideTest { } @Test - fun testKotlinxCoroutinesGuideChannel02() { - test("KotlinxCoroutinesGuideChannel02") { kotlinx.coroutines.guide.channel02.main() }.verifyLines( + fun testExampleChannel02() { + test("ExampleChannel02") { kotlinx.coroutines.guide.exampleChannel02.main() }.verifyLines( "1", "4", "9", @@ -30,8 +33,8 @@ class ChannelsGuideTest { } @Test - fun testKotlinxCoroutinesGuideChannel03() { - test("KotlinxCoroutinesGuideChannel03") { kotlinx.coroutines.guide.channel03.main() }.verifyLines( + fun testExampleChannel03() { + test("ExampleChannel03") { kotlinx.coroutines.guide.exampleChannel03.main() }.verifyLines( "1", "4", "9", @@ -42,8 +45,8 @@ class ChannelsGuideTest { } @Test - fun testKotlinxCoroutinesGuideChannel04() { - test("KotlinxCoroutinesGuideChannel04") { kotlinx.coroutines.guide.channel04.main() }.verifyLines( + fun testExampleChannel04() { + test("ExampleChannel04") { kotlinx.coroutines.guide.exampleChannel04.main() }.verifyLines( "1", "4", "9", @@ -54,8 +57,8 @@ class ChannelsGuideTest { } @Test - fun testKotlinxCoroutinesGuideChannel05() { - test("KotlinxCoroutinesGuideChannel05") { kotlinx.coroutines.guide.channel05.main() }.verifyLines( + fun testExampleChannel05() { + test("ExampleChannel05") { kotlinx.coroutines.guide.exampleChannel05.main() }.verifyLines( "2", "3", "5", @@ -70,15 +73,15 @@ class ChannelsGuideTest { } @Test - fun testKotlinxCoroutinesGuideChannel06() { - test("KotlinxCoroutinesGuideChannel06") { kotlinx.coroutines.guide.channel06.main() }.also { lines -> + fun testExampleChannel06() { + test("ExampleChannel06") { kotlinx.coroutines.guide.exampleChannel06.main() }.also { lines -> check(lines.size == 10 && lines.withIndex().all { (i, line) -> line.startsWith("Processor #") && line.endsWith(" received ${i + 1}") }) } } @Test - fun testKotlinxCoroutinesGuideChannel07() { - test("KotlinxCoroutinesGuideChannel07") { kotlinx.coroutines.guide.channel07.main() }.verifyLines( + fun testExampleChannel07() { + test("ExampleChannel07") { kotlinx.coroutines.guide.exampleChannel07.main() }.verifyLines( "foo", "foo", "BAR!", @@ -89,8 +92,8 @@ class ChannelsGuideTest { } @Test - fun testKotlinxCoroutinesGuideChannel08() { - test("KotlinxCoroutinesGuideChannel08") { kotlinx.coroutines.guide.channel08.main() }.verifyLines( + fun testExampleChannel08() { + test("ExampleChannel08") { kotlinx.coroutines.guide.exampleChannel08.main() }.verifyLines( "Sending 0", "Sending 1", "Sending 2", @@ -100,8 +103,8 @@ class ChannelsGuideTest { } @Test - fun testKotlinxCoroutinesGuideChannel09() { - test("KotlinxCoroutinesGuideChannel09") { kotlinx.coroutines.guide.channel09.main() }.verifyLines( + fun testExampleChannel09() { + test("ExampleChannel09") { kotlinx.coroutines.guide.exampleChannel09.main() }.verifyLines( "ping Ball(hits=1)", "pong Ball(hits=2)", "ping Ball(hits=3)", @@ -110,8 +113,8 @@ class ChannelsGuideTest { } @Test - fun testKotlinxCoroutinesGuideChannel10() { - test("KotlinxCoroutinesGuideChannel10") { kotlinx.coroutines.guide.channel10.main() }.verifyLines( + fun testExampleChannel10() { + test("ExampleChannel10") { kotlinx.coroutines.guide.exampleChannel10.main() }.verifyLines( "Initial element is available immediately: kotlin.Unit", "Next element is not ready in 50 ms: null", "Next element is ready in 100 ms: kotlin.Unit", diff --git a/kotlinx-coroutines-core/jvm/test/guide/test/ComposingGuideTest.kt b/kotlinx-coroutines-core/jvm/test/guide/test/ComposingGuideTest.kt index de4cba44c6..50c3fd7e62 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/test/ComposingGuideTest.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/test/ComposingGuideTest.kt @@ -1,53 +1,56 @@ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +// This file was automatically generated from composing-suspending-functions.md by Knit tool. Do not edit. package kotlinx.coroutines.guide.test import org.junit.Test class ComposingGuideTest { - @Test - fun testKotlinxCoroutinesGuideCompose01() { - test("KotlinxCoroutinesGuideCompose01") { kotlinx.coroutines.guide.compose01.main() }.verifyLinesArbitraryTime( + fun testExampleCompose01() { + test("ExampleCompose01") { kotlinx.coroutines.guide.exampleCompose01.main() }.verifyLinesArbitraryTime( "The answer is 42", "Completed in 2017 ms" ) } @Test - fun testKotlinxCoroutinesGuideCompose02() { - test("KotlinxCoroutinesGuideCompose02") { kotlinx.coroutines.guide.compose02.main() }.verifyLinesArbitraryTime( + fun testExampleCompose02() { + test("ExampleCompose02") { kotlinx.coroutines.guide.exampleCompose02.main() }.verifyLinesArbitraryTime( "The answer is 42", "Completed in 1017 ms" ) } @Test - fun testKotlinxCoroutinesGuideCompose03() { - test("KotlinxCoroutinesGuideCompose03") { kotlinx.coroutines.guide.compose03.main() }.verifyLinesArbitraryTime( + fun testExampleCompose03() { + test("ExampleCompose03") { kotlinx.coroutines.guide.exampleCompose03.main() }.verifyLinesArbitraryTime( "The answer is 42", "Completed in 1017 ms" ) } @Test - fun testKotlinxCoroutinesGuideCompose04() { - test("KotlinxCoroutinesGuideCompose04") { kotlinx.coroutines.guide.compose04.main() }.verifyLinesArbitraryTime( + fun testExampleCompose04() { + test("ExampleCompose04") { kotlinx.coroutines.guide.exampleCompose04.main() }.verifyLinesArbitraryTime( "The answer is 42", "Completed in 1085 ms" ) } @Test - fun testKotlinxCoroutinesGuideCompose05() { - test("KotlinxCoroutinesGuideCompose05") { kotlinx.coroutines.guide.compose05.main() }.verifyLinesArbitraryTime( + fun testExampleCompose05() { + test("ExampleCompose05") { kotlinx.coroutines.guide.exampleCompose05.main() }.verifyLinesArbitraryTime( "The answer is 42", "Completed in 1017 ms" ) } @Test - fun testKotlinxCoroutinesGuideCompose06() { - test("KotlinxCoroutinesGuideCompose06") { kotlinx.coroutines.guide.compose06.main() }.verifyLines( + fun testExampleCompose06() { + test("ExampleCompose06") { kotlinx.coroutines.guide.exampleCompose06.main() }.verifyLines( "Second child throws an exception", "First child was cancelled", "Computation failed with ArithmeticException" diff --git a/kotlinx-coroutines-core/jvm/test/guide/test/DispatcherGuideTest.kt b/kotlinx-coroutines-core/jvm/test/guide/test/DispatcherGuideTest.kt index 180738f8b3..c0c32410d5 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/test/DispatcherGuideTest.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/test/DispatcherGuideTest.kt @@ -1,13 +1,16 @@ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +// This file was automatically generated from coroutine-context-and-dispatchers.md by Knit tool. Do not edit. package kotlinx.coroutines.guide.test import org.junit.Test -class DispatchersGuideTest { - +class DispatcherGuideTest { @Test - fun testKotlinxCoroutinesGuideContext01() { - test("KotlinxCoroutinesGuideContext01") { kotlinx.coroutines.guide.context01.main() }.verifyLinesStartUnordered( + fun testExampleContext01() { + test("ExampleContext01") { kotlinx.coroutines.guide.exampleContext01.main() }.verifyLinesStartUnordered( "Unconfined : I'm working in thread main", "Default : I'm working in thread DefaultDispatcher-worker-1", "newSingleThreadContext: I'm working in thread MyOwnThread", @@ -16,8 +19,8 @@ class DispatchersGuideTest { } @Test - fun testKotlinxCoroutinesGuideContext02() { - test("KotlinxCoroutinesGuideContext02") { kotlinx.coroutines.guide.context02.main() }.verifyLinesStart( + fun testExampleContext02() { + test("ExampleContext02") { kotlinx.coroutines.guide.exampleContext02.main() }.verifyLinesStart( "Unconfined : I'm working in thread main", "main runBlocking: I'm working in thread main", "Unconfined : After delay in thread kotlinx.coroutines.DefaultExecutor", @@ -26,8 +29,8 @@ class DispatchersGuideTest { } @Test - fun testKotlinxCoroutinesGuideContext03() { - test("KotlinxCoroutinesGuideContext03") { kotlinx.coroutines.guide.context03.main() }.verifyLinesFlexibleThread( + fun testExampleContext03() { + test("ExampleContext03") { kotlinx.coroutines.guide.exampleContext03.main() }.verifyLinesFlexibleThread( "[main @coroutine#2] I'm computing a piece of the answer", "[main @coroutine#3] I'm computing another piece of the answer", "[main @coroutine#1] The answer is 42" @@ -35,8 +38,8 @@ class DispatchersGuideTest { } @Test - fun testKotlinxCoroutinesGuideContext04() { - test("KotlinxCoroutinesGuideContext04") { kotlinx.coroutines.guide.context04.main() }.verifyLines( + fun testExampleContext04() { + test("ExampleContext04") { kotlinx.coroutines.guide.exampleContext04.main() }.verifyLines( "[Ctx1 @coroutine#1] Started in ctx1", "[Ctx2 @coroutine#1] Working in ctx2", "[Ctx1 @coroutine#1] Back to ctx1" @@ -44,15 +47,15 @@ class DispatchersGuideTest { } @Test - fun testKotlinxCoroutinesGuideContext05() { - test("KotlinxCoroutinesGuideContext05") { kotlinx.coroutines.guide.context05.main() }.also { lines -> + fun testExampleContext05() { + test("ExampleContext05") { kotlinx.coroutines.guide.exampleContext05.main() }.also { lines -> check(lines.size == 1 && lines[0].startsWith("My job is \"coroutine#1\":BlockingCoroutine{Active}@")) } } @Test - fun testKotlinxCoroutinesGuideContext06() { - test("KotlinxCoroutinesGuideContext06") { kotlinx.coroutines.guide.context06.main() }.verifyLines( + fun testExampleContext06() { + test("ExampleContext06") { kotlinx.coroutines.guide.exampleContext06.main() }.verifyLines( "job1: I run in GlobalScope and execute independently!", "job2: I am a child of the request coroutine", "job1: I am not affected by cancellation of the request", @@ -61,8 +64,8 @@ class DispatchersGuideTest { } @Test - fun testKotlinxCoroutinesGuideContext07() { - test("KotlinxCoroutinesGuideContext07") { kotlinx.coroutines.guide.context07.main() }.verifyLines( + fun testExampleContext07() { + test("ExampleContext07") { kotlinx.coroutines.guide.exampleContext07.main() }.verifyLines( "request: I'm done and I don't explicitly join my children that are still active", "Coroutine 0 is done", "Coroutine 1 is done", @@ -72,8 +75,8 @@ class DispatchersGuideTest { } @Test - fun testKotlinxCoroutinesGuideContext08() { - test("KotlinxCoroutinesGuideContext08") { kotlinx.coroutines.guide.context08.main() }.verifyLinesFlexibleThread( + fun testExampleContext08() { + test("ExampleContext08") { kotlinx.coroutines.guide.exampleContext08.main() }.verifyLinesFlexibleThread( "[main @main#1] Started main coroutine", "[main @v1coroutine#2] Computing v1", "[main @v2coroutine#3] Computing v2", @@ -82,15 +85,15 @@ class DispatchersGuideTest { } @Test - fun testKotlinxCoroutinesGuideContext09() { - test("KotlinxCoroutinesGuideContext09") { kotlinx.coroutines.guide.context09.main() }.verifyLinesFlexibleThread( + fun testExampleContext09() { + test("ExampleContext09") { kotlinx.coroutines.guide.exampleContext09.main() }.verifyLinesFlexibleThread( "I'm working in thread DefaultDispatcher-worker-1 @test#2" ) } @Test - fun testKotlinxCoroutinesGuideContext10() { - test("KotlinxCoroutinesGuideContext10") { kotlinx.coroutines.guide.context10.main() }.verifyLines( + fun testExampleContext10() { + test("ExampleContext10") { kotlinx.coroutines.guide.exampleContext10.main() }.verifyLines( "Launched coroutines", "Coroutine 0 is done", "Coroutine 1 is done", @@ -99,8 +102,8 @@ class DispatchersGuideTest { } @Test - fun testKotlinxCoroutinesGuideContext11() { - test("KotlinxCoroutinesGuideContext11") { kotlinx.coroutines.guide.context11.main() }.verifyLinesFlexibleThread( + fun testExampleContext11() { + test("ExampleContext11") { kotlinx.coroutines.guide.exampleContext11.main() }.verifyLinesFlexibleThread( "Pre-main, current thread: Thread[main @coroutine#1,5,main], thread local value: 'main'", "Launch start, current thread: Thread[DefaultDispatcher-worker-1 @coroutine#2,5,main], thread local value: 'launch'", "After yield, current thread: Thread[DefaultDispatcher-worker-2 @coroutine#2,5,main], thread local value: 'launch'", diff --git a/kotlinx-coroutines-core/jvm/test/guide/test/ExceptionsGuideTest.kt b/kotlinx-coroutines-core/jvm/test/guide/test/ExceptionsGuideTest.kt index 7fa692b2a0..4a140208f9 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/test/ExceptionsGuideTest.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/test/ExceptionsGuideTest.kt @@ -1,13 +1,16 @@ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +// This file was automatically generated from exception-handling.md by Knit tool. Do not edit. package kotlinx.coroutines.guide.test import org.junit.Test class ExceptionsGuideTest { - @Test - fun testKotlinxCoroutinesGuideExceptions01() { - test("KotlinxCoroutinesGuideExceptions01") { kotlinx.coroutines.guide.exceptions01.main() }.verifyExceptions( + fun testExampleExceptions01() { + test("ExampleExceptions01") { kotlinx.coroutines.guide.exampleExceptions01.main() }.verifyExceptions( "Throwing exception from launch", "Exception in thread \"DefaultDispatcher-worker-2 @coroutine#2\" java.lang.IndexOutOfBoundsException", "Joined failed job", @@ -17,15 +20,15 @@ class ExceptionsGuideTest { } @Test - fun testKotlinxCoroutinesGuideExceptions02() { - test("KotlinxCoroutinesGuideExceptions02") { kotlinx.coroutines.guide.exceptions02.main() }.verifyLines( + fun testExampleExceptions02() { + test("ExampleExceptions02") { kotlinx.coroutines.guide.exampleExceptions02.main() }.verifyLines( "Caught java.lang.AssertionError" ) } @Test - fun testKotlinxCoroutinesGuideExceptions03() { - test("KotlinxCoroutinesGuideExceptions03") { kotlinx.coroutines.guide.exceptions03.main() }.verifyLines( + fun testExampleExceptions03() { + test("ExampleExceptions03") { kotlinx.coroutines.guide.exampleExceptions03.main() }.verifyLines( "Cancelling child", "Child is cancelled", "Parent is not cancelled" @@ -33,8 +36,8 @@ class ExceptionsGuideTest { } @Test - fun testKotlinxCoroutinesGuideExceptions04() { - test("KotlinxCoroutinesGuideExceptions04") { kotlinx.coroutines.guide.exceptions04.main() }.verifyLines( + fun testExampleExceptions04() { + test("ExampleExceptions04") { kotlinx.coroutines.guide.exampleExceptions04.main() }.verifyLines( "Second child throws an exception", "Children are cancelled, but exception is not handled until all children terminate", "The first child finished its non cancellable block", @@ -43,23 +46,23 @@ class ExceptionsGuideTest { } @Test - fun testKotlinxCoroutinesGuideExceptions05() { - test("KotlinxCoroutinesGuideExceptions05") { kotlinx.coroutines.guide.exceptions05.main() }.verifyLines( + fun testExampleExceptions05() { + test("ExampleExceptions05") { kotlinx.coroutines.guide.exampleExceptions05.main() }.verifyLines( "Caught java.io.IOException with suppressed [java.lang.ArithmeticException]" ) } @Test - fun testKotlinxCoroutinesGuideExceptions06() { - test("KotlinxCoroutinesGuideExceptions06") { kotlinx.coroutines.guide.exceptions06.main() }.verifyLines( + fun testExampleExceptions06() { + test("ExampleExceptions06") { kotlinx.coroutines.guide.exampleExceptions06.main() }.verifyLines( "Rethrowing CancellationException with original cause", "Caught original java.io.IOException" ) } @Test - fun testKotlinxCoroutinesGuideSupervision01() { - test("KotlinxCoroutinesGuideSupervision01") { kotlinx.coroutines.guide.supervision01.main() }.verifyLines( + fun testExampleSupervision01() { + test("ExampleSupervision01") { kotlinx.coroutines.guide.exampleSupervision01.main() }.verifyLines( "First child is failing", "First child is cancelled: true, but second one is still active", "Cancelling supervisor", @@ -68,8 +71,8 @@ class ExceptionsGuideTest { } @Test - fun testKotlinxCoroutinesGuideSupervision02() { - test("KotlinxCoroutinesGuideSupervision02") { kotlinx.coroutines.guide.supervision02.main() }.verifyLines( + fun testExampleSupervision02() { + test("ExampleSupervision02") { kotlinx.coroutines.guide.exampleSupervision02.main() }.verifyLines( "Child is sleeping", "Throwing exception from scope", "Child is cancelled", @@ -78,8 +81,8 @@ class ExceptionsGuideTest { } @Test - fun testKotlinxCoroutinesGuideSupervision03() { - test("KotlinxCoroutinesGuideSupervision03") { kotlinx.coroutines.guide.supervision03.main() }.verifyLines( + fun testExampleSupervision03() { + test("ExampleSupervision03") { kotlinx.coroutines.guide.exampleSupervision03.main() }.verifyLines( "Scope is completing", "Child throws an exception", "Caught java.lang.AssertionError", diff --git a/kotlinx-coroutines-core/jvm/test/guide/test/FlowGuideTest.kt b/kotlinx-coroutines-core/jvm/test/guide/test/FlowGuideTest.kt index 0353c54e7c..5d320f2124 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/test/FlowGuideTest.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/test/FlowGuideTest.kt @@ -1,13 +1,16 @@ +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + // This file was automatically generated from flow.md by Knit tool. Do not edit. package kotlinx.coroutines.guide.test import org.junit.Test class FlowGuideTest { - @Test - fun testKotlinxCoroutinesGuideFlow01() { - test("KotlinxCoroutinesGuideFlow01") { kotlinx.coroutines.guide.flow01.main() }.verifyLines( + fun testExampleFlow01() { + test("ExampleFlow01") { kotlinx.coroutines.guide.exampleFlow01.main() }.verifyLines( "1", "2", "3" @@ -15,8 +18,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow02() { - test("KotlinxCoroutinesGuideFlow02") { kotlinx.coroutines.guide.flow02.main() }.verifyLines( + fun testExampleFlow02() { + test("ExampleFlow02") { kotlinx.coroutines.guide.exampleFlow02.main() }.verifyLines( "1", "2", "3" @@ -24,8 +27,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow03() { - test("KotlinxCoroutinesGuideFlow03") { kotlinx.coroutines.guide.flow03.main() }.verifyLines( + fun testExampleFlow03() { + test("ExampleFlow03") { kotlinx.coroutines.guide.exampleFlow03.main() }.verifyLines( "1", "2", "3" @@ -33,8 +36,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow04() { - test("KotlinxCoroutinesGuideFlow04") { kotlinx.coroutines.guide.flow04.main() }.verifyLines( + fun testExampleFlow04() { + test("ExampleFlow04") { kotlinx.coroutines.guide.exampleFlow04.main() }.verifyLines( "I'm not blocked 1", "1", "I'm not blocked 2", @@ -45,8 +48,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow05() { - test("KotlinxCoroutinesGuideFlow05") { kotlinx.coroutines.guide.flow05.main() }.verifyLines( + fun testExampleFlow05() { + test("ExampleFlow05") { kotlinx.coroutines.guide.exampleFlow05.main() }.verifyLines( "Calling foo...", "Calling collect...", "Flow started", @@ -62,8 +65,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow06() { - test("KotlinxCoroutinesGuideFlow06") { kotlinx.coroutines.guide.flow06.main() }.verifyLines( + fun testExampleFlow06() { + test("ExampleFlow06") { kotlinx.coroutines.guide.exampleFlow06.main() }.verifyLines( "Emitting 1", "1", "Emitting 2", @@ -73,8 +76,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow07() { - test("KotlinxCoroutinesGuideFlow07") { kotlinx.coroutines.guide.flow07.main() }.verifyLines( + fun testExampleFlow07() { + test("ExampleFlow07") { kotlinx.coroutines.guide.exampleFlow07.main() }.verifyLines( "1", "2", "3" @@ -82,8 +85,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow08() { - test("KotlinxCoroutinesGuideFlow08") { kotlinx.coroutines.guide.flow08.main() }.verifyLines( + fun testExampleFlow08() { + test("ExampleFlow08") { kotlinx.coroutines.guide.exampleFlow08.main() }.verifyLines( "response 1", "response 2", "response 3" @@ -91,8 +94,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow09() { - test("KotlinxCoroutinesGuideFlow09") { kotlinx.coroutines.guide.flow09.main() }.verifyLines( + fun testExampleFlow09() { + test("ExampleFlow09") { kotlinx.coroutines.guide.exampleFlow09.main() }.verifyLines( "Making request 1", "response 1", "Making request 2", @@ -103,8 +106,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow10() { - test("KotlinxCoroutinesGuideFlow10") { kotlinx.coroutines.guide.flow10.main() }.verifyLines( + fun testExampleFlow10() { + test("ExampleFlow10") { kotlinx.coroutines.guide.exampleFlow10.main() }.verifyLines( "1", "2", "Finally in numbers" @@ -112,15 +115,15 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow11() { - test("KotlinxCoroutinesGuideFlow11") { kotlinx.coroutines.guide.flow11.main() }.verifyLines( + fun testExampleFlow11() { + test("ExampleFlow11") { kotlinx.coroutines.guide.exampleFlow11.main() }.verifyLines( "55" ) } @Test - fun testKotlinxCoroutinesGuideFlow12() { - test("KotlinxCoroutinesGuideFlow12") { kotlinx.coroutines.guide.flow12.main() }.verifyLines( + fun testExampleFlow12() { + test("ExampleFlow12") { kotlinx.coroutines.guide.exampleFlow12.main() }.verifyLines( "Filter 1", "Filter 2", "Map 2", @@ -134,8 +137,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow13() { - test("KotlinxCoroutinesGuideFlow13") { kotlinx.coroutines.guide.flow13.main() }.verifyLinesFlexibleThread( + fun testExampleFlow13() { + test("ExampleFlow13") { kotlinx.coroutines.guide.exampleFlow13.main() }.verifyLinesFlexibleThread( "[main @coroutine#1] Started foo flow", "[main @coroutine#1] Collected 1", "[main @coroutine#1] Collected 2", @@ -144,19 +147,19 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow14() { - test("KotlinxCoroutinesGuideFlow14") { kotlinx.coroutines.guide.flow14.main() }.verifyExceptions( + fun testExampleFlow14() { + test("ExampleFlow14") { kotlinx.coroutines.guide.exampleFlow14.main() }.verifyExceptions( "Exception in thread \"main\" java.lang.IllegalStateException: Flow invariant is violated:", - " Flow was collected in [CoroutineId(1), \"coroutine#1\":BlockingCoroutine{Active}@5511c7f8, BlockingEventLoop@2eac3323],", - " but emission happened in [CoroutineId(1), \"coroutine#1\":DispatchedCoroutine{Active}@2dae0000, DefaultDispatcher].", - " Please refer to 'flow' documentation or use 'flowOn' instead", - " at ..." + "\t\tFlow was collected in [CoroutineId(1), \"coroutine#1\":BlockingCoroutine{Active}@5511c7f8, BlockingEventLoop@2eac3323],", + "\t\tbut emission happened in [CoroutineId(1), \"coroutine#1\":DispatchedCoroutine{Active}@2dae0000, DefaultDispatcher].", + "\t\tPlease refer to 'flow' documentation or use 'flowOn' instead", + "\tat ..." ) } @Test - fun testKotlinxCoroutinesGuideFlow15() { - test("KotlinxCoroutinesGuideFlow15") { kotlinx.coroutines.guide.flow15.main() }.verifyLinesFlexibleThread( + fun testExampleFlow15() { + test("ExampleFlow15") { kotlinx.coroutines.guide.exampleFlow15.main() }.verifyLinesFlexibleThread( "[DefaultDispatcher-worker-1 @coroutine#2] Emitting 1", "[main @coroutine#1] Collected 1", "[DefaultDispatcher-worker-1 @coroutine#2] Emitting 2", @@ -167,8 +170,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow16() { - test("KotlinxCoroutinesGuideFlow16") { kotlinx.coroutines.guide.flow16.main() }.verifyLinesArbitraryTime( + fun testExampleFlow16() { + test("ExampleFlow16") { kotlinx.coroutines.guide.exampleFlow16.main() }.verifyLinesArbitraryTime( "1", "2", "3", @@ -177,8 +180,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow17() { - test("KotlinxCoroutinesGuideFlow17") { kotlinx.coroutines.guide.flow17.main() }.verifyLinesArbitraryTime( + fun testExampleFlow17() { + test("ExampleFlow17") { kotlinx.coroutines.guide.exampleFlow17.main() }.verifyLinesArbitraryTime( "1", "2", "3", @@ -187,8 +190,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow18() { - test("KotlinxCoroutinesGuideFlow18") { kotlinx.coroutines.guide.flow18.main() }.verifyLinesArbitraryTime( + fun testExampleFlow18() { + test("ExampleFlow18") { kotlinx.coroutines.guide.exampleFlow18.main() }.verifyLinesArbitraryTime( "1", "3", "Collected in 758 ms" @@ -196,8 +199,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow19() { - test("KotlinxCoroutinesGuideFlow19") { kotlinx.coroutines.guide.flow19.main() }.verifyLinesArbitraryTime( + fun testExampleFlow19() { + test("ExampleFlow19") { kotlinx.coroutines.guide.exampleFlow19.main() }.verifyLinesArbitraryTime( "Collecting 1", "Collecting 2", "Collecting 3", @@ -207,8 +210,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow20() { - test("KotlinxCoroutinesGuideFlow20") { kotlinx.coroutines.guide.flow20.main() }.verifyLines( + fun testExampleFlow20() { + test("ExampleFlow20") { kotlinx.coroutines.guide.exampleFlow20.main() }.verifyLines( "1 -> one", "2 -> two", "3 -> three" @@ -216,8 +219,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow21() { - test("KotlinxCoroutinesGuideFlow21") { kotlinx.coroutines.guide.flow21.main() }.verifyLinesArbitraryTime( + fun testExampleFlow21() { + test("ExampleFlow21") { kotlinx.coroutines.guide.exampleFlow21.main() }.verifyLinesArbitraryTime( "1 -> one at 437 ms from start", "2 -> two at 837 ms from start", "3 -> three at 1243 ms from start" @@ -225,8 +228,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow22() { - test("KotlinxCoroutinesGuideFlow22") { kotlinx.coroutines.guide.flow22.main() }.verifyLinesArbitraryTime( + fun testExampleFlow22() { + test("ExampleFlow22") { kotlinx.coroutines.guide.exampleFlow22.main() }.verifyLinesArbitraryTime( "1 -> one at 452 ms from start", "2 -> one at 651 ms from start", "2 -> two at 854 ms from start", @@ -236,8 +239,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow23() { - test("KotlinxCoroutinesGuideFlow23") { kotlinx.coroutines.guide.flow23.main() }.verifyLinesArbitraryTime( + fun testExampleFlow23() { + test("ExampleFlow23") { kotlinx.coroutines.guide.exampleFlow23.main() }.verifyLinesArbitraryTime( "1: First at 121 ms from start", "1: Second at 622 ms from start", "2: First at 727 ms from start", @@ -248,8 +251,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow24() { - test("KotlinxCoroutinesGuideFlow24") { kotlinx.coroutines.guide.flow24.main() }.verifyLinesArbitraryTime( + fun testExampleFlow24() { + test("ExampleFlow24") { kotlinx.coroutines.guide.exampleFlow24.main() }.verifyLinesArbitraryTime( "1: First at 136 ms from start", "2: First at 231 ms from start", "3: First at 333 ms from start", @@ -260,8 +263,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow25() { - test("KotlinxCoroutinesGuideFlow25") { kotlinx.coroutines.guide.flow25.main() }.verifyLinesArbitraryTime( + fun testExampleFlow25() { + test("ExampleFlow25") { kotlinx.coroutines.guide.exampleFlow25.main() }.verifyLinesArbitraryTime( "1: First at 142 ms from start", "2: First at 322 ms from start", "3: First at 425 ms from start", @@ -270,8 +273,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow26() { - test("KotlinxCoroutinesGuideFlow26") { kotlinx.coroutines.guide.flow26.main() }.verifyLines( + fun testExampleFlow26() { + test("ExampleFlow26") { kotlinx.coroutines.guide.exampleFlow26.main() }.verifyLines( "Emitting 1", "1", "Emitting 2", @@ -281,8 +284,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow27() { - test("KotlinxCoroutinesGuideFlow27") { kotlinx.coroutines.guide.flow27.main() }.verifyLines( + fun testExampleFlow27() { + test("ExampleFlow27") { kotlinx.coroutines.guide.exampleFlow27.main() }.verifyLines( "Emitting 1", "string 1", "Emitting 2", @@ -291,8 +294,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow28() { - test("KotlinxCoroutinesGuideFlow28") { kotlinx.coroutines.guide.flow28.main() }.verifyLines( + fun testExampleFlow28() { + test("ExampleFlow28") { kotlinx.coroutines.guide.exampleFlow28.main() }.verifyLines( "Emitting 1", "string 1", "Emitting 2", @@ -301,19 +304,19 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow29() { - test("KotlinxCoroutinesGuideFlow29") { kotlinx.coroutines.guide.flow29.main() }.verifyExceptions( + fun testExampleFlow29() { + test("ExampleFlow29") { kotlinx.coroutines.guide.exampleFlow29.main() }.verifyExceptions( "Emitting 1", "1", "Emitting 2", "Exception in thread \"main\" java.lang.IllegalStateException: Collected 2", - " at ..." + "\tat ..." ) } @Test - fun testKotlinxCoroutinesGuideFlow30() { - test("KotlinxCoroutinesGuideFlow30") { kotlinx.coroutines.guide.flow30.main() }.verifyExceptions( + fun testExampleFlow30() { + test("ExampleFlow30") { kotlinx.coroutines.guide.exampleFlow30.main() }.verifyExceptions( "Emitting 1", "1", "Emitting 2", @@ -322,8 +325,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow31() { - test("KotlinxCoroutinesGuideFlow31") { kotlinx.coroutines.guide.flow31.main() }.verifyLines( + fun testExampleFlow31() { + test("ExampleFlow31") { kotlinx.coroutines.guide.exampleFlow31.main() }.verifyLines( "1", "2", "3", @@ -332,8 +335,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow32() { - test("KotlinxCoroutinesGuideFlow32") { kotlinx.coroutines.guide.flow32.main() }.verifyLines( + fun testExampleFlow32() { + test("ExampleFlow32") { kotlinx.coroutines.guide.exampleFlow32.main() }.verifyLines( "1", "2", "3", @@ -342,8 +345,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow33() { - test("KotlinxCoroutinesGuideFlow33") { kotlinx.coroutines.guide.flow33.main() }.verifyLines( + fun testExampleFlow33() { + test("ExampleFlow33") { kotlinx.coroutines.guide.exampleFlow33.main() }.verifyLines( "1", "Flow completed exceptionally", "Caught exception" @@ -351,8 +354,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow34() { - test("KotlinxCoroutinesGuideFlow34") { kotlinx.coroutines.guide.flow34.main() }.verifyExceptions( + fun testExampleFlow34() { + test("ExampleFlow34") { kotlinx.coroutines.guide.exampleFlow34.main() }.verifyExceptions( "1", "Flow completed with null", "Exception in thread \"main\" java.lang.IllegalStateException: Collected 2" @@ -360,8 +363,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow35() { - test("KotlinxCoroutinesGuideFlow35") { kotlinx.coroutines.guide.flow35.main() }.verifyLines( + fun testExampleFlow35() { + test("ExampleFlow35") { kotlinx.coroutines.guide.exampleFlow35.main() }.verifyLines( "Event: 1", "Event: 2", "Event: 3", @@ -370,8 +373,8 @@ class FlowGuideTest { } @Test - fun testKotlinxCoroutinesGuideFlow36() { - test("KotlinxCoroutinesGuideFlow36") { kotlinx.coroutines.guide.flow36.main() }.verifyLines( + fun testExampleFlow36() { + test("ExampleFlow36") { kotlinx.coroutines.guide.exampleFlow36.main() }.verifyLines( "Done", "Event: 1", "Event: 2", diff --git a/kotlinx-coroutines-core/jvm/test/guide/test/SelectGuideTest.kt b/kotlinx-coroutines-core/jvm/test/guide/test/SelectGuideTest.kt index b5246ff4be..e3f47b9648 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/test/SelectGuideTest.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/test/SelectGuideTest.kt @@ -1,13 +1,16 @@ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +// This file was automatically generated from select-expression.md by Knit tool. Do not edit. package kotlinx.coroutines.guide.test import org.junit.Test class SelectGuideTest { - @Test - fun testKotlinxCoroutinesGuideSelect01() { - test("KotlinxCoroutinesGuideSelect01") { kotlinx.coroutines.guide.select01.main() }.verifyLines( + fun testExampleSelect01() { + test("ExampleSelect01") { kotlinx.coroutines.guide.exampleSelect01.main() }.verifyLines( "fizz -> 'Fizz'", "buzz -> 'Buzz!'", "fizz -> 'Fizz'", @@ -19,8 +22,8 @@ class SelectGuideTest { } @Test - fun testKotlinxCoroutinesGuideSelect02() { - test("KotlinxCoroutinesGuideSelect02") { kotlinx.coroutines.guide.select02.main() }.verifyLines( + fun testExampleSelect02() { + test("ExampleSelect02") { kotlinx.coroutines.guide.exampleSelect02.main() }.verifyLines( "a -> 'Hello 0'", "a -> 'Hello 1'", "b -> 'World 0'", @@ -33,8 +36,8 @@ class SelectGuideTest { } @Test - fun testKotlinxCoroutinesGuideSelect03() { - test("KotlinxCoroutinesGuideSelect03") { kotlinx.coroutines.guide.select03.main() }.verifyLines( + fun testExampleSelect03() { + test("ExampleSelect03") { kotlinx.coroutines.guide.exampleSelect03.main() }.verifyLines( "Consuming 1", "Side channel has 2", "Side channel has 3", @@ -50,16 +53,16 @@ class SelectGuideTest { } @Test - fun testKotlinxCoroutinesGuideSelect04() { - test("KotlinxCoroutinesGuideSelect04") { kotlinx.coroutines.guide.select04.main() }.verifyLines( + fun testExampleSelect04() { + test("ExampleSelect04") { kotlinx.coroutines.guide.exampleSelect04.main() }.verifyLines( "Deferred 4 produced answer 'Waited for 128 ms'", "11 coroutines are still active" ) } @Test - fun testKotlinxCoroutinesGuideSelect05() { - test("KotlinxCoroutinesGuideSelect05") { kotlinx.coroutines.guide.select05.main() }.verifyLines( + fun testExampleSelect05() { + test("ExampleSelect05") { kotlinx.coroutines.guide.exampleSelect05.main() }.verifyLines( "BEGIN", "Replace", "END", diff --git a/kotlinx-coroutines-core/jvm/test/guide/test/SharedStateGuideTest.kt b/kotlinx-coroutines-core/jvm/test/guide/test/SharedStateGuideTest.kt index 45988570ba..8d534a09ea 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/test/SharedStateGuideTest.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/test/SharedStateGuideTest.kt @@ -1,61 +1,64 @@ -// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit. +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +// This file was automatically generated from shared-mutable-state-and-concurrency.md by Knit tool. Do not edit. package kotlinx.coroutines.guide.test import org.junit.Test class SharedStateGuideTest { - @Test - fun testKotlinxCoroutinesGuideSync01() { - test("KotlinxCoroutinesGuideSync01") { kotlinx.coroutines.guide.sync01.main() }.verifyLinesStart( + fun testExampleSync01() { + test("ExampleSync01") { kotlinx.coroutines.guide.exampleSync01.main() }.verifyLinesStart( "Completed 100000 actions in", "Counter =" ) } @Test - fun testKotlinxCoroutinesGuideSync02() { - test("KotlinxCoroutinesGuideSync02") { kotlinx.coroutines.guide.sync02.main() }.verifyLinesStart( + fun testExampleSync02() { + test("ExampleSync02") { kotlinx.coroutines.guide.exampleSync02.main() }.verifyLinesStart( "Completed 100000 actions in", "Counter =" ) } @Test - fun testKotlinxCoroutinesGuideSync03() { - test("KotlinxCoroutinesGuideSync03") { kotlinx.coroutines.guide.sync03.main() }.verifyLinesArbitraryTime( + fun testExampleSync03() { + test("ExampleSync03") { kotlinx.coroutines.guide.exampleSync03.main() }.verifyLinesArbitraryTime( "Completed 100000 actions in xxx ms", "Counter = 100000" ) } @Test - fun testKotlinxCoroutinesGuideSync04() { - test("KotlinxCoroutinesGuideSync04") { kotlinx.coroutines.guide.sync04.main() }.verifyLinesArbitraryTime( + fun testExampleSync04() { + test("ExampleSync04") { kotlinx.coroutines.guide.exampleSync04.main() }.verifyLinesArbitraryTime( "Completed 100000 actions in xxx ms", "Counter = 100000" ) } @Test - fun testKotlinxCoroutinesGuideSync05() { - test("KotlinxCoroutinesGuideSync05") { kotlinx.coroutines.guide.sync05.main() }.verifyLinesArbitraryTime( + fun testExampleSync05() { + test("ExampleSync05") { kotlinx.coroutines.guide.exampleSync05.main() }.verifyLinesArbitraryTime( "Completed 100000 actions in xxx ms", "Counter = 100000" ) } @Test - fun testKotlinxCoroutinesGuideSync06() { - test("KotlinxCoroutinesGuideSync06") { kotlinx.coroutines.guide.sync06.main() }.verifyLinesArbitraryTime( + fun testExampleSync06() { + test("ExampleSync06") { kotlinx.coroutines.guide.exampleSync06.main() }.verifyLinesArbitraryTime( "Completed 100000 actions in xxx ms", "Counter = 100000" ) } @Test - fun testKotlinxCoroutinesGuideSync07() { - test("KotlinxCoroutinesGuideSync07") { kotlinx.coroutines.guide.sync07.main() }.verifyLinesArbitraryTime( + fun testExampleSync07() { + test("ExampleSync07") { kotlinx.coroutines.guide.exampleSync07.main() }.verifyLinesArbitraryTime( "Completed 100000 actions in xxx ms", "Counter = 100000" ) diff --git a/kotlinx-coroutines-core/jvm/test/guide/test/TestUtil.kt b/kotlinx-coroutines-core/jvm/test/guide/test/TestUtil.kt index 11fe97e91c..fb1c85bce1 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/test/TestUtil.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/test/TestUtil.kt @@ -7,7 +7,7 @@ package kotlinx.coroutines.guide.test import kotlinx.coroutines.* import kotlinx.coroutines.internal.* import kotlinx.coroutines.scheduling.* -import java.io.* +import kotlinx.knit.test.* import java.util.concurrent.* import kotlin.test.* @@ -25,81 +25,35 @@ private inline fun outputException(name: String, block: () -> T): T = private const val SHUTDOWN_TIMEOUT = 5000L // 5 sec at most to wait private val OUT_ENABLED = systemProp("guide.tests.sout", false) -@Suppress("DEPRECATION") fun test(name: String, block: () -> R): List = outputException(name) { - val sout = System.out - val oldOut = if (OUT_ENABLED) System.out else NullOut - val oldErr = System.err - val bytesOut = ByteArrayOutputStream() - val tee = TeeOutput(bytesOut, oldOut) - val ps = PrintStream(tee) - - oldOut.println("--- Running test$name") - System.setErr(ps) - System.setOut(ps) - CommonPool.usePrivatePool() - DefaultScheduler.usePrivateScheduler() - DefaultExecutor.shutdown(SHUTDOWN_TIMEOUT) - resetCoroutineId() - val threadsBefore = currentThreads() - var bytes = ByteArray(0) - withVirtualTimeSource(oldOut) { - try { - val result = block() - require(result === Unit) { "Test 'main' shall return Unit" } - } catch (e: Throwable) { - System.err.print("Exception in thread \"main\" ") - e.printStackTrace() - } finally { - // capture output - bytes = bytesOut.toByteArray() - oldOut.println("--- shutting down") - // the shutdown - CommonPool.shutdown(SHUTDOWN_TIMEOUT) - DefaultScheduler.shutdown(SHUTDOWN_TIMEOUT) - shutdownDispatcherPools(SHUTDOWN_TIMEOUT) - DefaultExecutor.shutdown(SHUTDOWN_TIMEOUT) // the last man standing -- cleanup all pending tasks - if (tee.flushLine()) oldOut.println() - oldOut.println("--- done") - System.setOut(sout) - System.setErr(oldErr) - checkTestThreads(threadsBefore) - } - } - CommonPool.restore() - DefaultScheduler.restore() - return ByteArrayInputStream(bytes).bufferedReader().readLines() -} - -private class TeeOutput( - private val bytesOut: OutputStream, - private val oldOut: PrintStream -) : OutputStream() { - val limit = 200 - var lineLength = 0 - - fun flushLine(): Boolean { - if (lineLength > limit) - oldOut.print(" ($lineLength chars in total)") - val result = lineLength > 0 - lineLength = 0 - return result - } - - override fun write(b: Int) { - bytesOut.write(b) - if (b == 0x0d || b == 0x0a) { // new line - flushLine() - oldOut.write(b) - } else { - lineLength++ - if (lineLength <= limit) - oldOut.write(b) + try { + captureOutput(name, stdoutEnabled = OUT_ENABLED) { log -> + CommonPool.usePrivatePool() + DefaultScheduler.usePrivateScheduler() + DefaultExecutor.shutdown(SHUTDOWN_TIMEOUT) + resetCoroutineId() + val threadsBefore = currentThreads() + try { + withVirtualTimeSource(log) { + val result = block() + require(result === Unit) { "Test 'main' shall return Unit" } + } + } finally { + // the shutdown + log.println("--- shutting down") + CommonPool.shutdown(SHUTDOWN_TIMEOUT) + DefaultScheduler.shutdown(SHUTDOWN_TIMEOUT) + shutdownDispatcherPools(SHUTDOWN_TIMEOUT) + DefaultExecutor.shutdown(SHUTDOWN_TIMEOUT) // the last man standing -- cleanup all pending tasks + } + checkTestThreads(threadsBefore) // check thread if the main completed successfully } + } finally { + CommonPool.restore() + DefaultScheduler.restore() } } - private fun shutdownDispatcherPools(timeout: Long) { val threads = arrayOfNulls(Thread.activeCount()) val n = Thread.enumerate(threads) @@ -212,12 +166,6 @@ fun List.verifyLinesStart(vararg expected: String) = verify { checkEqualNumberOfLines(expected) } -private object NullOut : PrintStream(NullOutputStream()) - -private class NullOutputStream : OutputStream() { - override fun write(b: Int) = Unit -} - private inline fun List.verify(verification: () -> Unit) { try { verification() @@ -226,7 +174,6 @@ private inline fun List.verify(verification: () -> Unit) { println("Printing [delayed] test output") forEach { println(it) } } - throw t } } \ No newline at end of file diff --git a/reactive/knit.properties b/reactive/knit.properties new file mode 100644 index 0000000000..18aecba666 --- /dev/null +++ b/reactive/knit.properties @@ -0,0 +1,6 @@ +# +# Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. +# + +knit.package=kotlinx.coroutines.rx2.guide +knit.dir=kotlinx-coroutines-rx2/test/guide/ \ No newline at end of file diff --git a/reactive/knit.test.include b/reactive/knit.test.include new file mode 100644 index 0000000000..dd9e61d041 --- /dev/null +++ b/reactive/knit.test.include @@ -0,0 +1,11 @@ +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +// This file was automatically generated from ${file.name} by Knit tool. Do not edit. +package ${test.package} + +import kotlinx.coroutines.guide.test.* +import org.junit.Test + +class ${test.name} : ReactiveTestBase() { \ No newline at end of file diff --git a/reactive/kotlinx-coroutines-reactor/README.md b/reactive/kotlinx-coroutines-reactor/README.md index db1af0dab2..50e1602a3a 100644 --- a/reactive/kotlinx-coroutines-reactor/README.md +++ b/reactive/kotlinx-coroutines-reactor/README.md @@ -19,7 +19,7 @@ Integration with [Flow]: | --------------- | -------------- | --------------- | [Flow.asFlux] | `Flux` | Converts the given flow to the TCK-compliant Flux. -This adapter is integrated with Reactor's `Context` and coroutines [ReactiveContext]. +This adapter is integrated with Reactor's `Context` and coroutines [ReactorContext]. Conversion functions: @@ -35,11 +35,14 @@ Conversion functions: [CoroutineScope]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html [CoroutineDispatcher]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html + +[Flow]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html [mono]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactor/kotlinx.coroutines.reactor/mono.html [flux]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactor/kotlinx.coroutines.reactor/flux.html [Flow.asFlux]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactor/kotlinx.coroutines.reactor/kotlinx.coroutines.flow.-flow/as-flux.html +[ReactorContext]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactor/kotlinx.coroutines.reactor/-reactor-context/index.html [kotlinx.coroutines.Job.asMono]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactor/kotlinx.coroutines.reactor/kotlinx.coroutines.-job/as-mono.html [kotlinx.coroutines.Deferred.asMono]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactor/kotlinx.coroutines.reactor/kotlinx.coroutines.-deferred/as-mono.html [kotlinx.coroutines.channels.ReceiveChannel.asFlux]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-reactor/kotlinx.coroutines.reactor/kotlinx.coroutines.channels.-receive-channel/as-flux.html diff --git a/reactive/kotlinx-coroutines-rx2/README.md b/reactive/kotlinx-coroutines-rx2/README.md index b3874b05d3..7fbad95369 100644 --- a/reactive/kotlinx-coroutines-rx2/README.md +++ b/reactive/kotlinx-coroutines-rx2/README.md @@ -56,6 +56,8 @@ Conversion functions: [ProducerScope]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-producer-scope/index.html [ReceiveChannel]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-receive-channel/index.html + +[Flow]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html [rxCompletable]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-rx2/kotlinx.coroutines.rx2/rx-completable.html diff --git a/settings.gradle b/settings.gradle index 2925355dc1..3c1dc0c558 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,7 +15,6 @@ def module(String path) { // --------------------------- include('benchmarks') -include('knit') include('site') include "kotlinx-coroutines-core" diff --git a/ui/coroutines-guide-ui.md b/ui/coroutines-guide-ui.md index fc020cbd86..2ebe58f0e8 100644 --- a/ui/coroutines-guide-ui.md +++ b/ui/coroutines-guide-ui.md @@ -1,58 +1,3 @@ - - - # Guide to UI programming with coroutines This guide assumes familiarity with basic coroutine concepts that are @@ -100,7 +45,7 @@ context object for your favourite UI library, even if it is not included out of * [Advanced topics](#advanced-topics) * [Starting coroutine in UI event handlers without dispatch](#starting-coroutine-in-ui-event-handlers-without-dispatch) - + ## Setup @@ -409,7 +354,6 @@ You cannot do that from the main UI thread nor from the UI-confined coroutine di block the main UI thread and cause the freeze up of the UI.