2006-07-03HUnit
■ Hunit実行編
Haskell用のテストフレームワークHUnitを試してみました。
-- ファイル名:calculation.hs module Calculation where add :: Int -> Int -> Int add x y = x + y
-- ファイル名:calculation_test.hs import Test.HUnit import Calculation -- Calculationモジュールのaddメソッドのテスト test1 = TestCase (assertEqual "test for add" 5 (add 2 3)) main = runTestTT test1
calculation.hsはテストされる側のモジュールです。またcalculation_.hsはcalculation.hsをテストする側です。
#テストする側ですと書きましたが、正確にはテストする側のmainモジュールと呼べば良いのでしょうか?
calculation.hsとcalculation_test.hsは同じディレクトリに存在します。
D:\Development\PracticeHaskell\work20060704 のディレクトリ 2006/07/04 02:13 <DIR> . 2006/07/04 02:13 <DIR> .. 2006/07/04 01:01 97 calculation.hs 2006/07/04 02:00 240 calculation_test.hs 2 個のファイル 337 バイト 2 個のディレクトリ 7,662,923,776 バイトの空き領域
テストを実行してみます。
D:\Development\PracticeHaskell\work20060704>runghc calculation_test.hs Cases: 1 Tried: 1 Errors: 0 Failures: 0
テストが成功しました。
次にわざと失敗するテストをひとつ追加してテストを実行してみます。
import Test.HUnit import Calculation test1 = TestCase (assertEqual "test for add" 5 (add 2 3)) --test2は失敗するテスト test2 = TestCase (assertEqual "failed test" 4 (add 2 7)) main = do runTestTT test1 runTestTT test2
テストを実行してみます。
D:\Development\PracticeHaskell\work20060704>runghc calculation_test.hs Cases: 1 Tried: 1 Errors: 0 Failures: 0 ### Error: user error (HUnit:failed test expected: 4 but got: 9) Cases: 1 Tried: 1 Errors: 1 Failures: 0
■ HUnitで苦労した点や、気がついた点をメモ
calculation_test.hsをコンパイルした場合は、Calculationモジュールが見つからないというエラーが表示される。モジュールをパスに追加すればよいのは分かるが、モジュールをパスに追加する方法が分からない。
D:\Development\PracticeHaskell\work20060704>ghc calculation_test.hs -o calculati on_test calculation_test.hs:2:0: Failed to load interface for `Calculation': Could not find module `Calculation': use -v to see a list of the files searched for
モジュール名とファイル名を異なるものにすると、テストが失敗する。
テストを実行 D:\Development\PracticeHaskell\work20060704>runghc calculation_test.hs Cases: 1 Tried: 1 Errors: 0 Failures: 0 Calculationモジュールのファイル名をcalculationからcalcへ変更 D:\Development\PracticeHaskell\work20060704>rename calculation.hs calc.hs テストを実行 D:\Development\PracticeHaskell\work20060704>runghc calculation_test.hs Could not find module `Calculation': use -v to see a list of the files searched for (imported from calculation_test.hs)
モジュール名とファイル名は揃えなくてはいけないのでしょうか?
以下assert文の"test for add"という文字列を削除するとテストが失敗する。この説明文は必要なのだろうか?(無いとテストが失敗するから必要なのでしょう)
assertEqual "test for add" 5 (add 2 3)
モジュールの書き方と、それをインポートする方法や考え方が良くわかっていなかった。
HUnitの情報が少ないのでいろいろと困った
ford air conditioner2007/07/24 21:30<a href="http://www.cwclewmm.cn/page25.html">dallas cowboys superbowl xxx pictures</a> dallas cowboys superbowl xxx pictures,<a href="http://www.cwclewmm.cn/page10.html">espn nba power ranking</a> espn nba power ranking,<a href="http://www.cwclewmm.cn/page13.html">how to get gmail</a> how to get gmail,<a href="http://www.cwclewmm.cn/page17.html">discount handcuff warehouse</a> discount handcuff warehouse,<a href="http://www.cwclewmm.cn/page29.html">housewife porno</a> housewife porno,<a href="http://www.cwclewmm.cn/page27.html">find out the sex of your baby</a> find out the sex of your baby,<a href="http://www.cwclewmm.cn/page19.html">free good spyware removal software</a> free good spyware removal software,<a href="http://www.cwclewmm.cn/page32.html">halloween board game</a> halloween board game,<a href="http://www.cwclewmm.cn/page12.html">enterprise car rental san francisco</a> enterprise car rental san francisco,<a href="http://www.cwclewmm.cn/page4.html">fox live radio for nascar</a> fox live radio for nascar,
customized golf gift2007/07/25 00:30<a href="http://www.yhobqwny.cn/page76.html">background themes</a> background themes,<a href="http://www.yhobqwny.cn/page98.html">anime dvd club anime dvd club</a> anime dvd club anime dvd club,<a href="http://www.yhobqwny.cn/page74.html">gold coast rental cars</a> gold coast rental cars,<a href="http://www.yhobqwny.cn/page84.html">download free porn psp</a> download free porn psp,<a href="http://www.yhobqwny.cn/page93.html">google satellite pic</a> google satellite pic,<a href="http://www.yhobqwny.cn/page74.html">kelly blue book classic cars</a> kelly blue book classic cars,<a href="http://www.yhobqwny.cn/page91.html">ikea coat rack</a> ikea coat rack,<a href="http://www.yhobqwny.cn/page74.html">abandoned old cars</a> abandoned old cars,<a href="http://www.yhobqwny.cn/page87.html">free profit loss statement</a> free profit loss statement,<a href="http://www.yhobqwny.cn/page85.html">interior residential wood doors lowes</a> interior residential wood doors lowes,
andy roddick penis2007/07/25 08:31<a href="http://www.jftbepvk.cn/page13.html">english on line dictionary</a> english on line dictionary,<a href="http://www.jftbepvk.cn/page37.html">4x4 tv show jeep lift kit install</a> 4x4 tv show jeep lift kit install,<a href="http://www.jftbepvk.cn/page48.html">google globe</a> google globe,<a href="http://www.jftbepvk.cn/page22.html">fuck old old women</a> fuck old old women,<a href="http://www.jftbepvk.cn/page14.html">chess master free download</a> chess master free download,<a href="http://www.jftbepvk.cn/page40.html">dvd benchmark</a> dvd benchmark,<a href="http://www.jftbepvk.cn/page21.html">gmail invitation codes</a> gmail invitation codes,<a href="http://www.jftbepvk.cn/page23.html">heard about microfiber cleaning cloths at walmart</a> heard about microfiber cleaning cloths at walmart,<a href="http://www.jftbepvk.cn/page24.html">college xxx parties</a> college xxx parties,<a href="http://www.jftbepvk.cn/page2.html">free ringtones 4 samsung</a> free ringtones 4 samsung,
erotic non nude2007/07/25 20:28<a href="http://www.zzlxhsuh.cn/page71.html">frederick toyota</a> frederick toyota,<a href="http://www.zzlxhsuh.cn/page94.html">astrology free horoscope matches</a> astrology free horoscope matches,<a href="http://www.zzlxhsuh.cn/page70.html">display picture for msn messenger</a> display picture for msn messenger,<a href="http://www.zzlxhsuh.cn/page82.html">fairfield hotels city california www online maps search home</a> fairfield hotels city california www online maps search home,<a href="http://www.zzlxhsuh.cn/page69.html">commercial finance loan uk</a> commercial finance loan uk,<a href="http://www.zzlxhsuh.cn/page91.html">hot acetic acid corrosion chart</a> hot acetic acid corrosion chart,<a href="http://www.zzlxhsuh.cn/page73.html">arizona pink jeep tours</a> arizona pink jeep tours,<a href="http://www.zzlxhsuh.cn/page83.html">free patterns for pinewood derby car</a> free patterns for pinewood derby car,<a href="http://www.zzlxhsuh.cn/page79.html">antique owl on books medal</a> antique owl on books medal,<a href="http://www.zzlxhsuh.cn/page99.html">kgw news</a> kgw news,
fucking porn star2007/07/26 06:18<a href="http://www.evazoimy.cn/page64.html">emo pics</a> emo pics,<a href="http://www.evazoimy.cn/page71.html">canada immigration site</a> canada immigration site,<a href="http://www.evazoimy.cn/page68.html">calli cox videos</a> calli cox videos,<a href="http://www.evazoimy.cn/page62.html">incoming mail server for gmail</a> incoming mail server for gmail,<a href="http://www.evazoimy.cn/page88.html">jamie cullum everlasting love</a> jamie cullum everlasting love,<a href="http://www.evazoimy.cn/page91.html">free mp3 songs ringtones</a> free mp3 songs ringtones,<a href="http://www.evazoimy.cn/page78.html">koi kaze wallpapers</a> koi kaze wallpapers,<a href="http://www.evazoimy.cn/page61.html">kungfu bikini</a> kungfu bikini,<a href="http://www.evazoimy.cn/page50.html">fucking fat bitch</a> fucking fat bitch,<a href="http://www.evazoimy.cn/page66.html">bikini beach orient bay menu</a> bikini beach orient bay menu,
free money runescape2007/07/26 09:19<a href="http://www.vllaxicr.cn/page72.html">fleischer superman cartoons</a> fleischer superman cartoons,<a href="http://www.vllaxicr.cn/page52.html">heater hot oil tankless water</a> heater hot oil tankless water,<a href="http://www.vllaxicr.cn/page61.html">hardcore orgies</a> hardcore orgies,<a href="http://www.vllaxicr.cn/page71.html">hotmail login failed</a> hotmail login failed,<a href="http://www.vllaxicr.cn/page56.html">emo love song lyric</a> emo love song lyric,<a href="http://www.vllaxicr.cn/page70.html">ferrari 4000</a> ferrari 4000,<a href="http://www.vllaxicr.cn/page87.html">florida employment commision</a> florida employment commision,<a href="http://www.vllaxicr.cn/page83.html">geomorphology dictionary</a> geomorphology dictionary,<a href="http://www.vllaxicr.cn/page63.html">free massage</a> free massage,<a href="http://www.vllaxicr.cn/page95.html">aerial view property</a> aerial view property,
free limewire trial2007/07/26 17:57<a href="http://www.jphybrci.cn/page13.html">google limewire</a> google limewire,<a href="http://www.jphybrci.cn/page4.html">gay arab sex</a> gay arab sex,<a href="http://www.jphybrci.cn/page46.html">christmas guild layout</a> christmas guild layout,<a href="http://www.jphybrci.cn/page19.html">check spam black list</a> check spam black list,<a href="http://www.jphybrci.cn/page44.html">bar tavern furniture</a> bar tavern furniture,<a href="http://www.jphybrci.cn/page37.html">batman dvd box set</a> batman dvd box set,<a href="http://www.jphybrci.cn/page41.html">exhaust manifold 97 jeep cherokee</a> exhaust manifold 97 jeep cherokee,<a href="http://www.jphybrci.cn/page23.html">braless boobs</a> braless boobs,<a href="http://www.jphybrci.cn/page5.html">iomega zip 250 drivers</a> iomega zip 250 drivers,<a href="http://www.jphybrci.cn/page37.html">batman birthday cakes</a> batman birthday cakes,
deep blowjobs2007/07/27 07:02<a href="http://www.zenfuiqi.cn/page57.html">billboards mobile advertisment trailer miami</a> billboards mobile advertisment trailer miami,<a href="http://www.zenfuiqi.cn/page80.html">appz limewire pro</a> appz limewire pro,<a href="http://www.zenfuiqi.cn/page51.html">christmas angel tree topper</a> christmas angel tree topper,<a href="http://www.zenfuiqi.cn/page65.html">cap juluca hotel</a> cap juluca hotel,<a href="http://www.zenfuiqi.cn/page74.html">2pac feat notorious big</a> 2pac feat notorious big,<a href="http://www.zenfuiqi.cn/page83.html">free discount hotel rooms in las vegas</a> free discount hotel rooms in las vegas,<a href="http://www.zenfuiqi.cn/page70.html">keyword advertising</a> keyword advertising,<a href="http://www.zenfuiqi.cn/page73.html">heck yes</a> heck yes,<a href="http://www.zenfuiqi.cn/page60.html">dvb warehouse</a> dvb warehouse,<a href="http://www.zenfuiqi.cn/page76.html">boy game gold pokemon through walk</a> boy game gold pokemon through walk,
free jetsons porn2007/07/27 09:21<a href="http://www.qzyxqnwt.cn/page92.html">fergie wet her pants</a> fergie wet her pants,<a href="http://www.qzyxqnwt.cn/page68.html">engine meta search software tag</a> engine meta search software tag,<a href="http://www.qzyxqnwt.cn/page56.html">free online naruto games</a> free online naruto games,<a href="http://www.qzyxqnwt.cn/page83.html">benz dealer las mercedes vegas</a> benz dealer las mercedes vegas,<a href="http://www.qzyxqnwt.cn/page62.html">de la salle football</a> de la salle football,<a href="http://www.qzyxqnwt.cn/page61.html">how to shave your vagina</a> how to shave your vagina,<a href="http://www.qzyxqnwt.cn/page50.html">golf cars parts</a> golf cars parts,<a href="http://www.qzyxqnwt.cn/page86.html">jackson perkins flowers</a> jackson perkins flowers,<a href="http://www.qzyxqnwt.cn/page80.html">brad pitt tattoo</a> brad pitt tattoo,<a href="http://www.qzyxqnwt.cn/page85.html">charleston city market</a> charleston city market,
chilesexo2007/08/01 07:56<a href="httpwwwlefnytjucnpage50html">stceciliaschurchny</a> stceciliaschurchny,<a href="httpwwwlefnytjucnpage54html">cecilde</a> cecilde,<a href="httpwwwlefnytjucnpage46html">avginternetsecruity</a> avginternetsecruity,<a href="httpwwwlefnytjucnpage67html">secondecumenicalcouncil</a> secondecumenicalcouncil,<a href="httpwwwlefnytjucnpage45html">massagemadisonwisconsinwaterbrava</a> massagemadisonwisconsinwaterbrava,<a href="httpwwwlefnytjucnpage68html">saturnusedcarmanchester</a> saturnusedcarmanchester,<a href="httpwwwlefnytjucnpage69html">susanklineartist</a> susanklineartist,<a href="httpwwwlefnytjucnpage58html">thefatsandoilsinpizza</a> thefatsandoilsinpizza,<a href="httpwwwlefnytjucnpage45html">lindabravalampenius</a> lindabravalampenius,<a href="httpwwwlefnytjucnpage68html">saturnperformancecams</a> saturnperformancecams,
boatsdeck2007/08/01 18:53<a href="httpwwwffyrwvdzcnpage49html">replacementpartsforgasgrillssoldbythebayincanada</a> replacementpartsforgasgrillssoldbythebayincanada,<a href="httpwwwffyrwvdzcnpage52html">drivinglicensesuspendednc</a> drivinglicensesuspendednc,<a href="httpwwwffyrwvdzcnpage56html">verdongorgefrance</a> verdongorgefrance,<a href="httpwwwffyrwvdzcnpage59html">boatsdeck</a> boatsdeck,<a href="httpwwwffyrwvdzcnpage42html">lolitasquirting</a> lolitasquirting,<a href="httpwwwffyrwvdzcnpage53html">braunsilkepilsoftperfection</a> braunsilkepilsoftperfection,<a href="httpwwwffyrwvdzcnpage42html">lolitanude</a> lolitanude,<a href="httpwwwffyrwvdzcnpage55html">redpoissonredfishjeuxfreedownload</a> redpoissonredfishjeuxfreedownload,<a href="httpwwwffyrwvdzcnpage66html">prettybusinesscardsforwomen</a> prettybusinesscardsforwomen,<a href="httpwwwffyrwvdzcnpage66html">callingcardshungary</a> callingcardshungary,