From 73f89d0c029acd65cdb1f2d92585d9e99f9c301c Mon Sep 17 00:00:00 2001 From: Olivier Melois Date: Sat, 26 Sep 2020 19:37:30 +0200 Subject: [PATCH] Moving flag from constructor to member --- jvm/src/test/scala/org/expecty/ExpectyLocationSpec.scala | 2 +- shared/src/main/scala/com/eed3si9n/expecty/Expecty.scala | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/jvm/src/test/scala/org/expecty/ExpectyLocationSpec.scala b/jvm/src/test/scala/org/expecty/ExpectyLocationSpec.scala index 706410f..05eca39 100644 --- a/jvm/src/test/scala/org/expecty/ExpectyLocationSpec.scala +++ b/jvm/src/test/scala/org/expecty/ExpectyLocationSpec.scala @@ -19,7 +19,7 @@ import junit.framework.ComparisonFailure import com.eed3si9n.expecty.Expecty class ExpectyLocationSpec { - val assert = new Expecty(true) // (displayLoc = true) + val assert = new Expecty { override val showLocation = true } @Test def position(): Unit = { diff --git a/shared/src/main/scala/com/eed3si9n/expecty/Expecty.scala b/shared/src/main/scala/com/eed3si9n/expecty/Expecty.scala index 4b2bd52..664eed5 100644 --- a/shared/src/main/scala/com/eed3si9n/expecty/Expecty.scala +++ b/shared/src/main/scala/com/eed3si9n/expecty/Expecty.scala @@ -14,9 +14,10 @@ package com.eed3si9n.expecty -class Expecty(displayLoc: Boolean = false) extends Recorder[Boolean, Unit] { +class Expecty extends Recorder[Boolean, Unit] { val failEarly: Boolean = true val showTypes: Boolean = false + val showLocation: Boolean = false // val printAsts: Boolean = false // val printExprs: Boolean = false @@ -28,7 +29,7 @@ class Expecty(displayLoc: Boolean = false) extends Recorder[Boolean, Unit] { // if (printExprs) println(rendering) if (!recordedExpr.value && failEarly) { val loc = recordedExpr.location - val locStr = if(displayLoc) " (" + loc.relativePath + ":" + loc.line + ")" else "" + val locStr = if(showLocation) " (" + loc.relativePath + ":" + loc.line + ")" else "" val msg = recordedMessage() val header = "assertion failed" + locStr +