rVM 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rake/helpers/code_statistics.rb +167 -0
- data/lib/rvm/classes.rb +4 -0
- data/lib/rvm/classes/string.rb +1 -0
- data/lib/rvm/functions/array.rb +3 -0
- data/lib/rvm/functions/array/set_at.rb +0 -4
- data/lib/rvm/functions/collection/size.rb +2 -2
- data/lib/rvm/functions/logic/and.rb +1 -1
- data/lib/rvm/functions/logic/or.rb +2 -2
- data/lib/rvm/interpreter.rb +84 -44
- data/lib/rvm/languages/ecma.rb +581 -501
- data/spec/base/class_spec.rb +27 -0
- data/spec/base/function_spec.rb +25 -0
- data/spec/base/interpreter/assignment_spec.rb +22 -0
- data/spec/base/interpreter/condition_spec.rb +47 -0
- data/spec/base/interpreter/constant_spec.rb +31 -0
- data/spec/base/interpreter/enviroment_spec.rb +51 -0
- data/spec/base/interpreter/function_call_spec.rb +72 -0
- data/spec/base/interpreter/interpreter_spec.rb +11 -0
- data/spec/base/interpreter/parameter_spec.rb +24 -0
- data/spec/base/interpreter/sequence_spec.rb +20 -0
- data/spec/base/interpreter/variable_spec.rb +24 -0
- data/spec/base/plugin_spec.rb +10 -0
- data/spec/classes/atom/association_spec.rb +39 -0
- data/spec/classes/atom/block_spec.rb +27 -0
- data/spec/classes/atom/boolean_spec.rb +67 -0
- data/spec/classes/atom/error_spec.rb +43 -0
- data/spec/classes/atom/list_spec.rb +68 -0
- data/spec/classes/atom/number_spec.rb +132 -0
- data/spec/classes/atom/string_spec.rb +175 -0
- data/spec/functions/association/assoc_get_spec.rb +41 -0
- data/spec/functions/association/assoc_set_spec.rb +43 -0
- data/spec/functions/collection/get_spec.rb +12 -0
- data/spec/functions/collection/set_spec.rb +10 -0
- data/spec/functions/collection/size_spec.rb +10 -0
- data/spec/functions/list/split_spec.rb +47 -0
- data/spec/functions/string/ansi_spec.rb +44 -0
- data/spec/functions/string/capstr_spec.rb +42 -0
- data/spec/functions/string/center_spec.rb +49 -0
- data/spec/functions/string/ljust_spec.rb +49 -0
- data/spec/functions/string/regmatch_spec.rb +52 -0
- data/spec/functions/string/rjust_spec.rb +49 -0
- data/spec/languages/ecma_spec.rb +337 -0
- data/spec/languages/math/compiler_spec.rb +49 -0
- data/spec/languages/math/tokenizer_spec.rb +73 -0
- data/spec/languages/math/tree_spec.rb +153 -0
- metadata +42 -5
@@ -0,0 +1,153 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '/../../../lib/rvm/languages/math/tree')
|
2
|
+
describe RVM::Languages::Math::Tree do
|
3
|
+
before do
|
4
|
+
@t = RVM::Languages::Math::Tree
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should handle numbers" do
|
8
|
+
@t.generate([['5', :number]]).should == {:type=>:number, :number=>"5"}
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should handle idents" do
|
12
|
+
@t.generate([['x', :ident]]).should == {:type => :ident, :ident => "x"}
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should handle opperators" do
|
16
|
+
@t.generate(
|
17
|
+
[['left', :ident], ['+', :opperator], ['right', :ident]]
|
18
|
+
).should == {
|
19
|
+
:type => :op,
|
20
|
+
:op => "+",
|
21
|
+
:left => {:type => :ident, :ident => "left"},
|
22
|
+
:right => {:type => :ident, :ident => "right"}
|
23
|
+
}
|
24
|
+
|
25
|
+
@t.generate(
|
26
|
+
[['left', :ident], ['+', :opperator], ['middle', :ident], ['-', :opperator], ['right', :ident]]
|
27
|
+
).should == {
|
28
|
+
:type => :op,
|
29
|
+
:op => "-",
|
30
|
+
:left => {
|
31
|
+
:type => :op,
|
32
|
+
:op => "+",
|
33
|
+
:left => {:type => :ident, :ident => "left"},
|
34
|
+
:right => {:type => :ident, :ident => "middle"}
|
35
|
+
},
|
36
|
+
:right => {:type => :ident, :ident => "right"}
|
37
|
+
}
|
38
|
+
|
39
|
+
@t.generate(
|
40
|
+
[["f", :function], ['x', :ident], [")", :paren_close], ['+', :opperator], ['right', :ident]]
|
41
|
+
).should == {
|
42
|
+
:type => :op,
|
43
|
+
:op => "+",
|
44
|
+
:left => {
|
45
|
+
:type => :function,
|
46
|
+
:op => "f",
|
47
|
+
:params => [
|
48
|
+
{:type => :ident, :ident => "x"},
|
49
|
+
]
|
50
|
+
},
|
51
|
+
:right => {:type => :ident, :ident => "right"}
|
52
|
+
}
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should handle opperators prioriteis" do
|
57
|
+
@t.generate(
|
58
|
+
[['left', :ident], ['+', :opperator], ['middle', :ident], ['*', :opperator], ['right', :ident]]
|
59
|
+
).should == {
|
60
|
+
:type => :op,
|
61
|
+
:op => "+",
|
62
|
+
:left => {:type => :ident, :ident => "left"},
|
63
|
+
:right => {
|
64
|
+
:type => :op,
|
65
|
+
:op => "*",
|
66
|
+
:left => {:type => :ident, :ident => "middle"},
|
67
|
+
:right => {:type => :ident, :ident => "right"}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should handle parenthets" do
|
73
|
+
@t.generate(
|
74
|
+
[["(", :paren_open], ['left', :ident], ['+', :opperator], ['middle', :ident], [")", :paren_close], ['*', :opperator], ['right', :ident]]
|
75
|
+
).should == {
|
76
|
+
:type => :op,
|
77
|
+
:op => "*",
|
78
|
+
:left => {
|
79
|
+
:type => :op,
|
80
|
+
:op => "+",
|
81
|
+
:left => {:type => :ident, :ident => "left"},
|
82
|
+
:right => {:type => :ident, :ident => "middle"}
|
83
|
+
},
|
84
|
+
:right => {:type => :ident, :ident => "right"}
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should handle functions" do
|
89
|
+
@t.generate(
|
90
|
+
[["f", :function], ['x', :ident], [")", :paren_close]]
|
91
|
+
).should == {
|
92
|
+
:type => :function,
|
93
|
+
:op => "f",
|
94
|
+
:params => [
|
95
|
+
{:type => :ident, :ident => "x"},
|
96
|
+
]
|
97
|
+
}
|
98
|
+
|
99
|
+
@t.generate(
|
100
|
+
[["f", :function], ['x', :ident], [',', :function_sep], ['y', :ident], [")", :paren_close]]
|
101
|
+
).should == {
|
102
|
+
:type => :function,
|
103
|
+
:op => "f",
|
104
|
+
:params => [
|
105
|
+
{:type => :ident, :ident => "y"},
|
106
|
+
{:type => :ident, :ident => "x"},
|
107
|
+
]
|
108
|
+
}
|
109
|
+
|
110
|
+
|
111
|
+
@t.generate(
|
112
|
+
[["f", :function], ['x', :ident], [',', :function_sep], ['y', :ident], [',', :function_sep], ['left', :ident], ['+', :opperator], ['right', :ident], [")", :paren_close]]
|
113
|
+
).should == {
|
114
|
+
:type => :function,
|
115
|
+
:op => "f",
|
116
|
+
:params => [
|
117
|
+
{
|
118
|
+
:type => :op,
|
119
|
+
:op => "+",
|
120
|
+
:left => {:type => :ident, :ident => "left"},
|
121
|
+
:right => {:type => :ident, :ident => "right"}
|
122
|
+
},
|
123
|
+
{:type => :ident, :ident => "y"},
|
124
|
+
{:type => :ident, :ident => "x"},
|
125
|
+
]
|
126
|
+
}
|
127
|
+
|
128
|
+
@t.generate(
|
129
|
+
[["f", :function], ['left', :ident], ['+', :opperator], ['right', :ident], [',', :function_sep], ['y', :ident], [',', :function_sep], ['x', :ident], [")", :paren_close]]
|
130
|
+
).should == {
|
131
|
+
:type => :function,
|
132
|
+
:op => "f",
|
133
|
+
:params => [
|
134
|
+
{:type => :ident, :ident => "x"},
|
135
|
+
{:type => :ident, :ident => "y"},
|
136
|
+
{
|
137
|
+
:type => :op,
|
138
|
+
:op => "+",
|
139
|
+
:left => {:type => :ident, :ident => "left"},
|
140
|
+
:right => {:type => :ident, :ident => "right"}
|
141
|
+
},
|
142
|
+
]
|
143
|
+
}
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should throw exeptions on unknown tokens" do
|
147
|
+
lambda{@t.generate([["haha", :not_good]])}.should raise_error
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should discard ; opperators without a right side" do
|
151
|
+
@t.generate([['x', :ident], [';', :opperator]]).should == {:type => :ident, :ident => "x"}
|
152
|
+
end
|
153
|
+
end
|
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.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Heinz N. Gies
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-07-
|
12
|
+
date: 2008-07-23 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -22,6 +22,9 @@ extensions: []
|
|
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
|
25
28
|
- lib/rvm
|
26
29
|
- lib/rvm/acts_as_rvm_type.rb
|
27
30
|
- lib/rvm/classes
|
@@ -127,10 +130,44 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
130
|
version:
|
128
131
|
requirements: []
|
129
132
|
|
130
|
-
rubyforge_project:
|
133
|
+
rubyforge_project: rvm
|
131
134
|
rubygems_version: 1.2.0
|
132
135
|
signing_key:
|
133
136
|
specification_version: 2
|
134
137
|
summary: A ruby based VM that lets one add secure scripting to ruby applications.
|
135
|
-
test_files:
|
136
|
-
|
138
|
+
test_files:
|
139
|
+
- spec/base/class_spec.rb
|
140
|
+
- spec/base/function_spec.rb
|
141
|
+
- spec/base/interpreter/assignment_spec.rb
|
142
|
+
- spec/base/interpreter/condition_spec.rb
|
143
|
+
- spec/base/interpreter/constant_spec.rb
|
144
|
+
- spec/base/interpreter/enviroment_spec.rb
|
145
|
+
- spec/base/interpreter/function_call_spec.rb
|
146
|
+
- spec/base/interpreter/interpreter_spec.rb
|
147
|
+
- spec/base/interpreter/parameter_spec.rb
|
148
|
+
- spec/base/interpreter/sequence_spec.rb
|
149
|
+
- spec/base/interpreter/variable_spec.rb
|
150
|
+
- spec/base/plugin_spec.rb
|
151
|
+
- spec/classes/atom/association_spec.rb
|
152
|
+
- spec/classes/atom/block_spec.rb
|
153
|
+
- spec/classes/atom/boolean_spec.rb
|
154
|
+
- spec/classes/atom/error_spec.rb
|
155
|
+
- spec/classes/atom/list_spec.rb
|
156
|
+
- spec/classes/atom/number_spec.rb
|
157
|
+
- spec/classes/atom/string_spec.rb
|
158
|
+
- spec/functions/association/assoc_get_spec.rb
|
159
|
+
- spec/functions/association/assoc_set_spec.rb
|
160
|
+
- spec/functions/collection/get_spec.rb
|
161
|
+
- spec/functions/collection/set_spec.rb
|
162
|
+
- spec/functions/collection/size_spec.rb
|
163
|
+
- spec/functions/list/split_spec.rb
|
164
|
+
- spec/functions/string/ansi_spec.rb
|
165
|
+
- spec/functions/string/capstr_spec.rb
|
166
|
+
- spec/functions/string/center_spec.rb
|
167
|
+
- spec/functions/string/ljust_spec.rb
|
168
|
+
- spec/functions/string/regmatch_spec.rb
|
169
|
+
- spec/functions/string/rjust_spec.rb
|
170
|
+
- spec/languages/ecma_spec.rb
|
171
|
+
- spec/languages/math/compiler_spec.rb
|
172
|
+
- spec/languages/math/tokenizer_spec.rb
|
173
|
+
- spec/languages/math/tree_spec.rb
|