Minor. Simplify 'async' tests

This commit is contained in:
Denis Zharkov
2016-06-17 15:39:22 +03:00
parent 72eb87f5d0
commit 96eb3f411d
2 changed files with 4 additions and 15 deletions
+4 -13
View File
@@ -12,10 +12,8 @@ fun foobar(x: String, y: String) = x + y
fun box(): String {
var result = ""
fun log(x: String) {
synchronized(result) {
if (result.isNotEmpty()) result += "\n"
result += x
}
if (result.isNotEmpty()) result += "\n"
result += x
}
val future = async<String> {
@@ -29,14 +27,7 @@ fun box(): String {
future.whenComplete { value, t ->
log("completed with '$value'")
}
future.join()
java.lang.Thread.sleep(1000)
val readResult = synchronized(result) {
result
}
}.join()
val expectedResult =
"""
@@ -45,7 +36,7 @@ fun box(): String {
|got '123 bar with foo' after 'foo'
|completed with '123 bar with foo'""".trimMargin().trim('\n', ' ')
if (expectedResult != readResult) return readResult
if (expectedResult != result) return result
return "OK"
}
-2
View File
@@ -23,8 +23,6 @@ fun box(): String {
if (future.get() != "56") return "fail: ${future.get()}"
java.lang.Thread.sleep(1000)
if (result != "OK") return "fail notOk"
val future2 = async<String>() {