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

Commit

Permalink
Add simple interface call test
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishiking committed Mar 11, 2024
1 parent 620ff4a commit af2d6ad
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions cli/src/main/scala/TestSuites.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ object TestSuites {
TestSuite("testsuite.core.add.Add", "add"),
TestSuite("testsuite.core.add.Add", "add"),
TestSuite("testsuite.core.virtualdispatch.VirtualDispatch", "virtualDispatch"),
TestSuite("testsuite.core.interfacecall.InterfaceCall", "interfaceCall"),
TestSuite("testsuite.core.asinstanceof.AsInstanceOfTest", "asInstanceOf"),
TestSuite("testsuite.core.hijackedclassesmono.HijackedClassesMonoTest", "hijackedClassesMono")
)
Expand Down
31 changes: 31 additions & 0 deletions test-suite/src/main/scala/testsuite/core/InterfaceCall.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package testsuite.core.interfacecall

import scala.scalajs.js.annotation._

object InterfaceCall {
def main(): Unit = { val _ = test() }

@JSExportTopLevel("interfaceCall")
def test(): Boolean = {
val c = new Concrete()
c.plus(c.zero, 1) == 1 && c.minus(1, c.zero) == 1
}

class Concrete extends AddSub with Zero {
override def zero: Int = 0
}

trait Adder {
def plus(a: Int, b: Int) = a + b
}

trait Sub {
def minus(a: Int, b: Int): Int = a - b
}

trait AddSub extends Adder with Sub

trait Zero {
def zero: Int
}
}

0 comments on commit af2d6ad

Please sign in to comment.