consolidating scripts
[dygraphs.git] / auto_tests / tests / scientific_notation.js
CommitLineData
0842b24b
DV
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 */
0842b24b 8
e8c70e4e
DV
9import Dygraph from '../../src/dygraph';
10import {assertDeepCloseTo} from './custom_asserts';
11
12describe("scientific-notation", function() {
0842b24b 13
e8c70e4e 14cleanupAfterEach();
0842b24b
DV
15
16function getXValues(g) {
17 var xs = [];
18 for (var i = 0; i < g.numRows(); i++) {
19 xs.push(g.getValue(i, 0));
20 }
21 return xs;
22}
23
89fdcedb 24it('testScientificInput', function() {
0842b24b
DV
25 var data = "X,Y\n" +
26 "1.0e1,-1\n" +
27 "2.0e1,0\n" +
28 "3.0e1,1\n" +
29 "4.0e1,0\n"
30 ;
31
32 var graph = document.getElementById("graph");
33 var g = new Dygraph(graph, data, {});
dc910fce 34 assertDeepCloseTo([10, 20, 30, 40], getXValues(g), 1e-6);
89fdcedb 35});
0842b24b 36
89fdcedb 37it('testScientificInputPlus', function() {
0842b24b
DV
38 var data = "X,Y\n" +
39 "1.0e+1,-1\n" +
40 "2.0e+1,0\n" +
41 "3.0e+1,1\n" +
42 "4.0e+1,0\n"
43 ;
44
45 var graph = document.getElementById("graph");
46 var g = new Dygraph(graph, data, {});
dc910fce 47 assertDeepCloseTo([10, 20, 30, 40], getXValues(g), 1e-6);
89fdcedb 48});
0842b24b 49
89fdcedb 50it('testScientificInputMinus', function() {
0842b24b
DV
51 var data = "X,Y\n" +
52 "1.0e-1,-1\n" +
53 "2.0e-1,0\n" +
54 "3.0e-1,1\n" +
55 "4.0e-1,0\n"
56 ;
57
58 var graph = document.getElementById("graph");
59 var g = new Dygraph(graph, data, {});
dc910fce 60 assertDeepCloseTo([0.1, 0.2, 0.3, 0.4], getXValues(g), 1e-6);
89fdcedb 61});
0842b24b 62
89fdcedb 63it('testScientificInputMinusCap', function() {
0842b24b
DV
64 var data = "X,Y\n" +
65 "1.0E-1,-1\n" +
66 "2.0E-1,0\n" +
67 "3.0E-1,1\n" +
68 "4.0E-1,0\n"
69 ;
70
71 var graph = document.getElementById("graph");
72 var g = new Dygraph(graph, data, {});
dc910fce 73 assertDeepCloseTo([0.1, 0.2, 0.3, 0.4], getXValues(g), 1e-6);
89fdcedb
DV
74});
75
76});