Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ fileOverride {
}
}
project.excludePaths = [
"glob:scalafix/**/input/**",
"glob:scalafix/**/output/**"
"glob:**/scalafix/**/input/**",
"glob:**/scalafix/**/output/**"
]
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,19 @@ import cats.effect.IO
object RenameAssertionExceptionToExpectationFailed extends SimpleIOSuite {

test("raise") {
IO.raiseError(AssertionException(
"some reason",
NonEmptyList.of(implicitly[SourceLocation]))).as(success)
IO.raiseError(AssertionException("some reason", NonEmptyList.of(implicitly[SourceLocation]))).as(success)
}

test("match") {
val program: IO[Unit] = IO.unit
program.attemptTap {
case Left(ex: AssertionException) => IO.println(ex)
case _ => IO.unit
case _ => IO.unit
}.as(success)
}

test("import") {
import weaver.AssertionException
IO.raiseError(AssertionException(
"some reason",
NonEmptyList.of(implicitly[SourceLocation]))).as(success)
IO.raiseError(AssertionException("some reason", NonEmptyList.of(implicitly[SourceLocation]))).as(success)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@ import cats.effect.IO
object RenameAssertionExceptionToExpectationFailed extends SimpleIOSuite {

test("raise") {
IO.raiseError(new ExpectationFailed(
"some reason",
NonEmptyList.of(implicitly[SourceLocation]))).as(success)
IO.raiseError(new ExpectationFailed("some reason", NonEmptyList.of(implicitly[SourceLocation]))).as(success)
}

test("match") {
val program: IO[Unit] = IO.unit
program.attemptTap {
case Left(ex: ExpectationFailed) => IO.println(ex)
case _ => IO.unit
case _ => IO.unit
}.as(success)
}

test("import") {
import weaver.ExpectationFailed
IO.raiseError(new ExpectationFailed(
"some reason",
NonEmptyList.of(implicitly[SourceLocation]))).as(success)
IO.raiseError(new ExpectationFailed("some reason", NonEmptyList.of(implicitly[SourceLocation]))).as(success)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object AddClueToExpectTest extends SimpleIOSuite {
expect(!a.isInstanceOf[Int])
}

pureTest("select") {
pureTest("select"){
val either = Left[Int, Int](1)
expect(either.toOption.isEmpty)
}
Expand Down Expand Up @@ -79,7 +79,7 @@ object AddClueToExpectTest extends SimpleIOSuite {
}

pureTest("ignore blocks") {
expect(Some(1).fold(true)({ _ => b == c }))
expect(Some(1).fold(true)({_ => b == c }))
}

}
10 changes: 5 additions & 5 deletions scalafix/v0_9_0/input/src/main/scala/fix/RewriteExpectTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ object RewriteExpectTest extends SimpleIOSuite {
pureTest("infer order with sealed traits") {
sealed trait Pet
object Pet {
case object Cat extends Pet
case object Cat extends Pet
case class Dog(friend: Pet) extends Pet
}
val petCat = Pet.Cat
Expand All @@ -107,10 +107,10 @@ object RewriteExpectTest extends SimpleIOSuite {

pureTest("infer order with common names") {
val expectedId = 1
val actualId = 2
val actualId = 2
val obtainedId = 3
val result = 4
expect(result == expectedId && actualId == expectedId &&
obtainedId == expectedId)
val result = 4
expect(result == expectedId && actualId == expectedId && obtainedId == expectedId)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ object AddClueToExpectTest extends SimpleIOSuite {
val c: Int = 3

pureTest("multiple") {
expect(clue(a) == clue(b)) and
expect(clue(b) == clue(c)) && not(expect(clue(c) == clue(a)))
expect(clue(a) == clue(b)) and expect(clue(b) == clue(c)) && not(expect(clue(c) == clue(a)))
}

pureTest("infix") {
Expand Down Expand Up @@ -42,7 +41,7 @@ object AddClueToExpectTest extends SimpleIOSuite {
expect(!clue(a).isInstanceOf[Int])
}

pureTest("select") {
pureTest("select"){
val either = Left[Int, Int](1)
expect(clue(either.toOption).isEmpty)
}
Expand All @@ -65,9 +64,7 @@ object AddClueToExpectTest extends SimpleIOSuite {

pureTest("all") {
def isGreater(a: Int, b: Int, c: Int): Boolean = a > b && b > c
expect.all(clue(a) == clue(b),
clue(Some(2)).nonEmpty,
isGreater(clue(a), clue(b), clue(c)))
expect.all(clue(a) == clue(b), clue(Some(2)).nonEmpty, isGreater(clue(a), clue(b), clue(c)))
}

pureTest("ignore clue in expect.all") {
Expand All @@ -80,8 +77,8 @@ object AddClueToExpectTest extends SimpleIOSuite {

pureTest("ignore blocks") {
expect(clue(Some(1)).fold(true) {
_ => b == c
})
_ => b == c
})
}

}
38 changes: 17 additions & 21 deletions scalafix/v0_9_0/output/src/main/scala/fix/RewriteExpectTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ object RewriteExpectTest extends SimpleIOSuite {
}

pureTest("nested ==") {
expect.same(1, 1).and(expect.same(2, 2)) and
expect.same(1, 1).and(expect(2 >= 2))
expect.same(1, 1).and(expect.same(2, 2)) and expect.same(1, 1).and(expect(2 >= 2))
}

pureTest("===") {
Expand All @@ -38,28 +37,27 @@ object RewriteExpectTest extends SimpleIOSuite {
}

pureTest("if then else if") {
if (1 == 2) expect(3 > 4)
else if (2 == 3) expect.same(5, 5) else expect(4 > 3)
if (1 == 2) expect(3 > 4) else if (2 == 3) expect.same(5, 5) else expect(4 > 3)
}

pureTest("match") {
val n: Int = 1
n match {
case 2 =>
expect(1 > 2)
case 3 =>
success
case 4 =>
failure("Assertion failed")
}
case 2 =>
expect(1 > 2)
case 3 =>
success
case 4 =>
failure("Assertion failed")
}
}

pureTest("match with wildcard false") {
val n: Int = 1
matches(n) {
case 2 =>
expect(1 > 2)
}
case 2 =>
expect(1 > 2)
}
}

pureTest("expect.all ==") {
Expand All @@ -79,8 +77,7 @@ object RewriteExpectTest extends SimpleIOSuite {
}

pureTest("expect.all with || and &&") {
expect(1 > 0).and(expect.same(2, 2)).and(expect(2 > 0).or(expect(3 >
4))).and(expect.same(2, 2))
expect(1 > 0).and(expect.same(2, 2)).and(expect(2 > 0).or(expect(3 > 4))).and(expect.same(2, 2))
}

pureTest("expect.all ignore clue") {
Expand All @@ -100,7 +97,7 @@ object RewriteExpectTest extends SimpleIOSuite {
pureTest("infer order with sealed traits") {
sealed trait Pet
object Pet {
case object Cat extends Pet
case object Cat extends Pet
case class Dog(friend: Pet) extends Pet
}
val petCat = Pet.Cat
Expand All @@ -110,10 +107,9 @@ object RewriteExpectTest extends SimpleIOSuite {

pureTest("infer order with common names") {
val expectedId = 1
val actualId = 2
val actualId = 2
val obtainedId = 3
val result = 4
expect.same(expectedId, result).and(expect.same(expectedId, actualId)).and(
expect.same(expectedId, obtainedId))
val result = 4
expect.same(expectedId, result).and(expect.same(expectedId, actualId)).and(expect.same(expectedId, obtainedId))
}
}
Loading