-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Issue#165] reject calls to _.to and _.into.transform (and their fall…
- Loading branch information
Showing
4 changed files
with
103 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
ducktape/src/test/scala/io/github/arainko/ducktape/issues/Issue165Suite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package io.github.arainko.ducktape.issues | ||
|
||
import io.github.arainko.ducktape.* | ||
|
||
class Issue165Suite extends DucktapeSuite { | ||
test("rejects _.to in given Transformer definitions") { | ||
assertFailsToCompileWith { | ||
""" | ||
case class A(a: Int) | ||
case class B(b: Int) | ||
given Transformer[A, B] = _.to[B] | ||
""" | ||
}( | ||
"Detected usage of `_.to[B]`, `_.fallibleTo[B]`, `_.into[B].transform()` or `_.into[B].fallible.transform()` in a given Transformer definition which results in a self-looping Transformer. Please use `Transformer.define[A, B]` or `Transformer.define[A, B].fallible` (for some types A and B) to create Transformer definitions @ B" | ||
) | ||
} | ||
|
||
test("rejects _.into.transform() in given Transformer definitions") { | ||
assertFailsToCompileWith { | ||
""" | ||
case class A(a: Int) | ||
case class B(b: Int) | ||
given Transformer[A, B] = _.into[B].transform() | ||
""" | ||
}( | ||
"Detected usage of `_.to[B]`, `_.fallibleTo[B]`, `_.into[B].transform()` or `_.into[B].fallible.transform()` in a given Transformer definition which results in a self-looping Transformer. Please use `Transformer.define[A, B]` or `Transformer.define[A, B].fallible` (for some types A and B) to create Transformer definitions @ B" | ||
) | ||
} | ||
|
||
test("rejects _.falibleTo in given Trasformer.Fallible definitions") { | ||
assertFailsToCompileWith { | ||
""" | ||
given Mode.FailFast.Option with {} | ||
case class A(a: Int) | ||
case class B(b: Int) | ||
given Transformer.Fallible[Option, A, B] = _.fallibleTo[B] | ||
""" | ||
}( | ||
"Detected usage of `_.to[B]`, `_.fallibleTo[B]`, `_.into[B].transform()` or `_.into[B].fallible.transform()` in a given Transformer definition which results in a self-looping Transformer. Please use `Transformer.define[A, B]` or `Transformer.define[A, B].fallible` (for some types A and B) to create Transformer definitions @ B" | ||
) | ||
} | ||
|
||
test("rejects _.into.falible in given Trasformer.Fallible definitions") { | ||
assertFailsToCompileWith { | ||
""" | ||
given Mode.FailFast.Option with {} | ||
case class A(a: Int) | ||
case class B(b: Int) | ||
given Transformer.Fallible[Option, A, B] = _.into[B].fallible.transform() | ||
""" | ||
}( | ||
"Detected usage of `_.to[B]`, `_.fallibleTo[B]`, `_.into[B].transform()` or `_.into[B].fallible.transform()` in a given Transformer definition which results in a self-looping Transformer. Please use `Transformer.define[A, B]` or `Transformer.define[A, B].fallible` (for some types A and B) to create Transformer definitions @ B" | ||
) | ||
} | ||
} |