-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtractTypeSignatureTest.hs
20 lines (16 loc) · 1.24 KB
/
ExtractTypeSignatureTest.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import ExtractTypeSignature
import Test.HUnit
import System.IO
import Control.Monad.IO.Class
mockTypesignature = " typesig str8int2str: [String, Numeral => String]" :: String
mockCode = lines "class RubypeTest\ndef str8int2str(a,b)\n'#{a} b'\nend\ntypesig str8int2str: [String, Numeral => String]\ndef marry(people)\n # Your Ruby code as usual\nend\ntypesig marry: [People -> Any]\nend" :: [String]
mockScope = Class "RubypeTest" [Method "str8int2str" "String -> Numeral -> String", Method "marry" "People -> Any"] :: Scope
tests = [
"typeSignatureMatch" ~: typeSignatureMatch typeSignaturePattern1 mockTypesignature ~=? Just "str8int2str: [String, Numeral => String]",
"extractTypeSignature" ~: extractTypeSignature typeSignaturePattern1 mockTypesignature ~=? Just "str8int2str :: String -> Numeral -> String",
"extractTypeSignatures" ~: extractTypeSignatures typeSignaturePattern1 mockCode ~=? ["str8int2str :: String -> Numeral -> String", "marry :: People -> Any"],
"ScopeToDoc" ~: lines (scopeToDoc mockScope) ~=? ["RubypeTest#str8int2str :: String -> Numeral -> String", "RubypeTest#marry :: People -> Any"],
"make Scope from code" ~: walk mockCode ~=? mockScope
]
main = do
runTestTT $ TestList tests