File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
tests/run/reflect-select-copy Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ import scala .quoted ._
2+ import scala .tasty ._
3+
4+ object scalatest {
5+
6+ inline def assert (condition : => Boolean ): Unit = ~ assertImpl('(condition), ' (" " ))
7+
8+ def assertImpl (cond : Expr [Boolean ], clue : Expr [Any ])(implicit refl : Reflection ): Expr [Unit ] = {
9+ import refl ._
10+ import quoted .Toolbox .Default ._
11+
12+ cond.unseal.underlyingArgument match {
13+ case Term .Apply (sel @ Term .Select (lhs, op), rhs :: Nil ) =>
14+ val Term .IsSelect (select) = sel
15+ val cond = Term .Apply (Term .Select .copy(select)(lhs, " >" ), rhs :: Nil ).seal[Boolean ]
16+ ' { scala.Predef .assert(~ cond) }
17+ case _ =>
18+ ' { scala.Predef .assert(~ cond) }
19+ }
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ object Test {
2+ import scalatest ._
3+
4+ class Box (val x : Int ) {
5+ def > (y : Int ): Boolean = x > y
6+ def > (b : Box ): Boolean = x > b.x
7+ }
8+
9+ def main (args : Array [String ]): Unit = {
10+ val a : Int = 100
11+ assert(a > 5 )
12+ assert(a > 5.0 )
13+ assert(a > 'a' )
14+
15+ val b1 = new Box (10 )
16+ val b2 = new Box (3 )
17+ assert(b1 > 4 )
18+ assert(b1 > b2)
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments