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.5 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.4 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.3 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.2 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.1 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.1.0 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.0.6 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.0.5 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.0.4 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.0.3 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.0.2 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.0.1 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.2.0.0 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.1.0.55 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.1.0.54 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.1.0.53 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.1.0.52 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.1.0.51 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.1.0.50 tracks/haskell/exercises/rna-transcription/test/Tests.hs
trackler-2.1.0.49 tracks/haskell/exercises/rna-transcription/test/Tests.hs