time-to-botec

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

product-test.js (1312B)


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