私はmethod1
,method2
,method3
のような機能を持っています。それらのすべてのために、testMethod1
,testMethod2
,testMethod3
のようなHUnit
のテスト機能があります。内部に関数名を取得
testMethod1 = TestCase $
assertEqual "testmethod1" ...
testMethod2 = TestCase $
assertEqual "testmethod2" ...
testMethod3 = TestCase $
assertEqual "testmethod3" ...
:それは(任意の「魔法」のトリックが評価されて達成することができますどのように
testMethod1 = TestCase $
assertEqual_ ...
)?
実際に質問すると、関数名をその定義の中でどのように使うことができるのでしょうか?
更新。
それは私があまりにも事態のタイプを処理したいことを、実際には元の質問から明らかではありません。
tProcess = TestCase $ do
assertEqual "tProcess" testResult $ someTest
assertEqual "tProcess" anotherTestResult $ anotherTest
assertEqual "tProcess" resultAgain $ testAgain
は最後に、私はそのような何かを書きたい:
tProcess = TestCase $ do
assertEqual_ testResult $ someTest
assertEqual_ anotherTestResult $ anotherTest
assertEqual_ resultAgain $ testAgain
テンプレートhaskell – pat
私の以前の質問は役に立ちます:http://stackoverflow.com/questions/7896928/how-to-get-variable-name-in-haskell –