Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Commit af2d6ad

Browse files
committed
Add simple interface call test
1 parent 620ff4a commit af2d6ad

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Diff for: cli/src/main/scala/TestSuites.scala

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ object TestSuites {
77
TestSuite("testsuite.core.add.Add", "add"),
88
TestSuite("testsuite.core.add.Add", "add"),
99
TestSuite("testsuite.core.virtualdispatch.VirtualDispatch", "virtualDispatch"),
10+
TestSuite("testsuite.core.interfacecall.InterfaceCall", "interfaceCall"),
1011
TestSuite("testsuite.core.asinstanceof.AsInstanceOfTest", "asInstanceOf"),
1112
TestSuite("testsuite.core.hijackedclassesmono.HijackedClassesMonoTest", "hijackedClassesMono")
1213
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package testsuite.core.interfacecall
2+
3+
import scala.scalajs.js.annotation._
4+
5+
object InterfaceCall {
6+
def main(): Unit = { val _ = test() }
7+
8+
@JSExportTopLevel("interfaceCall")
9+
def test(): Boolean = {
10+
val c = new Concrete()
11+
c.plus(c.zero, 1) == 1 && c.minus(1, c.zero) == 1
12+
}
13+
14+
class Concrete extends AddSub with Zero {
15+
override def zero: Int = 0
16+
}
17+
18+
trait Adder {
19+
def plus(a: Int, b: Int) = a + b
20+
}
21+
22+
trait Sub {
23+
def minus(a: Int, b: Int): Int = a - b
24+
}
25+
26+
trait AddSub extends Adder with Sub
27+
28+
trait Zero {
29+
def zero: Int
30+
}
31+
}

0 commit comments

Comments
 (0)