Sha256: a68be35ac7ce247fb6f4f85c774154f966b304493dbc381c4546eb56b4b7ce91
Contents?: true
Size: 704 Bytes
Versions: 2
Compression:
Stored size: 704 Bytes
Contents
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe LinearFunction do describe '.from_points' do it 'should return a Proc with arity of 1' do LinearFunction.from_points([0,0],[1,1]).arity.should eq(1) LinearFunction.from_points([1,2],[2,3]).arity.should eq(1) end context 'given points [0,1.1] and [2,1.2]' do it 'should produce a function that follows the equation y = 0.05x + 1.1' do f = LinearFunction.from_points [0,1.1], [2,1.2] f.call(0).should eq(1.1) f.call(0.5).should eq(1.125) f.call(1).should eq(1.15) f.call(1.5).should eq(1.175) f.call(2).should eq(1.2) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
variation-0.2.1 | spec/functions/linear_function_spec.rb |
variation-0.2.0 | spec/functions/linear_function_spec.rb |