time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

max-test.js (1234B)


      1 var vows = require('vows');
      2 var assert = require('assert');
      3 var suite = vows.describe('jStat.max');
      4 
      5 require('../env.js');
      6 
      7 suite.addBatch({
      8   'max': {
      9     'topic': function() {
     10       return jStat;
     11     },
     12     'return basic max': function(jStat) {
     13       assert.equal(jStat.max([1, 2, 3]), 3);
     14     },
     15     'max from instance': function(jStat) {
     16       assert.equal(jStat([1, 2, 3]).max(), 3);
     17     },
     18     'max matrix cols': function(jStat) {
     19       assert.deepEqual(jStat([[1, 2], [3, 4]]).max(), [3, 4]);
     20     },
     21     'max full matrix': function(jStat) {
     22       assert.equal(jStat([[1, 2], [3, 4]]).max(true), 4);
     23     }
     24   },
     25   '#max vector': {
     26     'topic': function() {
     27       jStat([1, 2, 3]).max(this.callback);
     28     },
     29     'max callback': function(val, stat) {
     30       assert.equal(val, 3);
     31     }
     32   },
     33   '#max matrix cols': {
     34     'topic': function() {
     35       jStat([[1, 2], [3, 4]]).max(this.callback);
     36     },
     37     'max matrix cols callback': function(val, stat) {
     38       assert.deepEqual(val, [3, 4]);
     39     }
     40   },
     41   '#max full matrix': {
     42     'topic': function() {
     43       jStat([[1, 2], [3, 4]]).max(true, this.callback);
     44     },
     45     'max full matrix callback': function(val, stat) {
     46       assert.equal(val, 4);
     47     }
     48   }
     49 });
     50 
     51 suite.export(module);