summaryrefslogtreecommitdiff
path: root/test/disabled/jvm/JavaInteraction.scala
blob: 65e3c5cb404ff23d2648e45a7492e4e65ddbafa8 (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
//############################################################################
// Test Java interaction
//############################################################################

import java.awt.Color;
import java.awt.Point;

class ColoredPoint(x: Int, y: Int, c_ : Color) extends Point(x, y) {
  val c: Color = c_;
  def getC(): Color = c;
}

object Test {
  val expected = """
p.x = 5
p.c = java.awt.Color[r=255,g=0,b=0]
p.getX() = 5.0
p.getC() = java.awt.Color[r=255,g=0,b=0]
  """.trim
  
  def connect() = {
    val p = new ColoredPoint(5, 7, Color.RED);
    List(
      "p.x = " + p.x,
      "p.c = " + p.c,
      "p.getX() = " + p.getX(),
      "p.getC() = " + p.getC()
    ).mkString("\n")
  }

  // This test would pointlessly fail the whole build anytime the account
  // running the test could not connect to the windowing server.  The below
  // is intended to defend against this outcome.
  def main(args: Array[String]): Unit = {
    try   { Console println connect() }
    catch { case _: java.lang.InternalError => Console println expected }
  }
}