~ubuntu-branches/debian/sid/scala/sid

« back to all changes in this revision

Viewing changes to test/files/run/elidable.scala

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg, Mehdi Dogguy, Lucas Satabin, Frank S. Thomas, Emmanuel Bourg
  • Date: 2015-06-05 23:52:59 UTC
  • mfrom: (1.2.11)
  • Revision ID: package-import@ubuntu.com-20150605235259-wk00vgk83dh8o19g
Tags: 2.10.5-1
* Team upload.

[ Mehdi Dogguy ]
* New upstream release (Closes: #744278).

[ Lucas Satabin ]
* Update patches
* Update the clean target
* Update paths of elements to install
* Update watch file

[ Frank S. Thomas ]
* Remove myself from Uploaders.

[ Emmanuel Bourg ]
* The package has been adopted by the Java Team (Closes: #754935)
* Patched the build to avoid downloading libraries from the Internet
* Replaced the minified JavaScript files with unobfuscated ones
* No longer build scala-partest.jar until diffutils is packaged or replaced
* debian/watch: Fixed the versions matched (x.y.z instead of x.y.z..z)
* debian/rules:
  - Added the missing get-orig-source target (Closes: #724704)
  - Improved the clean target
* debian/control:
  - Build depend on scala (>= 2.10) and bnd
  - Use canonical URLs for the Vcs-* fields
  - Standards-Version updated to 3.9.6 (no changes)
* Switch to debhelper level 9

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import annotation._
2
2
import elidable._
3
3
 
 
4
trait T {
 
5
  @elidable(FINEST) def f1()
 
6
  @elidable(SEVERE) def f2()
 
7
  @elidable(FINEST) def f3() = assert(false, "Should have been elided.")
 
8
  def f4()
 
9
}
 
10
 
 
11
class C extends T {
 
12
  def f1() = println("Good for me, I was not elided. C.f1")
 
13
  def f2() = println("Good for me, I was not elided. C.f2")
 
14
  @elidable(FINEST) def f4() = assert(false, "Should have been elided.")
 
15
}
 
16
 
 
17
object O {
 
18
  @elidable(FINEST) def f1() = assert(false, "Should have been elided.")
 
19
  @elidable(INFO) def f2() = assert(false, "Should have been elided.")
 
20
  @elidable(SEVERE) def f3() = println("Good for me, I was not elided. O.f3")
 
21
  @elidable(INFO) def f4 = assert(false, "Should have been elided (no parens).")
 
22
}
 
23
 
4
24
object Test {
5
25
  @elidable(FINEST) def f1() = assert(false, "Should have been elided.")
6
26
  @elidable(INFO) def f2() = assert(false, "Should have been elided.")
7
 
  @elidable(SEVERE) def f3() = println("Good for me, I was not elided.")
 
27
  @elidable(SEVERE) def f3() = println("Good for me, I was not elided. Test.f3")
8
28
  @elidable(INFO) def f4 = assert(false, "Should have been elided (no parens).")
9
 
  
 
29
 
 
30
  @elidable(FINEST) def f5() = {}
 
31
  @elidable(FINEST) def f6() = true
 
32
  @elidable(FINEST) def f7() = 1:Byte
 
33
  @elidable(FINEST) def f8() = 1:Short
 
34
  @elidable(FINEST) def f9() = 1:Char
 
35
  @elidable(FINEST) def fa() = 1
 
36
  @elidable(FINEST) def fb() = 1l
 
37
  @elidable(FINEST) def fc() = 1.0f
 
38
  @elidable(FINEST) def fd() = 1.0
 
39
  @elidable(FINEST) def fe() = "s"
 
40
 
10
41
  def main(args: Array[String]): Unit = {
11
42
    f1()
12
43
    f2()
13
44
    f3()
14
45
    f4
 
46
    O.f1()
 
47
    O.f2()
 
48
    O.f3()
 
49
    O.f4
 
50
 
 
51
    val c = new C
 
52
    c.f1()
 
53
    c.f2()
 
54
    c.f3()
 
55
    c.f4()
 
56
 
 
57
    // make sure a return value is still available when eliding a call
 
58
    println(f5())
 
59
    println(f6())
 
60
    println(f7())
 
61
    println(f8())
 
62
    println(f9().toInt)
 
63
    println(fa())
 
64
    println(fb())
 
65
    println(fc())
 
66
    println(fd())
 
67
    println(fe())
 
68
 
 
69
    // this one won't show up in the output because a call to f1 is elidable when accessed through T
 
70
    (c:T).f1()
 
71
 
 
72
    // Test whether the method definitions are still available.
 
73
    List("Test", "Test$", "O", "O$", "C", "T") foreach { className =>
 
74
      List("f1", "f2", "f3", "f4") foreach { methodName =>
 
75
        Class.forName(className).getMethod(methodName)
 
76
      }
 
77
    }
 
78
    List("Test", "Test$") foreach { className =>
 
79
      List("f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe") foreach { methodName =>
 
80
        Class.forName(className).getMethod(methodName)
 
81
      }
 
82
    }
 
83
    Class.forName("T$class").getMethod("f3", classOf[T])
15
84
  }
16
85
}