aboutsummaryrefslogtreecommitdiff
path: root/core/testdata/format/website-html/sampleWithAsserts.kt
blob: bb5848e6bb1d610ae2eb4b90054c491860b47f61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.io.FileNotFoundException
import java.io.File

/**
 * @sample sample
 */
fun a(): String {
    return "Hello, Work"
}

fun b(): String {
    return "Hello, Rest"
}

/**
 * @throws FileNotFoundException every time
 */
fun readSomeFile(f: File) {
    throw FileNotFoundException("BOOM")
}

fun sample() {
    assertPrints(a(), "Hello, Work")
    assertTrue(a() == b())
    assertTrue(a() == b(), "A eq B")
    assertFails("reading file now") { readSomeFile(File("some.txt")) }
    assertFailsWith<FileNotFoundException> { readSomeFile(File("some.txt")) }

    assertFails { readSomeFile(File("some.txt")) }

    fun indented() {
        assertFalse(a() != b(), "A neq B")
    }
}