viiite 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/CHANGELOG.md +70 -0
  2. data/Gemfile +2 -9
  3. data/Gemfile.lock +11 -32
  4. data/README.md +42 -123
  5. data/examples/bench_attr_vs_method-1.8.7.jpeg +0 -0
  6. data/examples/bench_attr_vs_method-1.9.3.jpeg +0 -0
  7. data/examples/bench_attr_vs_method.rb +18 -0
  8. data/examples/bench_iteration.rb +2 -4
  9. data/examples/bench_sort.rb +2 -7
  10. data/lib/viiite.rb +40 -18
  11. data/lib/viiite/bdb.rb +28 -0
  12. data/lib/viiite/bdb/cached.rb +63 -0
  13. data/lib/viiite/bdb/immediate.rb +46 -0
  14. data/lib/viiite/bdb/utils.rb +16 -0
  15. data/lib/viiite/benchmark.rb +35 -0
  16. data/lib/viiite/benchmark/runner.rb +50 -0
  17. data/lib/viiite/command.rb +33 -2
  18. data/lib/viiite/command/commons.rb +22 -0
  19. data/lib/viiite/command/help.rb +4 -5
  20. data/lib/viiite/command/plot.rb +44 -44
  21. data/lib/viiite/command/plot/to_gnuplot.rb +65 -0
  22. data/lib/viiite/command/{graph_style.rash → plot/to_gnuplot_graph.rash} +0 -0
  23. data/lib/viiite/command/{serie_style.rash → plot/to_gnuplot_serie.rash} +0 -0
  24. data/lib/viiite/command/plot/to_highcharts.rb +38 -0
  25. data/lib/viiite/command/plot/to_highcharts_graph.rb +29 -0
  26. data/lib/viiite/command/plot/to_text.rb +30 -0
  27. data/lib/viiite/command/report.rb +32 -10
  28. data/lib/viiite/command/run.rb +30 -7
  29. data/lib/viiite/errors.rb +5 -0
  30. data/lib/viiite/loader.rb +2 -2
  31. data/lib/viiite/tms.rb +21 -31
  32. data/lib/viiite/version.rb +5 -5
  33. data/spec/fixtures/bdb/Array/bench_sort.rb +7 -0
  34. data/spec/fixtures/{bench_iteration.rb → bdb/bench_iteration.rb} +2 -4
  35. data/spec/fixtures/command/bench_iteration.rb +3 -0
  36. data/spec/fixtures/saved/Array/bench_sort.rash +12 -0
  37. data/spec/fixtures/saved/bench_iteration.rash +18 -0
  38. data/spec/integration/plot/plot_1.cmd +1 -0
  39. data/spec/integration/plot/plot_1.stdout +64 -0
  40. data/spec/integration/plot/plot_2.cmd +1 -0
  41. data/spec/integration/plot/plot_2.stdout +37 -0
  42. data/spec/integration/plot/plot_3.cmd +1 -0
  43. data/spec/integration/plot/plot_3.stdout +64 -0
  44. data/spec/integration/plot/plot_4.cmd +1 -0
  45. data/spec/integration/plot/plot_4.stdout +1 -0
  46. data/spec/integration/report/viiite_report_1.cmd +1 -1
  47. data/spec/integration/report/viiite_report_1.stdout +7 -7
  48. data/spec/integration/report/viiite_report_2.cmd +1 -1
  49. data/spec/integration/report/viiite_report_2.stdout +22 -10
  50. data/spec/integration/report/viiite_report_3.cmd +1 -1
  51. data/spec/integration/report/viiite_report_3.stdout +46 -18
  52. data/spec/integration/report/viiite_report_4.cmd +1 -1
  53. data/spec/integration/report/viiite_report_4.stdout +34 -22
  54. data/spec/integration/report/viiite_report_5.cmd +1 -0
  55. data/spec/integration/report/viiite_report_5.stdout +7 -0
  56. data/spec/integration/report/viiite_report_6.cmd +1 -0
  57. data/spec/integration/report/viiite_report_6.stdout +7 -0
  58. data/spec/integration/report/viiite_report_7.cmd +1 -0
  59. data/spec/integration/report/viiite_report_7.stdout +7 -0
  60. data/spec/integration/report/viiite_report_8.cmd +1 -0
  61. data/spec/integration/report/viiite_report_8.stdout +16 -0
  62. data/spec/integration/report/viiite_report_9.cmd +1 -0
  63. data/spec/integration/report/viiite_report_9.stdout +88 -0
  64. data/spec/integration/test_command.rb +19 -23
  65. data/spec/integration/viiite/viiite_help.stdout +6 -0
  66. data/spec/spec_helper.rb +11 -17
  67. data/spec/unit/bdb/cached/test_dataset.rb +68 -0
  68. data/spec/unit/bdb/immediate/test_benchmark.rb +31 -0
  69. data/spec/unit/bdb/immediate/test_dataset.rb +31 -0
  70. data/spec/unit/bdb/immediate/test_enumerable.rb +20 -0
  71. data/spec/unit/bdb/immediate/test_pattern.rb +25 -0
  72. data/spec/unit/bdb/test_new.rb +44 -0
  73. data/spec/unit/bdb/utils/test_bench_file.rb +24 -0
  74. data/spec/unit/bdb/utils/test_replace_extension.rb +21 -0
  75. data/spec/unit/benchmark/bench_add.rb +3 -0
  76. data/spec/unit/benchmark/test_new.rb +28 -0
  77. data/spec/unit/command/commons/existing.rash +1 -0
  78. data/spec/unit/command/commons/test_single_source.rb +64 -0
  79. data/spec/unit/{formatter/plot → command/plot/gnuplot_utils}/test_to_data.rb +4 -4
  80. data/spec/unit/{formatter/plot → command/plot/gnuplot_utils}/test_to_dataset.rb +5 -5
  81. data/spec/unit/{formatter/plot → command/plot/gnuplot_utils}/test_to_plot.rb +4 -4
  82. data/spec/unit/command/test_run.rb +25 -12
  83. data/spec/unit/{test_runner.rb → test_benchmark.rb} +30 -11
  84. data/spec/unit/test_viiite.rb +17 -4
  85. data/spec/unit/tms/test_attributes.rb +11 -0
  86. data/spec/unit/tms/test_coerce.rb +11 -23
  87. data/spec/unit/tms/test_conversions.rb +23 -0
  88. data/spec/unit/tms/test_operations.rb +22 -0
  89. data/tasks/clean.rake +1 -1
  90. data/tasks/debug_mail.rake +13 -13
  91. data/tasks/gem.rake +13 -13
  92. data/tasks/integration_test.rake +3 -3
  93. data/tasks/spec_test.rake +9 -9
  94. data/tasks/unit_test.rake +9 -10
  95. data/tasks/yard.rake +13 -13
  96. data/viiite.gemspec +26 -29
  97. data/viiite.noespec +4 -7
  98. metadata +335 -235
  99. data/examples/bench_sort.eps +0 -816
  100. data/examples/bench_sort.rash +0 -100
  101. data/examples/raw.rash +0 -6
  102. data/lib/viiite/formatter.rb +0 -5
  103. data/lib/viiite/formatter/plot.rb +0 -38
  104. data/lib/viiite/runner.rb +0 -59
  105. data/lib/viiite/viiite_file.rb +0 -20
  106. data/spec/integration/raw_data.rash +0 -6
  107. data/spec/unit/tms/test_divide.rb +0 -26
  108. data/spec/unit/tms/test_minus.rb +0 -26
  109. data/spec/unit/tms/test_plus.rb +0 -34
  110. data/spec/unit/tms/test_times.rb +0 -26
  111. data/spec/unit/tms/test_to_a.rb +0 -11
  112. data/spec/unit/tms/test_to_ruby_literal.rb +0 -11
  113. data/spec/unit/tms/test_to_s.rb +0 -11
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+ module Viiite
3
+ class BDB
4
+ describe Utils, ".replace_extension" do
5
+
6
+ let(:utils){ Object.new.extend(Utils) }
7
+ subject{ utils.replace_extension(file, ".ext") }
8
+
9
+ describe "on a file without extension" do
10
+ let(:file){ "hello/world" }
11
+ it{ should eq("hello/world.ext") }
12
+ end
13
+
14
+ describe "on a file with extension" do
15
+ let(:file){ "hello/world.rb" }
16
+ it{ should eq("hello/world.ext") }
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ Viiite.bench do |b|
2
+ b.report(:add){ 1+1 }
3
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ module Viiite
3
+ describe Benchmark, '.new' do
4
+
5
+ subject{ Benchmark.new(arg) }
6
+
7
+ after{
8
+ subject.to_a.size.should eq(1)
9
+ subject.to_a.first.keys.sort_by(&:to_s).should eq([:bench, :tms])
10
+ }
11
+
12
+ describe 'with a Proc' do
13
+ let(:arg){ lambda{|b| b.report(:add){ 1+1 } } }
14
+ it{ should be_a(Benchmark) }
15
+ end
16
+
17
+ describe 'with an existing file' do
18
+ let(:arg){ File.expand_path('../bench_add.rb', __FILE__) }
19
+ it{ should be_a(Benchmark) }
20
+ end
21
+
22
+ describe 'with an IO' do
23
+ let(:arg){ File.open(File.expand_path('../bench_add.rb', __FILE__), 'r') }
24
+ it{ should be_a(Benchmark) }
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1 @@
1
+ {:name => "existing"}
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+ module Viiite
3
+ class Command
4
+ describe Commons, "#single_source" do
5
+
6
+ let(:commons){
7
+ Object.new.extend(Commons).
8
+ extend(Module.new{
9
+ attr_accessor :requester
10
+ })
11
+ }
12
+ subject{ commons.single_source(argv) }
13
+
14
+ describe "with an empty argv" do
15
+ let(:argv){ [] }
16
+ it{ should be_a(Alf::Reader) }
17
+ end
18
+
19
+ describe "with an argv with more than one arg" do
20
+ let(:argv){ [1, 2, 3] }
21
+ specify{
22
+ lambda{subject}.should raise_error(Quickl::InvalidArgument)
23
+ }
24
+ end
25
+
26
+ describe "with a argv with one existing file" do
27
+ let(:argv){ [ File.expand_path("../existing.rash", __FILE__) ] }
28
+ it{ should be_a(Alf::Reader) }
29
+ specify{
30
+ subject.to_a.should eq([{:name => 'existing'}])
31
+ }
32
+ end
33
+
34
+ describe "with a argv with a benchmark name but no requester" do
35
+ let(:argv){ [ :hello ] }
36
+ specify{
37
+ lambda{subject}.should raise_error(Quickl::InvalidArgument)
38
+ }
39
+ end
40
+
41
+ describe 'with a argv and a requester' do
42
+ let(:argv){ [ :hello ] }
43
+ let(:requester){
44
+ Object.new.extend Module.new{
45
+ def bdb; self; end
46
+ def dataset(name); name.to_s.upcase; end
47
+ }
48
+ }
49
+ before{ commons.requester = requester }
50
+ describe "with a block" do
51
+ subject{
52
+ commons.single_source(argv){|*args| args}
53
+ }
54
+ it{ should eq([requester, :hello]) }
55
+ end
56
+ describe "without block" do
57
+ it{ should eq("HELLO") }
58
+ end
59
+ end
60
+
61
+
62
+ end
63
+ end
64
+ end
@@ -1,16 +1,16 @@
1
1
  require 'spec_helper'
2
2
  module Viiite
3
- class Formatter::Plot
4
- describe "to_data" do
3
+ class Command::Plot
4
+ describe GnuplotUtils, "#to_data" do
5
5
 
6
6
  let(:data) { [ {:x => 1, :y => 10}, {:x => 2, :y => 20} ] }
7
7
 
8
- subject{ Formatter::Plot.to_data(data) }
8
+ subject{ GnuplotUtils.to_data(data) }
9
9
 
10
10
  it "should return the expected array" do
11
11
  subject.should == [ [1,2], [10,20] ]
12
12
  end
13
13
 
14
14
  end
15
- end
15
+ end
16
16
  end
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
  module Viiite
3
- class Formatter::Plot
4
- describe "to_dataset" do
3
+ class Command::Plot
4
+ describe GnuplotUtils, "#to_dataset" do
5
5
 
6
6
  let(:tuple) {
7
- {:title => "serie",
7
+ {:title => "serie",
8
8
  :linewidth => 4,
9
9
  :data => [ {:x => 1, :y => 10}, {:x => 2, :y => 20} ] }
10
10
  }
11
- subject{ Formatter::Plot.to_dataset(tuple) }
11
+ subject{ GnuplotUtils.to_dataset(tuple) }
12
12
 
13
13
  it "should return a correct dataset instance" do
14
14
  subject.should be_a(Gnuplot::DataSet)
@@ -18,5 +18,5 @@ module Viiite
18
18
  end
19
19
 
20
20
  end
21
- end
21
+ end
22
22
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  module Viiite
3
- class Formatter::Plot
4
- describe "to_plot" do
3
+ class Command::Plot
4
+ describe GnuplotUtils, "#to_plot" do
5
5
 
6
6
  let(:data) { [ {:x => 1, :y => 10}, {:x => 2, :y => 20} ] }
7
7
 
@@ -9,7 +9,7 @@ module Viiite
9
9
 
10
10
  let(:plot) { {:title => "plot", :series => [ dataset ] } }
11
11
 
12
- subject{ Formatter::Plot.to_plot(plot) }
12
+ subject{ GnuplotUtils.to_plot(plot) }
13
13
 
14
14
  it "should return a correct plot instance" do
15
15
  subject.is_a?(Gnuplot::Plot).should be_true
@@ -17,5 +17,5 @@ module Viiite
17
17
  end
18
18
 
19
19
  end
20
- end
20
+ end
21
21
  end
@@ -3,21 +3,34 @@ module Viiite
3
3
  class Command
4
4
  describe Run do
5
5
 
6
- subject{ Run.run(argv) }
7
-
8
- before{ redirect_io }
9
- after { restore_io }
6
+ let(:bench_iteration){ fixtures_folder+'/command/bench_iteration.rb' }
7
+ subject{
8
+ out, err = capture_io { Run.run(argv) }
9
+ rel = Alf::Reader.reader(StringIO.new(out)).to_rel
10
+ rel = rel.project([:tms], {:allbut => true})
11
+ }
10
12
 
11
13
  describe "when passed a benchmark file" do
12
- let(:argv){ [bench_iteration] }
13
- specify{
14
- subject
15
- $stdout.string.each_line do |line|
16
- h = eval(line)
17
- h.should be_a(Hash)
18
- h[:tms].should be_a(Viiite::Tms)
19
- end
14
+ let(:argv){ [ bench_iteration ] }
15
+ it{ should eq(Alf::Relation[{:bench => :times}]) }
16
+ end
17
+
18
+ describe "with --runs" do
19
+ let(:argv){ [ bench_iteration, "--runs=2" ] }
20
+ let(:expected){
21
+ Alf::Relation[{:bench => :times, :run => 0},
22
+ {:bench => :times, :run => 1}]
23
+ }
24
+ it{ should eq(expected) }
25
+ end
26
+
27
+ describe "with --runs and --run-key" do
28
+ let(:argv){ [ bench_iteration, "--runs=2", "--run-key=hello" ] }
29
+ let(:expected){
30
+ Alf::Relation[{:bench => :times, :hello => 0},
31
+ {:bench => :times, :hello => 1}]
20
32
  }
33
+ it{ should eq(expected) }
21
34
  end
22
35
 
23
36
  end
@@ -1,16 +1,16 @@
1
1
  require 'spec_helper'
2
2
  module Viiite
3
- describe Runner do
4
-
5
- it "should be definable with Viiite.bm" do
6
- b = Viiite.bm do |viiite|
3
+ describe Benchmark do
4
+
5
+ it "should be definable with Viiite.bench" do
6
+ b = Viiite.bench do |viiite|
7
7
  viiite.report{ 1 + 1 }
8
8
  end
9
- b.should be_kind_of(Viiite::Runner)
9
+ b.should be_kind_of(Viiite::Benchmark)
10
10
  end
11
11
 
12
12
  it "should be executable" do
13
- b = Viiite.bm do |viiite|
13
+ b = Viiite.bench do |viiite|
14
14
  viiite.report{ 1 + 1 }
15
15
  end
16
16
  res = []
@@ -24,7 +24,7 @@ module Viiite
24
24
  end
25
25
 
26
26
  it "should be enumerable" do
27
- b = Viiite.bm do |viiite|
27
+ b = Viiite.bench do |viiite|
28
28
  viiite.report{ 1 + 1 }
29
29
  end
30
30
  res = b.to_a
@@ -32,10 +32,10 @@ module Viiite
32
32
  res.size.should == 1
33
33
  res.first[:tms].should be_kind_of(Viiite::Tms)
34
34
  end
35
-
35
+
36
36
  it "should support variation points" do
37
- b = Viiite.bm do |viiite|
38
- 2.times do |i|
37
+ b = Viiite.bench do |viiite|
38
+ 2.times do |i|
39
39
  viiite.variation_point(:"#run", i)
40
40
  viiite.report do end
41
41
  end
@@ -45,7 +45,7 @@ module Viiite
45
45
  end
46
46
 
47
47
  it "should support ranging over values" do
48
- b = Viiite.bm do |viiite|
48
+ b = Viiite.bench do |viiite|
49
49
  viiite.range_over [10, 100, 1000], :times do |t|
50
50
  viiite.report do end
51
51
  end
@@ -53,5 +53,24 @@ module Viiite
53
53
  b.to_a.collect{|t| t[:times]}.should == [10, 100, 1000]
54
54
  end
55
55
 
56
+ it "should support nested #with, #variation_point and #range_over" do
57
+ Viiite.bench do |r|
58
+ r.variation_point :all, true
59
+ r.variation_point(:ruby, :ruby) do
60
+ r.variation_point :for_bench1, true
61
+ r.range_over(1..2, :i) do
62
+ r.report(:bench1) {}
63
+ end
64
+ end
65
+ r.with(:a => :b) do
66
+ r.report(:bench2) {}
67
+ end
68
+ end.to_rel.project([:tms], {:allbut => true}).should == Alf::Relation[
69
+ {:all => true, :ruby => :ruby, :for_bench1 => true, :i => 1, :bench => :bench1},
70
+ {:all => true, :ruby => :ruby, :for_bench1 => true, :i => 2, :bench => :bench1},
71
+ {:all => true, :a => :b, :bench => :bench2}
72
+ ]
73
+ end
74
+
56
75
  end
57
76
  end
@@ -1,12 +1,25 @@
1
1
  require 'spec_helper'
2
2
  describe Viiite do
3
-
3
+
4
4
  it "should have a version number" do
5
5
  Viiite.const_defined?(:VERSION).should be_true
6
6
  end
7
7
 
8
- it "should provide a way to have short ruby descr" do
9
- Viiite.which_ruby.should_not be_empty
8
+ it "should provide a way to have a short ruby description" do
9
+ {
10
+ 'ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux]' => 'ruby 1.8.7p334',
11
+ 'ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]' => 'ruby 1.8.7p352',
12
+ 'ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2011.03' => 'ree 2011.03',
13
+ 'ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]' => 'ruby 1.9.2p290',
14
+ 'ruby 1.9.3dev (2011-07-31 revision 32789) [x86_64-linux]' => 'ruby 1.9.3dev',
15
+ 'ruby 1.9.4dev (2011-08-24 trunk 33047) [x86_64-linux]' => 'ruby 1.9.4dev',
16
+ 'rubinius 1.2.5dev (1.8.7 489d5384 yyyy-mm-dd JI) [x86_64-unknown-linux-gnu]' => 'rubinius 1.2.5dev',
17
+ 'rubinius 2.0.0dev (1.8.7 d705d318 yyyy-mm-dd JI) [x86_64-unknown-linux-gnu]' => 'rubinius 2.0.0dev',
18
+ 'jruby 1.6.3 (ruby-1.8.7-p330) (2011-07-07 965162f) (OpenJDK 64-Bit Server VM 1.6.0_22) [linux-amd64-java]' => 'jruby 1.6.3',
19
+ 'jruby 1.7.0.dev (ruby-1.8.7-p330) (2011-08-24 7b9f999) (OpenJDK 64-Bit Server VM 1.6.0_22) [linux-amd64-java]' => 'jruby 1.7.0.dev',
20
+ }.each_pair { |description, short|
21
+ Viiite.short_ruby_description(description).should == short
22
+ }
10
23
  end
11
-
24
+
12
25
  end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+ module Viiite
3
+ describe Tms, "#attributes" do
4
+ subject { Tms.new(1.0, 2.0, 3.0, 4.0, 5.0) }
5
+ its(:utime) { should eq 1.0 }
6
+ its(:stime) { should eq 2.0 }
7
+ its(:cutime) { should eq 3.0 }
8
+ its(:cstime) { should eq 4.0 }
9
+ its(:real) { should eq 5.0 }
10
+ end
11
+ end
@@ -6,40 +6,28 @@ module Viiite
6
6
 
7
7
  describe "from zero" do
8
8
  let(:arg){ 0.0 }
9
- specify{
10
- subject.should be_a(Tms)
11
- subject.to_a.should eq([0.0, 0.0, 0.0, 0.0, 0.0])
12
- }
9
+ it { should eq Tms[0.0, 0.0, 0.0, 0.0, 0.0] }
13
10
  end
14
11
 
15
12
  describe "from one" do
16
13
  let(:arg){ 1.0 }
17
- specify{
18
- subject.should be_a(Tms)
19
- subject.to_a.should eq([1.0, 0.0, 0.0, 0.0, 0.0])
20
- }
14
+ it { should eq Tms[1.0, 0.0, 0.0, 0.0, 0.0] }
21
15
  end
22
16
 
23
17
  describe "from a complete hash" do
24
18
  let(:arg){ {
25
- :utime => 1.0,
26
- :stime => 2.0,
27
- :cutime => 3.0,
28
- :cstime => 4.0,
29
- :real => 5.0,
30
- } }
31
- specify{
32
- subject.should be_a(Tms)
33
- subject.to_a.should eq([1.0, 2.0, 3.0, 4.0, 5.0])
34
- }
19
+ :utime => 1.0,
20
+ :stime => 2.0,
21
+ :cutime => 3.0,
22
+ :cstime => 4.0,
23
+ :real => 5.0,
24
+ } }
25
+ it { should eq Tms[1.0, 2.0, 3.0, 4.0, 5.0] }
35
26
  end
36
27
 
37
28
  describe "from an array" do
38
- let(:arg){ [1.0, 2.0, 3.0, 4.0, 5.0] }
39
- specify{
40
- subject.should be_a(Tms)
41
- subject.to_a.should eq([1.0, 2.0, 3.0, 4.0, 5.0])
42
- }
29
+ let(:arg){ [1.0, 2.0, 3.0, 4.0, 5.0] }
30
+ it { should eq Tms[1.0, 2.0, 3.0, 4.0, 5.0] }
43
31
  end
44
32
 
45
33
  end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+ module Viiite
3
+ describe Tms, "conversions" do
4
+
5
+ let(:tms) { Tms.new(1.0, 2.0, 3.0, 4.0, 5.0) }
6
+
7
+ specify '#to_s' do
8
+ tms.to_s.should eq " 1.000000 2.000000 10.000000 ( 5.000000)"
9
+ end
10
+
11
+ specify '#to_a' do
12
+ tms.to_a.should eq [1.0, 2.0, 3.0, 4.0, 5.0]
13
+ end
14
+
15
+ specify '#to_h' do
16
+ tms.to_h.should eq :utime=>1.0, :stime=>2.0, :cutime=>3.0, :cstime=>4.0, :real=>5.0
17
+ end
18
+
19
+ specify '#to_ruby_literal' do
20
+ eval(tms.to_ruby_literal).should eq tms
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+ module Viiite
3
+ describe Tms, "operations: +,-,*,/" do
4
+
5
+ let(:tms){ Tms.new(1.0, 2.0, 3.0, 4.0, 5.0) }
6
+
7
+ specify "with an integer" do
8
+ (tms + 2).should eq Tms[3.0, 4.0, 5.0, 6.0, 7.0]
9
+ (tms / 2).should eq Tms[0.5, 1.0, 1.5, 2.0, 2.5]
10
+ end
11
+
12
+ specify "with another tms" do
13
+ (tms - tms).should eq Tms[0.0, 0.0, 0.0, 0.0, 0.0]
14
+ (tms / tms).should eq Tms[1.0, 1.0, 1.0, 1.0, 1.0]
15
+ end
16
+
17
+ specify "the other way round" do
18
+ (2 + tms).should eq Tms[3.0, 4.0, 5.0, 6.0, 7.0]
19
+ end
20
+
21
+ end
22
+ end