summaryrefslogtreecommitdiff
path: root/test/files/scalacheck/quasiquotes/LiftableProps.scala
blob: 510ab9906853e098f2be2a86afcf7892a658c098 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import org.scalacheck._
import Prop._
import Gen._
import Arbitrary._

import scala.reflect.runtime.universe._
import Flag._

object LiftableProps extends QuasiquoteProperties("liftable") {
  property("splice byte") = test {
    val c: Byte = 0
    assert(q"$c"  Literal(Constant(c)))
  }

  property("splice short") = test {
    val c: Short = 0
    assert(q"$c"  Literal(Constant(c)))
  }

  property("splice char") = test {
    val c: Char = 'c'
    assert(q"$c"  Literal(Constant(c)))
  }

  property("splice int") = test {
    val c: Int = 0
    assert(q"$c"  Literal(Constant(c)))
  }

  property("splice long") = test {
    val c: Long = 0
    assert(q"$c"  Literal(Constant(c)))
  }

  property("splice float") = test {
    val c: Float = 0.0f
    assert(q"$c"  Literal(Constant(c)))
  }

  property("splice double") = test {
    val c: Double = 0.0
    assert(q"$c"  Literal(Constant(c)))
  }

  property("splice boolean") = test {
    val c: Boolean = false
    assert(q"$c"  Literal(Constant(c)))
  }

  property("splice string") = test {
    val c: String = "s"
    assert(q"$c"  Literal(Constant(c)))
  }

  property("splice unit") = test {
    val c: Unit = ()
    assert(q"$c"  Literal(Constant(c)))
  }

  property("lift symbol") = test {
    val s = rootMirror.staticClass("scala.Int")
    assert(q"$s"  Ident(s))
  }

  property("lift type") = test {
    val tpe = rootMirror.staticClass("scala.Int").toType
    assert(q"$tpe"  TypeTree(tpe))
  }

  property("lift type tag") = test {
    val tag = TypeTag.Int
    assert(q"$tag"  TypeTree(tag.tpe))
  }

  property("lift weak type tag") = test {
    val tag = WeakTypeTag.Int
    assert(q"$tag"  TypeTree(tag.tpe))
  }

  property("lift constant") = test {
    val const = Constant(0)
    assert(q"$const"  q"0")
  }
}