From dd0e4af1a4a6c638ecdc0d29f9abb7b77641a136 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 29 Mar 2017 18:33:46 +0300 Subject: Implement assertion replacement templates for samples --- core/testdata/format/website-html/sampleWithAsserts.html | 5 ++++- core/testdata/format/website-html/sampleWithAsserts.kt | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'core/testdata/format/website-html') diff --git a/core/testdata/format/website-html/sampleWithAsserts.html b/core/testdata/format/website-html/sampleWithAsserts.html index 012f91ab..7d014dbb 100644 --- a/core/testdata/format/website-html/sampleWithAsserts.html +++ b/core/testdata/format/website-html/sampleWithAsserts.html @@ -2,11 +2,14 @@

a

fun a(): String
-

+
import java.io.FileNotFoundException
+import java.io.File
 
 fun main(args: Array) {
 //sampleStart
 println(a()) // Hello, Work
 println("a() == b() is ${a() == b()}") // true
+// readSomeFile(File("some.txt")) // reading file now will fail
+// readSomeFile(File("some.txt")) // will fail with FileNotFoundException
 //sampleEnd
 }
diff --git a/core/testdata/format/website-html/sampleWithAsserts.kt b/core/testdata/format/website-html/sampleWithAsserts.kt index bb9732d5..f5b03eb8 100644 --- a/core/testdata/format/website-html/sampleWithAsserts.kt +++ b/core/testdata/format/website-html/sampleWithAsserts.kt @@ -1,3 +1,6 @@ +import java.io.FileNotFoundException +import java.io.File + /** * @sample sample */ @@ -9,7 +12,16 @@ 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()) + assertFails("reading file now") { readSomeFile(File("some.txt")) } + assertFailsWith { readSomeFile(File("some.txt")) } } \ No newline at end of file -- cgit