summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests/RangeMacroTest.scala
blob: 88a0730fcb4f088ceac9c8f54d6a4cf666225797 (plain)
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
// See LICENSE for license details.

package chiselTests

import chisel3._
import scala.language.experimental.macros
import org.scalatest._
import org.scalatest.prop._
import chisel3.testers.BasicTester

package object rangeMacroTest {

implicit class ChiselRange(val sc: StringContext) extends AnyVal {
  def range(args: Any*): Unit = macro chisel3.internal.RangeTransform.apply
}

}

import rangeMacroTest._

/** Comprehensive test of static range parsing functionality.
  * Note: negative (failure) conditions can't be tested because they will fail at compile time,
  * before the testing environment is entered.
  */
class RangeMacroSpec extends ChiselPropSpec {
  property("Range macros should work") {
    range"(0,${1+1}]"
    range"  (  0  ,  ${1+1}  ]  "
  }
}