Added a test for bignums
commit68d844cdf80baf7893b27075457741955e19f5fc
authorNiklas Larsson <niklas@mm.st>
dateFri 10 Apr 2015, 09:49 (12 years ago)
parentbedca84
idris.cabal+4
@@ -346,6 +346,10 @@ Extra-source-files:
346346 test/basic013/*.idr
347347 test/basic013/expected
348348
349+ test/bignum001/run
350+ test/bignum001/*.idr
351+ test/bignum001/expected
352+
349353 test/delab001/*.idr
350354 test/delab001/run
351355 test/delab001/expected
test/README+1
@@ -1,6 +1,7 @@
11Tests are categorised as follows:
22
33basic: Basic language features, some complete programs
4+bignum: Bignums and GMP
45dsl: Embedded DSLs and features to support DSL development
56effects: Effects package
67error: Error messages and error reflection
test/bignum001/bignum001.idrnew file+17
@@ -0,0 +1,17 @@
1+module Main
2+
3+fac : Integer -> Integer
4+fac 0 = 1
5+fac n = n*fac(n-1)
6+
7+binomial : Integer -> Integer -> Integer
8+binomial n k = divBigInt (fac n) ((fac k)*(fac (n-k)))
9+
10+sumBinomials : Integer -> Integer
11+sumBinomials n = foldr (+) 0 (map (\k=>binomial n k) [0..n])
12+
13+main : IO ()
14+main = do
15+ if sumBinomials 1000 - pow 2 1000 == 0
16+ then putStrLn "OK"
17+ else putStrLn "ERROR"
test/bignum001/expectednew file+1
test/bignum001/runnew file+4
@@ -0,0 +1,4 @@
1+#!/usr/bin/env bash
2+idris $@ bignum001.idr -o bignum001
3+./bignum001
4+rm -f bignum001 *.ibc