Skip to content
Snippets Groups Projects
Commit f24a06db authored by Manos Koukoutos's avatar Manos Koukoutos
Browse files

Fix directlyNestedFunDefs, plus test

parent 7645771e
No related branches found
No related tags found
No related merge requests found
......@@ -344,8 +344,8 @@ object ExprOps {
/** Returns functions in directly nested LetDefs */
def directlyNestedFunDefs(e: Expr): Set[FunDef] = {
foldRight[Set[FunDef]]{
case (LetDef(fd,bd), _) => Set(fd)
foldRight[Set[FunDef]]{
case (LetDef(fd,_), Seq(fromFd, fromBd)) => fromBd + fd
case (_, subs) => subs.flatten.toSet
}(e)
}
......@@ -2095,50 +2095,3 @@ object ExprOps {
}
......@@ -26,7 +26,18 @@ class ExprOpsSuite extends LeonTestSuiteWithProgram with helpers.ExpressionsDSL
| def aMatch(a: Foo) = a match {
| case b1 @ Bar4(b2: Bar3) => b2
| }
|}""".stripMargin
|}""".stripMargin,
"""object Nested {
| def foo = {
| def bar = {
| def baz = 42
| baz
| }
| def zoo = 42
| }
|}
|
""".stripMargin
)
test("mapForPattern introduces casts"){ implicit fix =>
......@@ -80,4 +91,11 @@ class ExprOpsSuite extends LeonTestSuiteWithProgram with helpers.ExpressionsDSL
assert(asInstOf(expr, cct) === AsInstanceOf(expr, cct))
}
test("directlyNestedFunDefs") { implicit fix =>
val foo = funDef("Nested.foo")
val nested = directlyNestedFunDefs(foo.fullBody)
nested.exists { _.id.name == "bar"} &&
nested.exists { _.id.name == "zoo"}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment