Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Shon Feder <shon@informal.systems>
  • Loading branch information
thpani and Shon Feder authored May 20, 2022
1 parent 90c20d3 commit 851eebe
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,12 @@ trait CrossTestEncodings extends AnyFunSuite with Checkers {
private def shrinkType(tp: TlaType1): Stream[TlaType1] = tp match {
case IntT1() | RealT1() | BoolT1() | StrT1() => Stream.empty
case FunT1(arg, res) => Stream(arg, res)
case SetT1(elem) => Stream(elem)
case SeqT1(elem) => Stream(elem)
case SetT1(elem) | SeqT1(elem) => Stream(elem)
case TupT1(elems @ _*) =>
Stream.concat(
// shrink to one of the element types
Stream(elems: _*),
// recursively shrink one tuple element type
// tuples with a single element type shrunk, keeping the other types as-is
elems.zipWithIndex.foldLeft(Stream.empty[TlaType1]) { case (acc, (tp, idx)) =>
acc ++ shrink(tp).map(shrunkType => TupT1(elems.updated(idx, shrunkType): _*))
},
Expand All @@ -366,7 +365,7 @@ trait CrossTestEncodings extends AnyFunSuite with Checkers {
fieldTypes.foldLeft(Stream.empty[TlaType1]) { case (acc, (fieldName, tp)) =>
acc ++ shrink(tp).map(shrunkType => RecT1(fieldTypes.updated(fieldName, shrunkType)))
},
// tuples over a subset of the current field types
// records with a subset of the current field types
Stream(shrink(fieldTypes).filterNot(_.isEmpty).map(elems => RecT1(elems)): _*),
)
case ConstT1(_) | OperT1(_, _) | RealT1() | RecRowT1(_) | RowT1(_, _) | SparseTupT1(_) | VarT1(_) | VariantT1(_) =>
Expand Down

0 comments on commit 851eebe

Please sign in to comment.