diff options
Diffstat (limited to 'core/testdata/format/website-samples')
5 files changed, 53 insertions, 0 deletions
diff --git a/core/testdata/format/website-samples/dropImport.md b/core/testdata/format/website-samples/dropImport.md index 13c8fb79..1e05678b 100644 --- a/core/testdata/format/website-samples/dropImport.md +++ b/core/testdata/format/website-samples/dropImport.md @@ -12,6 +12,7 @@ layout: api ``` kotlin import some.* + fun main(args: Array<String>) { //sampleStart diff --git a/core/testdata/format/website-samples/newLinesInSamples.kt b/core/testdata/format/website-samples/newLinesInSamples.kt new file mode 100644 index 00000000..ee49aefc --- /dev/null +++ b/core/testdata/format/website-samples/newLinesInSamples.kt @@ -0,0 +1,19 @@ +fun groupBySample() { + val words = listOf("a", "abc", "ab", "def", "abcd") + val byLength = words.groupBy { it.length } + + assertPrints(byLength.keys, "[1, 3, 2, 4]") + assertPrints(byLength.values, "[[a], [abc, def], [ab], [abcd]]") + + val mutableByLength: MutableMap<Int, MutableList<String>> = words.groupByTo(mutableMapOf()) { it.length } + // same content as in byLength map, but the map is mutable + assertTrue(mutableByLength == byLength) +} + + +/** + * @sample groupBySample + */ +fun foo() { + +}
\ No newline at end of file diff --git a/core/testdata/format/website-samples/newLinesInSamples.md b/core/testdata/format/website-samples/newLinesInSamples.md new file mode 100644 index 00000000..5344b983 --- /dev/null +++ b/core/testdata/format/website-samples/newLinesInSamples.md @@ -0,0 +1,31 @@ +--- +title: foo - test +layout: api +--- + +<div class='api-docs-breadcrumbs'><a href="test/index">test</a> / <a href="test/foo">foo</a></div> + +# foo + +<div class="signature"><code><span class="keyword">fun </span><span class="identifier">foo</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></div> +<div class="sample" markdown="1"> + +``` kotlin + + +fun main(args: Array<String>) { +//sampleStart +val words = listOf("a", "abc", "ab", "def", "abcd") +val byLength = words.groupBy { it.length } + +println(byLength.keys) // [1, 3, 2, 4] +println(byLength.values) // [[a], [abc, def], [ab], [abcd]] + +val mutableByLength: MutableMap<Int, MutableList<String>> = words.groupByTo(mutableMapOf()) { it.length } +// same content as in byLength map, but the map is mutable +println("mutableByLength == byLength is ${mutableByLength == byLength}") // true +//sampleEnd +} +``` + +</div> diff --git a/core/testdata/format/website-samples/sample.md b/core/testdata/format/website-samples/sample.md index 203f1b02..b29075a7 100644 --- a/core/testdata/format/website-samples/sample.md +++ b/core/testdata/format/website-samples/sample.md @@ -18,6 +18,7 @@ applied to each element and returns a map where each group key is associated wit ``` kotlin + fun main(args: Array<String>) { //sampleStart if (true) { diff --git a/core/testdata/format/website-samples/sampleWithAsserts.md b/core/testdata/format/website-samples/sampleWithAsserts.md index 98d7df33..c114468a 100644 --- a/core/testdata/format/website-samples/sampleWithAsserts.md +++ b/core/testdata/format/website-samples/sampleWithAsserts.md @@ -12,6 +12,7 @@ layout: api ``` kotlin + fun main(args: Array<String>) { //sampleStart println(a()) // Hello, Work |