Skip to content

Commit

Permalink
Sumas de dos abundantes
Browse files Browse the repository at this point in the history
  • Loading branch information
jaalonso committed Sep 10, 2024
1 parent 12edd34 commit e112174
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
21 changes: 21 additions & 0 deletions src/Sumas_de_dos_abundantes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module Sumas_de_dos_abundantes where

import Data.List (genericLength, group)
import Data.Numbers.Primes (primeFactors)
import Test.Hspec (Spec, describe, hspec, it, shouldBe)
import Test.QuickCheck

-- 1ª solución
Expand Down Expand Up @@ -89,6 +90,26 @@ primeroYlongitud :: [a] -> (a,Integer)
primeroYlongitud (x:xs) =
(x, 1 + genericLength xs)

-- Verificación
-- ============

verifica :: IO ()
verifica = hspec spec

specG :: [Integer] -> Spec
specG sumasDeDosAbundantes = do
it "e1" $
take 10 sumasDeDosAbundantes `shouldBe` [24,30,32,36,38,40,42,44,48,50]

spec :: Spec
spec = do
describe "def. 1" $ specG sumasDeDosAbundantes1
describe "def. 2" $ specG sumasDeDosAbundantes2

-- La verificación es
-- λ> verifica
-- 2 examples, 0 failures

-- Comprobación de equivalencia
-- ============================

Expand Down
16 changes: 2 additions & 14 deletions test/Sumas_de_dos_abundantes_Spec.hs
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
module Sumas_de_dos_abundantes_Spec (main, spec) where

import Sumas_de_dos_abundantes
import Test.Hspec
import Test.QuickCheck
import Sumas_de_dos_abundantes (spec)
import Test.Hspec (hspec)

main :: IO ()
main = hspec spec

specG :: [Integer] -> Spec
specG sumasDeDosAbundantes = do
it "e1" $
take 10 sumasDeDosAbundantes `shouldBe` [24,30,32,36,38,40,42,44,48,50]

spec :: Spec
spec = do
describe "def. 1" $ specG sumasDeDosAbundantes1
describe "def. 2" $ specG sumasDeDosAbundantes2
describe "equivalencia" $ it "p1" $ property prop_sumasDeDosAbundantes

0 comments on commit e112174

Please sign in to comment.