Sha256: c1a5ed9135f9b31f541c106189557b051a84c573ae1f1d237478a47fe9267ce7

Contents?: true

Size: 1.91 KB

Versions: 96

Compression:

Stored size: 1.91 KB

Contents

{-# LANGUAGE RecordWildCards #-}

import Data.Foldable     (for_)
import Test.Hspec        (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)

import DNA (toRNA)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs

specs :: Spec
specs = describe "toRNA" $ for_ cases test
  where
    test Case{..} = it description $ toRNA dna `shouldBe` expected

data Case = Case { description ::       String
                 , dna         ::       String
                 , expected    :: Maybe String
                 }

cases :: [Case]
cases = [ Case { description = "rna complement of cytosine is guanine"
               , dna         =      "C"
               , expected    = Just "G"
               }
        , Case { description = "rna complement of guanine is cytosine"
               , dna         =      "G"
               , expected    = Just "C"
               }
        , Case { description = "rna complement of thymine is adenine"
               , dna         =      "T"
               , expected    = Just "A"
               }
        , Case { description = "rna complement of adenine is uracil"
               , dna         =      "A"
               , expected    = Just "U"
               }
        , Case { description = "rna complement"
               , dna         =      "ACGTGGTCTTAA"
               , expected    = Just "UGCACCAGAAUU"
               }
        , Case { description = "dna correctly handles invalid input"
               , dna         = "U"
               , expected    = Nothing
               }
        , Case { description = "dna correctly handles completely invalid input"
               , dna         = "XXX"
               , expected    = Nothing
               }
        , Case { description = "dna correctly handles partially invalid input"
               , dna         = "ACGTXXXCTTAA"
               , expected    = Nothing
               }
        ]

Version data entries

96 entries across 96 versions & 1 rubygems

Version Path
trackler-2.2.1.25 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.24 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.23 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.22 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.21 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.20 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.19 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.18 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.17 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.16 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.15 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.14 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.13 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.12 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.11 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.10 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.9 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.8 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.7 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.6 tracks/haskell/exercises/rna-transcription/test/Tests.hs