Sha256: 550e18274a668bfe511a169a7f15b8077b86189e05bbcfcd2269dce03c8dfc90

Contents?: true

Size: 1.29 KB

Versions: 9

Compression:

Stored size: 1.29 KB

Contents

/**
 * Module dependencies.
 */

var should = require('../');

function test(name, fn){
  try {
    fn();
  } catch (err) {
    console.log('    \x1b[31m%s', name);
    console.log('    %s\x1b[0m', err.stack);
    return;
  }
  console.log('  √ \x1b[32m%s\x1b[0m', name);
}

function Point(x, y) {
  this.x = x;
  this.y = y;
  this.sub = function(other){
    return new Point(
        this.x - other.x
      , this.y - other.y);
  }
}

console.log();

test('new Point(x, y)', function(){
  var point = new Point(50, 100);
  point.should.be.an.instanceof(Point);
  point.should.have.property('x', 50);
  point.should.have.property('y', 100);
});

test('Point#sub()', function(){
  var a = new Point(50, 100)
    , b = new Point(20, 50);
  a.sub(b).should.be.an.instanceof(Point);
  a.sub(b).should.not.equal(a);
  a.sub(b).should.not.equal(b);
  a.sub(b).should.have.property('x', 30);
  a.sub(b).should.have.property('y', 50);
});

test('Point#add()', function(){
  var point = new Point(50, 100);
  point.should.respondTo('add');
});

test('Math#sin()', function(){
  Math.sin(12).should.be.approximately(-0.5365, 1e-3);
});

test('Math#cos()', function(){
  Math.cos(0).should.not.be.approximately(10, 1e-3);
});

test('Math#log()', function(){
  Math.log(10).should.be.approximately(10, 1e-3);
});

console.log();

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
stylus-source-0.34.1 vendor/node_modules/should/examples/runner.js
stylus-source-0.34.0 vendor/node_modules/should/examples/runner.js
stylus-source-0.33.1 vendor/node_modules/should/examples/runner.js
stylus-source-0.33.0 vendor/node_modules/should/examples/runner.js
stylus-source-0.32.1 vendor/node_modules/should/examples/runner.js
stylus-source-0.32.0 vendor/node_modules/should/examples/runner.js
stylus-source-0.31.0 vendor/node_modules/should/examples/runner.js
stylus-source-0.30.1 vendor/node_modules/should/examples/runner.js
stylus-source-0.30.0 vendor/node_modules/should/examples/runner.js