~ubuntu-branches/ubuntu/precise/whoopsie-daisy/precise-proposed

« back to all changes in this revision

Viewing changes to backend/stats/static/js/d3/test/core/min-test.js

  • Committer: Package Import Robot
  • Author(s): Evan Dandrea
  • Date: 2012-04-10 14:28:58 UTC
  • Revision ID: package-import@ubuntu.com-20120410142858-nk453o1z7t7py3bs
Tags: 0.1.26
* Take ownership of the NetworkManager state variant on setup and
  unref it, plugging a memory leak.
* Log the reason the server rejected the submitted crash report.
* Send the Whoopsie version with each crash submission.
* Delete both .upload and .uploaded files after 14 days. Thanks
  Marc Deslauriers (LP: #973687).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require("../env");
 
2
 
 
3
var vows = require("vows"),
 
4
    assert = require("assert");
 
5
 
 
6
var suite = vows.describe("d3.min");
 
7
 
 
8
suite.addBatch({
 
9
  "min": {
 
10
    topic: function() {
 
11
      return d3.min;
 
12
    },
 
13
    "returns the least numeric value for numbers": function(min) {
 
14
      assert.equal(min([1]), 1);
 
15
      assert.equal(min([5, 1, 2, 3, 4]), 1);
 
16
      assert.equal(min([20, 3]), 3);
 
17
      assert.equal(min([3, 20]), 3);
 
18
    },
 
19
    "returns the least lexicographic value for strings": function(min) {
 
20
      assert.equal(min(["c", "a", "b"]), "a");
 
21
      assert.equal(min(["20", "3"]), "20");
 
22
      assert.equal(min(["3", "20"]), "20");
 
23
    },
 
24
    "ignores null, undefined and NaN": function(min) {
 
25
      assert.equal(min([NaN, 1, 2, 3, 4, 5]), 1);
 
26
      assert.equal(min([1, 2, 3, 4, 5, NaN]), 1);
 
27
      assert.equal(min([10, null, 3, undefined, 5, NaN]), 3);
 
28
    },
 
29
    "compares heterogenous types as numbers": function(min) {
 
30
      assert.strictEqual(min([20, "3"]), "3");
 
31
      assert.strictEqual(min(["20", 3]), 3);
 
32
      assert.strictEqual(min([3, "20"]), 3);
 
33
      assert.strictEqual(min(["3", 20]), "3");
 
34
    },
 
35
    "returns undefined for empty array": function(min) {
 
36
      assert.isUndefined(min([]));
 
37
      assert.isUndefined(min([null]));
 
38
      assert.isUndefined(min([undefined]));
 
39
      assert.isUndefined(min([NaN]));
 
40
      assert.isUndefined(min([NaN, NaN]));
 
41
    },
 
42
    "applies the optional accessor function": function(min) {
 
43
      assert.equal(d3.min([[1, 2, 3, 4, 5], [2, 4, 6, 8, 10]], function(d) { return d3.max(d); }), 5);
 
44
      assert.equal(d3.min([1, 2, 3, 4, 5], function(d, i) { return i; }), 0);
 
45
    }
 
46
  }
 
47
});
 
48
 
 
49
suite.export(module);