blob: 162f796c6348473ab3b0088e463f0ef7575086d6 (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
import scala.tools.partest.utils.CodeTest
case class Element(name: String)
object Test extends App {
case class InnerElement(name: String)
def foo[T](ys: List[T]) = {
val fun: reflect.Code[Int => Int] = x => x + ys.length
fun
}
CodeTest(foo(List(2)), args)
CodeTest({() => val e = Element("someName"); e}, args)
// CodeTest({() => val e = InnerElement("someName"); e}, args) // (does not work yet)
def titi() = {
var truc = 0
CodeTest(() => {
truc = 6
}, args)
}
def tata(): Unit = {
var truc = 0
CodeTest(() => {
truc = truc + 6
}, args)
}
titi()
tata()
new baz.A(args)
def show() {
def foo[T](ys: List[T]) = {
val fun: reflect.Code[Int => Int] = x => x + ys.length
CodeTest(fun, args)
}
foo(List(1, 2, 3))
}
show()
def evaltest(x: Int) = {
CodeTest.static(() => x + 1, args)
CodeTest(() => x + 1, args)
}
println("1+1 = "+evaltest(1))
}
package baz {
case class BazElement(name: String) { }
class A(args: Array[String]) {
CodeTest(() => new baz.BazElement("someName"), args)
}
}
|