summaryrefslogtreecommitdiff
path: root/examples/scala-js/compiler/src/test/scala/scala/scalajs/compiler/test/JSExportASTTest.scala
blob: 4a2b1af88d17a9862c9d5027c260aa91573a2b49 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package scala.scalajs.compiler.test

import util._

import org.junit.Test
import org.junit.Assert._

import scala.scalajs.ir.{Trees => js}

class JSExportASTTest extends JSASTTest {

  @Test
  def inheritExportMethods: Unit = {

    var props = 0

    """
    import scala.scalajs.js.annotation.JSExport

    class A {
      @JSExport
      def foo = 1
    }

    class B extends A {
      @JSExport
      override def foo = 2
    }
    """.traverse {
      case js.PropertyDef(js.StringLiteral("foo"), _, _, _) =>
        props += 1
    }

    assertEquals("Only define the property `foo` once", props, 1)

  }

}