making comments nicer
[dygraphs.git] / auto_tests / tests / scientific_notation.js
... / ...
CommitLineData
1/**
2 * @fileoverview Tests input data which uses scientific notation.
3 * This is a regression test for
4 * http://code.google.com/p/dygraphs/issues/detail?id=186
5 *
6 * @author danvk@google.com (Dan Vanderkam)
7 */
8describe("scientific-notation", function() {
9
10beforeEach(function() {
11 document.body.innerHTML = "<div id='graph'></div>";
12});
13
14afterEach(function() {
15});
16
17function getXValues(g) {
18 var xs = [];
19 for (var i = 0; i < g.numRows(); i++) {
20 xs.push(g.getValue(i, 0));
21 }
22 return xs;
23}
24
25it('testScientificInput', function() {
26 var data = "X,Y\n" +
27 "1.0e1,-1\n" +
28 "2.0e1,0\n" +
29 "3.0e1,1\n" +
30 "4.0e1,0\n"
31 ;
32
33 var graph = document.getElementById("graph");
34 var g = new Dygraph(graph, data, {});
35 assertDeepCloseTo([10, 20, 30, 40], getXValues(g), 1e-6);
36});
37
38it('testScientificInputPlus', function() {
39 var data = "X,Y\n" +
40 "1.0e+1,-1\n" +
41 "2.0e+1,0\n" +
42 "3.0e+1,1\n" +
43 "4.0e+1,0\n"
44 ;
45
46 var graph = document.getElementById("graph");
47 var g = new Dygraph(graph, data, {});
48 assertDeepCloseTo([10, 20, 30, 40], getXValues(g), 1e-6);
49});
50
51it('testScientificInputMinus', function() {
52 var data = "X,Y\n" +
53 "1.0e-1,-1\n" +
54 "2.0e-1,0\n" +
55 "3.0e-1,1\n" +
56 "4.0e-1,0\n"
57 ;
58
59 var graph = document.getElementById("graph");
60 var g = new Dygraph(graph, data, {});
61 assertDeepCloseTo([0.1, 0.2, 0.3, 0.4], getXValues(g), 1e-6);
62});
63
64it('testScientificInputMinusCap', function() {
65 var data = "X,Y\n" +
66 "1.0E-1,-1\n" +
67 "2.0E-1,0\n" +
68 "3.0E-1,1\n" +
69 "4.0E-1,0\n"
70 ;
71
72 var graph = document.getElementById("graph");
73 var g = new Dygraph(graph, data, {});
74 assertDeepCloseTo([0.1, 0.2, 0.3, 0.4], getXValues(g), 1e-6);
75});
76
77});