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
22
33// Taken from the implementation for JS
44
5- import scala .concurrent .Future
5+ import scala .concurrent .{Await , Future }
6+ import concurrent .duration ._
67import scala .scalanative .reflect .Reflect
78
89/**
910 * Platform specific stuff that differs between JVM, JS and Native
1011 */
1112object 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 )
2114
2215 type EnableReflectiveInstantiation =
2316 scala.scalanative.reflect.annotation.EnableReflectiveInstantiation
Original file line number Diff line number Diff line change @@ -171,7 +171,9 @@ object TestRunner {
171171 case HTree .Leaf (f) => f().map(HTree .Leaf (_))
172172 case HTree .Node (v, children @ _* ) =>
173173 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())
175177 } yield HTree .Node (v, childValues:_* )
176178 }
177179
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