forked from d3/d3-format
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformat-type-e-test.js
28 lines (25 loc) · 935 Bytes
/
format-type-e-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var tape = require("tape"),
format = require("../");
tape("format(\"e\") can output exponent notation", function(test) {
var f = format.format("e");
test.equal(f(0), "0.000000e+0");
test.equal(f(42), "4.200000e+1");
test.equal(f(42000000), "4.200000e+7");
test.equal(f(420000000), "4.200000e+8");
test.equal(f(-4), "-4.000000e+0");
test.equal(f(-42), "-4.200000e+1");
test.equal(f(-4200000), "-4.200000e+6");
test.equal(f(-42000000), "-4.200000e+7");
test.equal(format.format(".0e")(42), "4e+1")
test.equal(format.format(".3e")(42), "4.200e+1")
test.end();
});
tape("format(\"e\") can format negative zero as zero", function(test) {
test.equal(format.format("1e")(-0), "0.000000e+0");
test.equal(format.format("1e")(-1e-12), "-1.000000e-12");
test.end();
});
tape("format(\",e\") does not group Infinity", function(test) {
test.equal(format.format(",e")(Infinity), "Infinity");
test.end();
});