File tree Expand file tree Collapse file tree 2 files changed +31
-7
lines changed Expand file tree Collapse file tree 2 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -1259,6 +1259,7 @@ object Build {
1259
1259
1260
1260
++ conditionally(! hasModules, " js/src/test/require-no-modules" )
1261
1261
++ conditionally(hasModules, " js/src/test/require-modules" )
1262
+ ++ conditionally(hasModules && ! linkerConfig.closureCompiler, " js/src/test/require-multi-modules" )
1262
1263
++ conditionally(moduleKind == ModuleKind .ESModule , " js/src/test/require-dynamic-import" )
1263
1264
++ conditionally(moduleKind == ModuleKind .ESModule , " js/src/test/require-esmodule" )
1264
1265
)
Original file line number Diff line number Diff line change 1
1
package hello
2
2
3
- import scala .scalajs .js
3
+ import scala .concurrent ._
4
+ import scala .concurrent .ExecutionContext .Implicits .global
4
5
5
- trait MyTrait {
6
- val x = 5
7
- def foo (y : Int ) = x
8
- }
6
+ import scala .scalajs .js
7
+ import scala .scalajs .js .annotation ._
9
8
10
- object HelloWorld extends MyTrait {
9
+ object HelloWorld {
11
10
def main (args : Array [String ]): Unit = {
12
11
println(" hello dotty.js!" )
13
- println(foo( 4 ))
12
+ new Test ().localDefDynamic().onComplete(println(_ ))
14
13
}
15
14
}
15
+
16
+ class Test {
17
+ def localDefDynamic (): Future [Unit ] = {
18
+ assertDynamicLoad {
19
+ js.dynamicImport {
20
+ def test (x : Int ) = FailureOnLoad
21
+ test(2 )
22
+ }
23
+ }
24
+ }
25
+
26
+ private def assertDynamicLoad [T ](promise : js.Promise [T ]): Future [Unit ] = {
27
+ promise.toFuture
28
+ .map(_ => throw new AssertionError (" expected failure" ))
29
+ .recover {
30
+ case js.JavaScriptException (e : js.Error )
31
+ if e.message == " load failure for test" =>
32
+ }
33
+ }
34
+ }
35
+
36
+ @ JSImport (" ../test-classes/fail-load.js" , JSImport .Default )
37
+ @ js.native
38
+ private object FailureOnLoad extends js.Object
You can’t perform that action at this time.
0 commit comments