Skip to content

Commit 2b2a5a5

Browse files
committed
add gulpfile and installation instructions
1 parent 9ebee51 commit 2b2a5a5

File tree

6 files changed

+77
-29
lines changed

6 files changed

+77
-29
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,11 @@ by [Peter Olson](https://github.com/peterolson).
77
## Module documentation
88

99
- [Data.BigInt](docs/Data/BigInt.md)
10+
11+
## Installation
12+
13+
```
14+
npm install
15+
bower install
16+
gulp
17+
```

bower.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"**/.*",
1111
"node_modules",
1212
"bower_components",
13-
"output"
13+
"output",
14+
"test",
15+
"gulpfile.js",
16+
"package.json"
1417
],
1518
"dependencies": {
1619
"purescript-maybe": "^0.3.2"

gulpfile.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/* jshint node: true */
2+
3+
"use strict";
4+
5+
var gulp = require("gulp");
6+
var purescript = require("gulp-purescript");
7+
var run = require("gulp-run");
8+
var rimraf = require("rimraf");
9+
10+
var sources = [
11+
"src/**/*.purs",
12+
"test/**/*.purs",
13+
"bower_components/purescript-*/src/**/*.purs"
14+
];
15+
16+
var foreigns = [
17+
"src/**/*.js",
18+
"bower_components/purescript-*/src/**/*.js"
19+
];
20+
21+
gulp.task("clean-docs", function (cb) {
22+
rimraf("docs", cb);
23+
});
24+
25+
gulp.task("clean-output", function (cb) {
26+
rimraf("output", cb);
27+
});
28+
29+
gulp.task("clean", ["clean-docs", "clean-output"]);
30+
31+
gulp.task("make", function() {
32+
return purescript.psc({
33+
src: sources,
34+
ffi: foreigns,
35+
output: "output"
36+
});
37+
});
38+
39+
gulp.task("docs", ["clean-docs"], function () {
40+
return purescript.pscDocs({
41+
src: sources,
42+
docgen: {
43+
"Data.BigInt": "docs/Data/BigInt.md"
44+
}
45+
});
46+
});
47+
48+
gulp.task("test", ["make"], function() {
49+
return purescript.pscBundle({
50+
src: ['output/**/*.js', 'node_modules/big-integert/BigInteger.min.js'],
51+
main: 'Test.Main'
52+
})
53+
.pipe(run("node"));
54+
});
55+
56+
gulp.task("default", ["make", "docs", "test"]);

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
22
"name": "purescript-bigints",
3-
"version": "0.1.0",
43
"dependencies": {
5-
"big-integer": "^1.5.5"
4+
"big-integer": "^1.5.5",
5+
"gulp": "^3.9.0",
6+
"gulp-purescript": "^0.5.0",
7+
"gulp-run": "^1.6.10",
8+
"rimraf": "^2.4.2"
69
}
710
}

runtests.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

test/Main.purs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,17 @@ main = do
6262
testBinary mod mod
6363
testBinary div div
6464

65+
log "It should perform multiplications which would lead to imprecise results using Number"
66+
assert $ Just (fromInt 333190782 * fromInt 1103515245) == fromString "367681107430471590"
67+
6568
-- To check the multiplication, we need to make sure that the Int does not overflow
6669
quickCheck (\x y -> fromSmallInt x * fromSmallInt y == fromInt (runSmallInt x * runSmallInt y))
6770

6871
log "compare and (==) should be the same before and after converting to BigInt"
6972
quickCheck (\x y -> compare x y == compare (fromInt x) (fromInt y))
7073
quickCheck (\x y -> (fromSmallInt x == fromSmallInt y) == (runSmallInt x == runSmallInt y))
7174

72-
log $ "pow should perform integer exponentiation and yield 0 for negative exponents"
75+
log "pow should perform integer exponentiation and yield 0 for negative exponents"
7376
assert $ three `pow` four == fromInt 81
7477
assert $ three `pow` -two == zero
7578
assert $ three `pow` zero == one

0 commit comments

Comments
 (0)