rVM 0.0.14 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. data/README +4 -4
  2. data/bin/rvm +229 -0
  3. data/lib/rvm.rb +6 -6
  4. data/lib/rvm/acts_as_rvm_type.rb +26 -3
  5. data/lib/rvm/classes.rb +9 -15
  6. data/lib/rvm/classes/block.rb +8 -3
  7. data/lib/rvm/classes/class.rb +2 -2
  8. data/lib/rvm/classes/list.rb +1 -1
  9. data/lib/rvm/classes/null.rb +31 -0
  10. data/lib/rvm/classes/number.rb +4 -0
  11. data/lib/rvm/classes/object.rb +1 -1
  12. data/lib/rvm/classes/string.rb +6 -1
  13. data/lib/rvm/environment.rb +256 -0
  14. data/lib/rvm/functions.rb +9 -4
  15. data/lib/rvm/functions/array.rb +26 -2
  16. data/lib/rvm/functions/array/append.rb +31 -1
  17. data/lib/rvm/functions/array/at.rb +29 -1
  18. data/lib/rvm/functions/array/set_at.rb +29 -0
  19. data/lib/rvm/functions/association/assoc_get.rb +34 -0
  20. data/lib/rvm/functions/association/assoc_set.rb +32 -0
  21. data/lib/rvm/functions/bitwise.rb +3 -0
  22. data/lib/rvm/functions/bitwise/bitwise_and.rb +41 -0
  23. data/lib/rvm/functions/bitwise/bitwise_or.rb +41 -0
  24. data/lib/rvm/functions/bitwise/bitwise_xor.rb +41 -0
  25. data/lib/rvm/functions/collection/get.rb +37 -4
  26. data/lib/rvm/functions/collection/set.rb +37 -3
  27. data/lib/rvm/functions/collection/size.rb +33 -1
  28. data/lib/rvm/functions/general/cmp.rb +35 -7
  29. data/lib/rvm/functions/general/eq.rb +29 -0
  30. data/lib/rvm/functions/general/gt.rb +29 -0
  31. data/lib/rvm/functions/general/gte.rb +29 -0
  32. data/lib/rvm/functions/general/lt.rb +29 -0
  33. data/lib/rvm/functions/general/lte.rb +29 -0
  34. data/lib/rvm/functions/general/neq.rb +5 -0
  35. data/lib/rvm/functions/io/print.rb +38 -8
  36. data/lib/rvm/functions/list/align.rb +25 -1
  37. data/lib/rvm/functions/list/join.rb +27 -0
  38. data/lib/rvm/functions/list/map.rb +34 -0
  39. data/lib/rvm/functions/list/split.rb +31 -0
  40. data/lib/rvm/functions/logic/and.rb +36 -2
  41. data/lib/rvm/functions/logic/not.rb +27 -0
  42. data/lib/rvm/functions/logic/or.rb +32 -2
  43. data/lib/rvm/functions/math/add.rb +25 -0
  44. data/lib/rvm/functions/math/cos.rb +39 -0
  45. data/lib/rvm/functions/math/div.rb +25 -0
  46. data/lib/rvm/functions/math/mod.rb +41 -0
  47. data/lib/rvm/functions/math/mul.rb +25 -0
  48. data/lib/rvm/functions/math/neg.rb +25 -0
  49. data/lib/rvm/functions/math/power.rb +25 -0
  50. data/lib/rvm/functions/math/shl.rb +41 -0
  51. data/lib/rvm/functions/math/shr.rb +41 -0
  52. data/lib/rvm/functions/math/sin.rb +39 -0
  53. data/lib/rvm/functions/math/sub.rb +25 -0
  54. data/lib/rvm/functions/math/tan.rb +39 -0
  55. data/lib/rvm/functions/rails/print.rb +33 -3
  56. data/lib/rvm/interpreter.rb +405 -272
  57. data/lib/rvm/languages.rb +45 -11
  58. data/lib/rvm/languages/brainfuck.rb +15 -16
  59. data/lib/rvm/languages/ecma.rb +4 -1257
  60. data/lib/rvm/languages/ecma/compiler.rb +1353 -0
  61. data/lib/rvm/languages/ecma/core-math.js +84 -0
  62. data/lib/rvm/languages/math.rb +9 -16
  63. data/lib/rvm/languages/math/compiler.rb +9 -9
  64. data/lib/rvm/languages/math/tokenizer.rb +1 -1
  65. data/lib/rvm/languages/math/tree.rb +14 -14
  66. data/lib/rvm/library.rb +26 -18
  67. data/lib/rvm/optimisation.rb +109 -0
  68. data/lib/rvm/plugin.rb +109 -45
  69. data/lib/rvm/rails.rb +79 -54
  70. data/spec/classes/atom/association_spec.rb +8 -8
  71. data/spec/classes/atom/block_spec.rb +8 -5
  72. data/spec/classes/atom/boolean_spec.rb +1 -1
  73. data/spec/classes/atom/error_spec.rb +1 -1
  74. data/spec/classes/atom/list_spec.rb +1 -1
  75. data/spec/classes/atom/number_spec.rb +2 -2
  76. data/spec/classes/atom/string_spec.rb +1 -1
  77. data/spec/languages/ecma/ecma_spec.rb +94 -38
  78. data/spec/languages/ecma/json_spec.rb +4 -4
  79. data/spec/languages/math/compiler_spec.rb +5 -5
  80. data/spec/languages/math/tokenizer_spec.rb +1 -1
  81. data/spec/languages/math/tree_spec.rb +1 -1
  82. data/spec/{base → rvm}/class_spec.rb +2 -2
  83. data/spec/{base/interpreter → rvm}/enviroment_spec.rb +19 -9
  84. data/spec/{base → rvm}/function_spec.rb +2 -2
  85. data/spec/{functions → rvm/functions}/association/assoc_get_spec.rb +2 -2
  86. data/spec/{functions → rvm/functions}/association/assoc_set_spec.rb +2 -2
  87. data/spec/rvm/functions/collection/get_spec.rb +12 -0
  88. data/spec/rvm/functions/collection/set_spec.rb +10 -0
  89. data/spec/rvm/functions/collection/size_spec.rb +10 -0
  90. data/spec/{functions → rvm/functions}/list/split_spec.rb +3 -3
  91. data/spec/{functions → rvm/functions}/string/ansi_spec.rb +3 -3
  92. data/spec/{functions → rvm/functions}/string/capstr_spec.rb +3 -3
  93. data/spec/{functions → rvm/functions}/string/center_spec.rb +3 -3
  94. data/spec/{functions → rvm/functions}/string/ljust_spec.rb +3 -3
  95. data/spec/{functions → rvm/functions}/string/regmatch_spec.rb +3 -3
  96. data/spec/{functions → rvm/functions}/string/rjust_spec.rb +3 -3
  97. data/spec/{base → rvm}/interpreter/assignment_spec.rb +1 -1
  98. data/spec/rvm/interpreter/condition_spec.rb +103 -0
  99. data/spec/{base → rvm}/interpreter/constant_spec.rb +1 -1
  100. data/spec/rvm/interpreter/core_call_spec.rb +72 -0
  101. data/spec/{base → rvm}/interpreter/interpreter_spec.rb +1 -1
  102. data/spec/{base → rvm}/interpreter/parameter_spec.rb +1 -1
  103. data/spec/rvm/interpreter/sequence_spec.rb +47 -0
  104. data/spec/{base → rvm}/interpreter/variable_spec.rb +1 -1
  105. data/spec/{base → rvm}/plugin_spec.rb +2 -2
  106. metadata +66 -35
  107. data/lib/rake/helpers/code_statistics.rb +0 -167
  108. data/spec/base/interpreter/condition_spec.rb +0 -47
  109. data/spec/base/interpreter/function_call_spec.rb +0 -72
  110. data/spec/base/interpreter/sequence_spec.rb +0 -20
  111. data/spec/functions/collection/get_spec.rb +0 -12
  112. data/spec/functions/collection/set_spec.rb +0 -10
  113. data/spec/functions/collection/size_spec.rb +0 -10
@@ -1,4 +1,4 @@
1
- require 'lib/rvm/interpreter'
1
+ require 'rvm/interpreter'
2
2
 
3
3
  describe RVM::Interpreter do
4
4
 
@@ -1,4 +1,4 @@
1
- require 'lib/rvm/interpreter'
1
+ require 'rvm/interpreter'
2
2
 
3
3
  describe RVM::Interpreter::Parameter do
4
4
  before do
@@ -0,0 +1,47 @@
1
+ require 'rvm/interpreter'
2
+
3
+ describe RVM::Interpreter::Sequence do
4
+ =begin
5
+ before do
6
+ @part1 = mock('part1 mock')
7
+ @part2 = mock('part2 mock')
8
+ @env = mock('env mock')
9
+
10
+ @object = RVM::Interpreter::Sequence.new([@part1,@part2])
11
+ end
12
+
13
+ it "should execute each part after another" do
14
+ @part1.should_receive(:execute).with(@env, nil).once
15
+ @part2.should_receive(:execute).with(@env, nil).once
16
+ @env.should_receive(:path).with(no_args).exactly(6).times.and_return([1])
17
+ @object.execute(@env)
18
+ end
19
+
20
+ it "should have a data_type of :any" do
21
+ @object.data_type.should == :any
22
+ end
23
+
24
+ it "should add add a new layer to path when called" do
25
+ @path = mock('path mock')
26
+ @object = RVM::Interpreter::Sequence.new([@part1])
27
+ @part1.should_receive(:execute).with(@env, nil).once
28
+ @env.should_receive(:path).with(no_args).exactly(4).times.and_return(@path)
29
+ @path.should_receive(:<<).with(0).once
30
+ @path.should_receive(:pop).with(no_args).twice.and_return(0)
31
+ @path.should_receive(:<<).with(1).once
32
+ @object.execute(@env)
33
+ end
34
+
35
+ it "should skip parts according to the path" do
36
+ @part2.should_receive(:execute).with(@env, nil).once
37
+ @env.should_receive(:path).with(no_args).exactly(6).times.and_return([1])
38
+ @object.execute(@env, [1])
39
+ end
40
+
41
+ it "should hand down the path to the next executor" do
42
+ @part2.should_receive(:execute).with(@env, [2]).once
43
+ @env.should_receive(:path).with(no_args).exactly(6).times.and_return([1])
44
+ @object.execute(@env, [1,2])
45
+ end
46
+ =end
47
+ end
@@ -1,4 +1,4 @@
1
- require 'lib/rvm/interpreter'
1
+ require 'rvm/interpreter'
2
2
 
3
3
  describe RVM::Interpreter::Variable do
4
4
  before do
@@ -1,5 +1,5 @@
1
- require 'lib/rvm/plugin'
2
- require File.dirname(__FILE__) + '/helpers/plugin_helper'
1
+ require 'rvm/plugin'
2
+ require 'spec/rvm/helpers/plugin_helper'
3
3
 
4
4
  describe RVM::PluginHost do
5
5
  it_should_behave_like 'a plugin host'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rVM
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heinz N. Gies
@@ -9,23 +9,33 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-31 00:00:00 +02:00
12
+ date: 2009-01-02 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
16
  description:
17
17
  email: heinz@licenser.net
18
- executables: []
19
-
18
+ executables:
19
+ - rvm
20
20
  extensions: []
21
21
 
22
22
  extra_rdoc_files:
23
23
  - README
24
24
  files:
25
- - lib/rake
26
- - lib/rake/helpers
27
- - lib/rake/helpers/code_statistics.rb
28
- - lib/rvm
25
+ - lib/rvm.rb
26
+ - lib/rvm/./acts_as_rvm_type.rb
27
+ - lib/rvm/./classes
28
+ - lib/rvm/./classes.rb
29
+ - lib/rvm/./environment.rb
30
+ - lib/rvm/./functions
31
+ - lib/rvm/./functions.rb
32
+ - lib/rvm/./interpreter.rb
33
+ - lib/rvm/./languages
34
+ - lib/rvm/./languages.rb
35
+ - lib/rvm/./library.rb
36
+ - lib/rvm/./optimisation.rb
37
+ - lib/rvm/./plugin.rb
38
+ - lib/rvm/./rails.rb
29
39
  - lib/rvm/acts_as_rvm_type.rb
30
40
  - lib/rvm/classes
31
41
  - lib/rvm/classes/association.rb
@@ -34,10 +44,12 @@ files:
34
44
  - lib/rvm/classes/class.rb
35
45
  - lib/rvm/classes/error.rb
36
46
  - lib/rvm/classes/list.rb
47
+ - lib/rvm/classes/null.rb
37
48
  - lib/rvm/classes/number.rb
38
49
  - lib/rvm/classes/object.rb
39
50
  - lib/rvm/classes/string.rb
40
51
  - lib/rvm/classes.rb
52
+ - lib/rvm/environment.rb
41
53
  - lib/rvm/functions
42
54
  - lib/rvm/functions/all.rb
43
55
  - lib/rvm/functions/array
@@ -48,6 +60,11 @@ files:
48
60
  - lib/rvm/functions/association
49
61
  - lib/rvm/functions/association/assoc_get.rb
50
62
  - lib/rvm/functions/association/assoc_set.rb
63
+ - lib/rvm/functions/bitwise
64
+ - lib/rvm/functions/bitwise/bitwise_and.rb
65
+ - lib/rvm/functions/bitwise/bitwise_or.rb
66
+ - lib/rvm/functions/bitwise/bitwise_xor.rb
67
+ - lib/rvm/functions/bitwise.rb
51
68
  - lib/rvm/functions/collection
52
69
  - lib/rvm/functions/collection/get.rb
53
70
  - lib/rvm/functions/collection/set.rb
@@ -77,11 +94,17 @@ files:
77
94
  - lib/rvm/functions/logic.rb
78
95
  - lib/rvm/functions/math
79
96
  - lib/rvm/functions/math/add.rb
97
+ - lib/rvm/functions/math/cos.rb
80
98
  - lib/rvm/functions/math/div.rb
99
+ - lib/rvm/functions/math/mod.rb
81
100
  - lib/rvm/functions/math/mul.rb
82
101
  - lib/rvm/functions/math/neg.rb
83
102
  - lib/rvm/functions/math/power.rb
103
+ - lib/rvm/functions/math/shl.rb
104
+ - lib/rvm/functions/math/shr.rb
105
+ - lib/rvm/functions/math/sin.rb
84
106
  - lib/rvm/functions/math/sub.rb
107
+ - lib/rvm/functions/math/tan.rb
85
108
  - lib/rvm/functions/math.rb
86
109
  - lib/rvm/functions/objects
87
110
  - lib/rvm/functions/objects/send.rb
@@ -101,6 +124,9 @@ files:
101
124
  - lib/rvm/interpreter.rb
102
125
  - lib/rvm/languages
103
126
  - lib/rvm/languages/brainfuck.rb
127
+ - lib/rvm/languages/ecma
128
+ - lib/rvm/languages/ecma/compiler.rb
129
+ - lib/rvm/languages/ecma/core-math.js
104
130
  - lib/rvm/languages/ecma.rb
105
131
  - lib/rvm/languages/math
106
132
  - lib/rvm/languages/math/compiler.rb
@@ -109,15 +135,20 @@ files:
109
135
  - lib/rvm/languages/math.rb
110
136
  - lib/rvm/languages.rb
111
137
  - lib/rvm/library.rb
138
+ - lib/rvm/optimisation.rb
112
139
  - lib/rvm/plugin.rb
113
140
  - lib/rvm/rails.rb
114
- - lib/rvm.rb
141
+ - bin/rvm
115
142
  - README
116
143
  has_rdoc: true
117
144
  homepage: http://code.licenser.net/projects/show/rvm
118
145
  post_install_message:
119
- rdoc_options: []
120
-
146
+ rdoc_options:
147
+ - --title
148
+ - rVM
149
+ - --main
150
+ - README
151
+ - --line-numbers
121
152
  require_paths:
122
153
  - lib
123
154
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -140,18 +171,6 @@ signing_key:
140
171
  specification_version: 2
141
172
  summary: A ruby based VM that lets one add secure scripting to ruby applications.
142
173
  test_files:
143
- - spec/base/class_spec.rb
144
- - spec/base/function_spec.rb
145
- - spec/base/interpreter/assignment_spec.rb
146
- - spec/base/interpreter/condition_spec.rb
147
- - spec/base/interpreter/constant_spec.rb
148
- - spec/base/interpreter/enviroment_spec.rb
149
- - spec/base/interpreter/function_call_spec.rb
150
- - spec/base/interpreter/interpreter_spec.rb
151
- - spec/base/interpreter/parameter_spec.rb
152
- - spec/base/interpreter/sequence_spec.rb
153
- - spec/base/interpreter/variable_spec.rb
154
- - spec/base/plugin_spec.rb
155
174
  - spec/classes/atom/association_spec.rb
156
175
  - spec/classes/atom/block_spec.rb
157
176
  - spec/classes/atom/boolean_spec.rb
@@ -159,20 +178,32 @@ test_files:
159
178
  - spec/classes/atom/list_spec.rb
160
179
  - spec/classes/atom/number_spec.rb
161
180
  - spec/classes/atom/string_spec.rb
162
- - spec/functions/association/assoc_get_spec.rb
163
- - spec/functions/association/assoc_set_spec.rb
164
- - spec/functions/collection/get_spec.rb
165
- - spec/functions/collection/set_spec.rb
166
- - spec/functions/collection/size_spec.rb
167
- - spec/functions/list/split_spec.rb
168
- - spec/functions/string/ansi_spec.rb
169
- - spec/functions/string/capstr_spec.rb
170
- - spec/functions/string/center_spec.rb
171
- - spec/functions/string/ljust_spec.rb
172
- - spec/functions/string/regmatch_spec.rb
173
- - spec/functions/string/rjust_spec.rb
174
181
  - spec/languages/ecma/ecma_spec.rb
175
182
  - spec/languages/ecma/json_spec.rb
176
183
  - spec/languages/math/compiler_spec.rb
177
184
  - spec/languages/math/tokenizer_spec.rb
178
185
  - spec/languages/math/tree_spec.rb
186
+ - spec/rvm/class_spec.rb
187
+ - spec/rvm/enviroment_spec.rb
188
+ - spec/rvm/function_spec.rb
189
+ - spec/rvm/functions/association/assoc_get_spec.rb
190
+ - spec/rvm/functions/association/assoc_set_spec.rb
191
+ - spec/rvm/functions/collection/get_spec.rb
192
+ - spec/rvm/functions/collection/set_spec.rb
193
+ - spec/rvm/functions/collection/size_spec.rb
194
+ - spec/rvm/functions/list/split_spec.rb
195
+ - spec/rvm/functions/string/ansi_spec.rb
196
+ - spec/rvm/functions/string/capstr_spec.rb
197
+ - spec/rvm/functions/string/center_spec.rb
198
+ - spec/rvm/functions/string/ljust_spec.rb
199
+ - spec/rvm/functions/string/regmatch_spec.rb
200
+ - spec/rvm/functions/string/rjust_spec.rb
201
+ - spec/rvm/interpreter/assignment_spec.rb
202
+ - spec/rvm/interpreter/condition_spec.rb
203
+ - spec/rvm/interpreter/constant_spec.rb
204
+ - spec/rvm/interpreter/core_call_spec.rb
205
+ - spec/rvm/interpreter/interpreter_spec.rb
206
+ - spec/rvm/interpreter/parameter_spec.rb
207
+ - spec/rvm/interpreter/sequence_spec.rb
208
+ - spec/rvm/interpreter/variable_spec.rb
209
+ - spec/rvm/plugin_spec.rb
@@ -1,167 +0,0 @@
1
- # From rails (http://rubyonrails.com)
2
- #
3
- # Improved by murphy
4
- class CodeStatistics
5
-
6
- TEST_TYPES = /\btest/i
7
-
8
- # Create a new Code Statistic.
9
- #
10
- # Rakefile Example:
11
- #
12
- # desc 'Report code statistics (LOC) from the application'
13
- # task :stats => :copy_files do
14
- # require 'rake_helpers/code_statistics'
15
- # CodeStatistics.new(
16
- # ["Main", "lib"],
17
- # ["Tests", "test"],
18
- # ["Demos", "demo"]
19
- # ).to_s
20
- # end
21
- def initialize(*pairs)
22
- @pairs = pairs
23
- @statistics = calculate_statistics
24
- @total = if pairs.empty? then nil else calculate_total end
25
- end
26
-
27
- # Print a textual table viewing the stats
28
- #
29
- # Intended for console output.
30
- def print
31
- print_header
32
- @pairs.each { |name, path| print_line name, @statistics[name] }
33
- print_splitter
34
-
35
- if @total
36
- print_line 'Total', @total
37
- print_splitter
38
- end
39
-
40
- print_code_test_stats
41
- end
42
-
43
- private
44
-
45
- DEFAULT_FILE_PATTERN = /\.rb$/
46
-
47
- def calculate_statistics
48
- @pairs.inject({}) do |stats, (name, path, pattern, is_ruby_code)|
49
- pattern ||= DEFAULT_FILE_PATTERN
50
- path = File.join path, '*.rb'
51
- stats[name] = calculate_directory_statistics path, pattern, is_ruby_code
52
- stats
53
- end
54
- end
55
-
56
- def calculate_directory_statistics directory, pattern = DEFAULT_FILE_PATTERN, is_ruby_code = true
57
- is_ruby_code = true if is_ruby_code.nil?
58
- stats = Hash.new 0
59
-
60
- Dir[directory].each do |file_name|
61
- puts "Scanning #{file_name}..." if $DEBUG
62
- next unless file_name =~ pattern
63
-
64
- lines = codelines = classes = modules = methods = 0
65
- empty_lines = comment_lines = 0
66
- in_comment_block = false
67
-
68
- File.readlines(file_name).each do |line|
69
- lines += 1
70
- if line[/^\s*$/]
71
- empty_lines += 1
72
- elsif is_ruby_code
73
- case line
74
- when /^=end\b/
75
- comment_lines += 1
76
- in_comment_block = false
77
- when in_comment_block
78
- comment_lines += 1
79
- when /^\s*class\b/: classes += 1
80
- when /^\s*module\b/: modules += 1
81
- when /^\s*def\b/: methods += 1
82
- when /^\s*#/: comment_lines += 1
83
- when /^=begin\b/
84
- in_comment_block = false
85
- comment_lines += 1
86
- when /^__END__$/
87
- in_comment_block = true
88
- end
89
- end
90
- end
91
-
92
- codelines = lines - comment_lines - empty_lines
93
-
94
- stats[:lines] += lines
95
- stats[:comments] += comment_lines
96
- stats[:codelines] += codelines
97
- stats[:classes] += classes
98
- stats[:modules] += modules
99
- stats[:methods] += methods
100
- stats[:files] += 1
101
- end
102
-
103
- stats
104
- end
105
-
106
- def calculate_total
107
- total = Hash.new 0
108
- @statistics.each_value { |pair| pair.each { |k, v| total[k] += v } }
109
- total
110
- end
111
-
112
- def calculate_code
113
- code_loc = 0
114
- @statistics.each { |k, v| code_loc += v[:codelines] unless k[TEST_TYPES] }
115
- code_loc
116
- end
117
-
118
- def calculate_tests
119
- test_loc = 0
120
- @statistics.each { |k, v| test_loc += v[:codelines] if k[TEST_TYPES] }
121
- test_loc
122
- end
123
-
124
- def print_header
125
- print_splitter
126
- puts "| T=Test Name | Files | Lines | LOC | Comments | Classes | Modules | Methods | M/C | LOC/M |"
127
- print_splitter
128
- end
129
-
130
- def print_splitter
131
- puts "+---------------------------+-------+-------+-------+----------+---------+---------+---------+-----+-------+"
132
- end
133
-
134
- def print_line name, statistics
135
- m_over_c = (statistics[:methods] / (statistics[:classes] + statistics[:modules])) rescue m_over_c = 0
136
- loc_over_m = (statistics[:codelines] / statistics[:methods]) - 2 rescue loc_over_m = 0
137
-
138
- if name[TEST_TYPES]
139
- name = "T #{name}"
140
- else
141
- name = " #{name}"
142
- end
143
-
144
- line = "| %-25s | %5d | %5d | %5d | %8d | %7d | %7d | %7d | %3d | %5d |" % (
145
- [name, *statistics.values_at(:files, :lines, :codelines, :comments, :classes, :modules, :methods)] +
146
- [m_over_c, loc_over_m] )
147
-
148
- puts line
149
- end
150
-
151
- def print_code_test_stats
152
- code = calculate_code
153
- tests = calculate_tests
154
-
155
- puts " Code LOC = #{code} Test LOC = #{tests} Code:Test Ratio = [1 : #{sprintf("%.2f", tests.to_f/code)}]"
156
- puts ""
157
- end
158
-
159
- end
160
-
161
- # Run a test script.
162
- if $0 == __FILE__
163
- $VERBOSE = true
164
- CodeStatistics.new(
165
- ['This dir', File.dirname(__FILE__)]
166
- ).print
167
- end
@@ -1,47 +0,0 @@
1
- require 'lib/rvm/interpreter'
2
-
3
- describe RVM::Interpreter::Condition do
4
- before do
5
- @true_case = mock('true case mock')
6
- @false_case = mock('false case mock')
7
- @condition = mock('condition mock')
8
- @env = RVM::Interpreter.env
9
- @object = RVM::Interpreter::Condition.new(@condition, @true_case, @false_case)
10
- end
11
-
12
- it "should execute the condition if true execute the true case, retring it's value" do
13
- result = mock('result mock')
14
- result.should_receive(:is_true?).with(no_args).once.and_return(true)
15
- @true_case.should_receive(:execute).with(@env).once.and_return('true case')
16
- @condition.should_receive(:execute).with(@env).once.and_return(result)
17
- @object.execute(@env).should == 'true case'
18
- end
19
-
20
- it "should execute the condition if false execute the false case, retring it's value" do
21
- result = mock('result mock')
22
- result.should_receive(:is_true?).with(no_args).once.and_return(false)
23
- @false_case.should_receive(:execute).with(@env).once.and_return('false case')
24
- @condition.should_receive(:execute).with(@env).once.and_return(result)
25
- @object.execute(@env).should == 'false case'
26
- end
27
-
28
- it "should execute the condition if false and no false condition is given return nil" do
29
- @object = RVM::Interpreter::Condition.new(@condition, @true_case)
30
- result = mock('result mock')
31
- result.should_receive(:is_true?).with(no_args).once.and_return(false)
32
- @condition.should_receive(:execute).with(@env).once.and_return(result)
33
- @object.execute(@env).should be_nil
34
- end
35
-
36
- it "should return the type of it's cases if they are the same" do
37
- @true_case.should_receive(:data_type).with(no_args).once.and_return('type1')
38
- @false_case.should_receive(:data_type).with(no_args).at_least(:once).and_return('type1')
39
- @object.data_type.should == 'type1'
40
- end
41
-
42
- it "should return the :any type if the types are not the same" do
43
- @true_case.should_receive(:data_type).with(no_args).once.and_return('type1')
44
- @false_case.should_receive(:data_type).with(no_args).once.and_return('type2')
45
- @object.data_type.should == :any
46
- end
47
- end