提交 ee76025c authored 作者: Frederic's avatar Frederic

Added fct to test compiled function.

上级 c8615bdc
...@@ -93,7 +93,8 @@ class TestOptimizationMixin(object): ...@@ -93,7 +93,8 @@ class TestOptimizationMixin(object):
def assertFunctionContains(self, f, op, min=1, max=sys.maxint): def assertFunctionContains(self, f, op, min=1, max=sys.maxint):
toposort = f.maker.env.toposort() toposort = f.maker.env.toposort()
matches = [node for node in toposort if node.op == op] matches = [node for node in toposort if node.op == op]
assert (min <= len(matches) <= max), (toposort, matches, str(op), min, max) assert (min <= len(matches) <= max), (toposort, matches,
str(op), len(matches), min, max)
def assertFunctionContains0(self, f, op): def assertFunctionContains0(self, f, op):
return self.assertFunctionContains(f, op, min=0, max=0) return self.assertFunctionContains(f, op, min=0, max=0)
...@@ -104,6 +105,15 @@ class TestOptimizationMixin(object): ...@@ -104,6 +105,15 @@ class TestOptimizationMixin(object):
def assertFunctionContainsN(self, f, op, N): def assertFunctionContainsN(self, f, op, N):
return self.assertFunctionContains(f, op, min=N, max=N) return self.assertFunctionContains(f, op, min=N, max=N)
def assertFunctionContainsClass(self, f, op, min=1, max=sys.maxint):
toposort = f.maker.env.toposort()
matches = [node for node in toposort if isinstance(node.op, op)]
assert (min <= len(matches) <= max), (toposort, matches,
str(op), len(matches), min, max)
def assertFunctionContainsClassN(self, f, op, N):
return self.assertFunctionContainsClass(f, op, min=N, max=N)
def SkipTest(self, msg='Skip this test'): def SkipTest(self, msg='Skip this test'):
raise SkipTest(msg) raise SkipTest(msg)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论