File tree Expand file tree Collapse file tree 3 files changed +23
-11
lines changed Expand file tree Collapse file tree 3 files changed +23
-11
lines changed Original file line number Diff line number Diff line change @@ -2,22 +2,15 @@ package utest
2
2
3
3
// Taken from the implementation for JS
4
4
5
- import scala .concurrent .Future
5
+ import scala .concurrent .{Await , Future }
6
+ import concurrent .duration ._
6
7
import scala .scalanative .reflect .Reflect
7
8
8
9
/**
9
10
* Platform specific stuff that differs between JVM, JS and Native
10
11
*/
11
12
object PlatformShims {
12
- def await [T ](f : Future [T ]): T = {
13
- scala.scalanative.runtime.loop()
14
- f.value match {
15
- case Some (v) => v.get
16
- case None => throw new IllegalStateException (
17
- " Test that returns Future must be run asynchronously in Scala Native, see TestTreeSeq::runAsync"
18
- )
19
- }
20
- }
13
+ def await [T ](f : Future [T ]): T = Await .result(f, Duration .Inf )
21
14
22
15
type EnableReflectiveInstantiation =
23
16
scala.scalanative.reflect.annotation.EnableReflectiveInstantiation
Original file line number Diff line number Diff line change @@ -171,7 +171,9 @@ object TestRunner {
171
171
case HTree .Leaf (f) => f().map(HTree .Leaf (_))
172
172
case HTree .Node (v, children @ _* ) =>
173
173
for {
174
- childValues <- Future .traverse(children.toSeq)(evaluateFutureTree(_))
174
+ childValues <- children.foldLeft(Future .successful(List .newBuilder[HTree [N , L ]])) { (fb, c) =>
175
+ fb.flatMap(b => evaluateFutureTree(c).map(b += _))
176
+ }.map(_.result())
175
177
} yield HTree .Node (v, childValues:_* )
176
178
}
177
179
Original file line number Diff line number Diff line change
1
+ package test .utest
2
+ import utest ._
3
+ import concurrent .{Future , ExecutionContext }
4
+
5
+ object FutureTest extends TestSuite {
6
+ implicit val ec : ExecutionContext = ExecutionContext .global
7
+ @ volatile var flag = false
8
+
9
+ def tests = TestSuite {
10
+ test(" runs before next test" ){
11
+ Future { flag = true }
12
+ }
13
+ test(" previous test ran first" ){
14
+ assert(flag)
15
+ }
16
+ }
17
+ }
You can’t perform that action at this time.
0 commit comments