codemodels-ruby 0.1.5-java
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.
- data/.gitignore +3 -0
- data/Gemfile +3 -0
- data/README.md +6 -0
- data/Rakefile +13 -0
- data/codemodels-ruby.gemspec +33 -0
- data/lib/codemodels/ruby.rb +12 -0
- data/lib/codemodels/ruby/code.rb +14 -0
- data/lib/codemodels/ruby/info_extraction.rb +100 -0
- data/lib/codemodels/ruby/language.rb +17 -0
- data/lib/codemodels/ruby/metamodel.rb +481 -0
- data/lib/codemodels/ruby/model_building.rb +36 -0
- data/lib/codemodels/ruby/parser.rb +809 -0
- data/lib/codemodels/ruby/query.rb +25 -0
- data/lib/jars/com.google.collect_1.0.0.v201105210816.jar +0 -0
- data/lib/jars/com.google.inject_2.0.0.v201105231817.jar +0 -0
- data/lib/jars/com.ibm.icu_4.4.2.v20110208.jar +0 -0
- data/lib/jars/org.apache.commons.lang_2.4.0.v201005080502.jar +0 -0
- data/lib/jars/org.apache.commons.logging_1.1.1.jar +0 -0
- data/lib/jars/org.apache.log4j_1.2.16.jar +0 -0
- data/lib/jars/org.eclipse.core.runtime.compatibility_3.2.100.v20100505.jar +0 -0
- data/lib/jars/org.eclipse.core.runtime_3.7.0.v20110110.jar +0 -0
- data/test/data/012_add_comments_permissions.rb +14 -0
- data/test/data/darcs_adapter.rb +242 -0
- data/test/data/example_of_complex_class.rb +157 -0
- data/test/data/issues_helper_test.rb +271 -0
- data/test/data/status_test.rb +14 -0
- data/test/data/user_custom_field.rb +23 -0
- data/test/helper.rb +87 -0
- data/test/test_assignments.rb +14 -0
- data/test/test_blocks.rb +102 -0
- data/test/test_constants.rb +14 -0
- data/test/test_exception_handling.rb +35 -0
- data/test/test_info.rb +52 -0
- data/test/test_logic.rb +61 -0
- data/test/test_metamodel.rb +70 -0
- data/test/test_modules_and_classes.rb +81 -0
- data/test/test_not_variable_assignements.rb +75 -0
- data/test/test_operations.rb +440 -0
- data/test/test_parsing_complex.rb +49 -0
- data/test/test_parsing_literals.rb +92 -0
- data/test/test_statements.rb +169 -0
- data/test/test_terms_extraction.rb +240 -0
- data/test/test_values_extraction.rb +102 -0
- data/test/test_variables.rb +81 -0
- metadata +272 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestOperations < Test::Unit::TestCase
|
4
|
+
|
5
|
+
include TestHelper
|
6
|
+
include LightModels
|
7
|
+
include LightModels::Ruby
|
8
|
+
|
9
|
+
def test_load_complex_file
|
10
|
+
|
11
|
+
content = IO.read(File.dirname(__FILE__)+'/data/example_of_complex_class.rb')
|
12
|
+
root = Ruby.parse(content)
|
13
|
+
|
14
|
+
assert_right_class root, Ruby::Block
|
15
|
+
assert_equal 4, root.contents.count
|
16
|
+
assert Ruby.is_call(root.contents[0],'require',[Ruby::string('helper')])
|
17
|
+
assert Ruby.is_call(root.contents[1],'require',[Ruby::string('test/unit')])
|
18
|
+
assert Ruby.is_call(root.contents[2],'require',[Ruby::string('ruby-lightmodels')])
|
19
|
+
def_of_TestOperations = root.contents[3]
|
20
|
+
|
21
|
+
# class TestOperations
|
22
|
+
assert_right_class def_of_TestOperations, Ruby::ClassDecl
|
23
|
+
assert_equal Ruby.constant('Test','Unit','TestCase'),def_of_TestOperations.super_class
|
24
|
+
assert_equal 19,def_of_TestOperations.contents.count
|
25
|
+
|
26
|
+
# TestOperations test_symbol
|
27
|
+
t_symbol = def_of_TestOperations.contents[0]
|
28
|
+
assert Ruby.is_def(t_symbol,'test_symbol')
|
29
|
+
assert_equal 3,t_symbol.body.contents.count
|
30
|
+
|
31
|
+
st = t_symbol.body.contents[0]
|
32
|
+
assert_right_class st, Ruby::LocalVarAssignment
|
33
|
+
assert_equal 'root',st.name_assigned
|
34
|
+
assert_node st.value, ExplicitReceiverCall, name: 'parse',
|
35
|
+
args: [Ruby.string(':a')],
|
36
|
+
receiver: Ruby.constant('Ruby')
|
37
|
+
|
38
|
+
st = t_symbol.body.contents[1]
|
39
|
+
assert_node st, ImplicitReceiverCall, name: 'assert_right_class',
|
40
|
+
args: [LocalVarAccess.build('root'),Ruby.constant('Ruby','Symbol')],
|
41
|
+
receiver: nil
|
42
|
+
|
43
|
+
st = t_symbol.body.contents[2]
|
44
|
+
call_root_name = ImplicitReceiverCall.build name: 'name', args: [], receiver: LocalVarAccess.build('root'),
|
45
|
+
args: [Ruby.string('a'),call_root_name],
|
46
|
+
receiver: nil
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestOperations < Test::Unit::TestCase
|
4
|
+
|
5
|
+
include TestHelper
|
6
|
+
include LightModels
|
7
|
+
|
8
|
+
def test_symbol
|
9
|
+
root = Ruby.parse(':a')
|
10
|
+
|
11
|
+
assert_right_class root, Ruby::Symbol
|
12
|
+
assert_equal 'a',root.name
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_false
|
16
|
+
root = Ruby.parse('false')
|
17
|
+
|
18
|
+
assert_right_class root, Ruby::BooleanLiteral
|
19
|
+
assert_equal false,root.value
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_dstring
|
23
|
+
root = Ruby.parse("\"some string\"")
|
24
|
+
|
25
|
+
assert_right_class root, Ruby::StringLiteral
|
26
|
+
assert_equal 'some string', root.value
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_dstring_with_value
|
30
|
+
root = Ruby.parse('/^#{Regexp.escape(operator)}(.*)$/')
|
31
|
+
|
32
|
+
assert_right_class root, Ruby::RegExpLiteral
|
33
|
+
assert_equal 3, root.pieces.count
|
34
|
+
assert_is_str root.pieces[0],'^'
|
35
|
+
assert_is_str root.pieces[2],'(.*)$'
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_dregexp_with_value
|
39
|
+
root = Ruby.parse('"some #{val} string"')
|
40
|
+
|
41
|
+
assert_right_class root, Ruby::DynamicStringLiteral
|
42
|
+
assert_equal 3, root.pieces.count
|
43
|
+
assert_is_str root.pieces[0],'some '
|
44
|
+
assert_is_str root.pieces[2],' string'
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_true
|
48
|
+
root = Ruby.parse('true')
|
49
|
+
|
50
|
+
assert_right_class root, Ruby::BooleanLiteral
|
51
|
+
assert_equal true,root.value
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_nil
|
55
|
+
root = Ruby.parse('nil')
|
56
|
+
|
57
|
+
assert_right_class root, Ruby::NilLiteral
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_float
|
61
|
+
root = Ruby.parse('12.3')
|
62
|
+
|
63
|
+
assert_node root,Ruby::FloatLiteral,
|
64
|
+
value: 12.3
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_regexp
|
68
|
+
root = Ruby.parse'/^[a-z]*/'
|
69
|
+
|
70
|
+
assert_node root,Ruby::RegExpLiteral,
|
71
|
+
value: '^[a-z]*'
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_cmd_line_str
|
75
|
+
root = Ruby.parse '`svn info --xml #{path}`'
|
76
|
+
|
77
|
+
assert_right_class root, Ruby::CmdLineStringLiteral
|
78
|
+
assert_equal 2, root.pieces.count
|
79
|
+
assert_is_str root.pieces[0],'svn info --xml '
|
80
|
+
assert_node root.pieces[1], Ruby::Call, name:'path'
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_dynamic_symbol
|
84
|
+
root = Ruby.parse ':"cf_#{visible_field.id}"'
|
85
|
+
|
86
|
+
assert_right_class root, Ruby::DynamicSymbol
|
87
|
+
assert_equal 2, root.pieces.count
|
88
|
+
assert_is_str root.pieces[0],'cf_'
|
89
|
+
assert_node root.pieces[1], Ruby::Call, name:'id'
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestOperations < Test::Unit::TestCase
|
4
|
+
|
5
|
+
include TestHelper
|
6
|
+
include LightModels
|
7
|
+
|
8
|
+
def test_alias
|
9
|
+
root = Ruby.parse("alias pippo display")
|
10
|
+
|
11
|
+
assert_node root, Ruby::AliasStatement,
|
12
|
+
new_name: LiteralReference.build('pippo'),
|
13
|
+
old_name: LiteralReference.build('display')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_case_single_when
|
17
|
+
r = Ruby.parse("case v; when 'A'; 1;end")
|
18
|
+
|
19
|
+
assert_node r, Ruby::CaseStatement, else_body: nil
|
20
|
+
assert_equal 1, r.when_clauses.count
|
21
|
+
assert_node r.when_clauses[0], Ruby::WhenClause, condition: Ruby.string('A'), body: Ruby.int(1)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_case_two_whens
|
25
|
+
r = Ruby.parse("case v; when 'A'; 1; when 'B'; 2; end")
|
26
|
+
|
27
|
+
assert_node r, Ruby::CaseStatement, else_body: nil
|
28
|
+
assert_equal 2, r.when_clauses.count
|
29
|
+
assert_node r.when_clauses[0], Ruby::WhenClause, condition: Ruby.string('A'), body: Ruby.int(1)
|
30
|
+
assert_node r.when_clauses[1], Ruby::WhenClause, condition: Ruby.string('B'), body: Ruby.int(2)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_case_two_whens_and_else
|
34
|
+
r = Ruby.parse("case v; when 'A'; 1; when 'B'; 2; else; 3; end")
|
35
|
+
|
36
|
+
assert_node r, Ruby::CaseStatement, else_body: Ruby.int(3)
|
37
|
+
assert_equal 2, r.when_clauses.count
|
38
|
+
assert_node r.when_clauses[0], Ruby::WhenClause, condition: Ruby.string('A'), body: Ruby.int(1)
|
39
|
+
assert_node r.when_clauses[1], Ruby::WhenClause, condition: Ruby.string('B'), body: Ruby.int(2)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_while_pre
|
43
|
+
r = Ruby.parse('while 1; 2; end')
|
44
|
+
|
45
|
+
assert_node r, Ruby::WhileStatement, condition: Ruby.int(1), body: Ruby.int(2)#, type: :prefixed
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_while_post
|
49
|
+
r = Ruby.parse('2 while 1')
|
50
|
+
|
51
|
+
assert_node r, Ruby::WhileStatement, condition: Ruby.int(1), body: Ruby.int(2)#, type: :postfixed
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_until_pre
|
55
|
+
r = Ruby.parse('until 1; 2; end')
|
56
|
+
|
57
|
+
assert_node r, Ruby::UntilStatement, condition: Ruby.int(1), body: Ruby.int(2)#, type: :prefixed
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_until_post
|
61
|
+
r = Ruby.parse('2 until 1')
|
62
|
+
|
63
|
+
assert_node r, Ruby::UntilStatement, condition: Ruby.int(1), body: Ruby.int(2)#, type: :postfixed
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_if_pre
|
67
|
+
r = Ruby.parse('if 1; 2; end')
|
68
|
+
|
69
|
+
assert_node r, Ruby::IfStatement, condition: Ruby.int(1), then_body: Ruby.int(2), else_body: nil
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_if_pre_with_else
|
73
|
+
r = Ruby.parse('if 1; 2; else; 3; end')
|
74
|
+
|
75
|
+
assert_node r, Ruby::IfStatement, condition: Ruby.int(1), then_body: Ruby.int(2), else_body: Ruby.int(3)
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_if_post
|
79
|
+
r = Ruby.parse('2 if 1')
|
80
|
+
|
81
|
+
assert_node r, Ruby::IfStatement, condition: Ruby.int(1), then_body: Ruby.int(2), else_body: nil
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_termary_operator
|
85
|
+
r = Ruby.parse('1 ? 2 : 3')
|
86
|
+
|
87
|
+
assert_node r, Ruby::IfStatement, condition: Ruby.int(1), then_body: Ruby.int(2), else_body: Ruby.int(3)
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_unless_pre
|
91
|
+
r = Ruby.parse('unless 1; 2; end')
|
92
|
+
|
93
|
+
assert_node r, Ruby::IfStatement, condition: Ruby.int(1), then_body:nil, else_body: Ruby.int(2)
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_unless_pre_with_else
|
97
|
+
r = Ruby.parse('unless 1; 2; else; 3; end')
|
98
|
+
|
99
|
+
assert_node r, Ruby::IfStatement, condition: Ruby.int(1), then_body: Ruby.int(3), else_body: Ruby.int(2)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_unless_post
|
103
|
+
r = Ruby.parse('2 unless 1')
|
104
|
+
|
105
|
+
assert_node r, Ruby::IfStatement, condition: Ruby.int(1), then_body:nil, else_body: Ruby.int(2)
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_undef
|
109
|
+
r = Ruby.parse('undef pippo')
|
110
|
+
|
111
|
+
assert_node r, Ruby::UndefStatement, name: Ruby::LiteralReference.build('pippo')
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_inline_rescue
|
115
|
+
r = Ruby.parse('1 rescue 2')
|
116
|
+
|
117
|
+
assert_node r, Ruby::RescueStatement, body: Ruby.int(1), value: Ruby::int(2)
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_break
|
121
|
+
r = Ruby.parse('break')
|
122
|
+
|
123
|
+
assert_node r, Ruby::BreakStatement
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_defined
|
127
|
+
r = Ruby.parse('defined? mymethod')
|
128
|
+
|
129
|
+
assert_node r, Ruby::IsDefined
|
130
|
+
assert_node r.value, Ruby::Call, name: 'mymethod'
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_call_no_receiver_no_params
|
134
|
+
r = Ruby.parse('using_open_id?')
|
135
|
+
|
136
|
+
assert_node r, Ruby::Call, name:'using_open_id?', args:[]
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_call_only_iter
|
140
|
+
r = Ruby.parse('respond_to do |format| 1; end')
|
141
|
+
|
142
|
+
assert_node r, Ruby::Call, name:'respond_to', args:[]
|
143
|
+
assert_node r.block_arg, Ruby::CodeBlock
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_call_iter_and_args
|
147
|
+
r = Ruby.parse('respond_to(1,2) do |format| 1; end')
|
148
|
+
|
149
|
+
assert_node r, Ruby::Call, name:'respond_to', args:[Ruby.int(1),Ruby.int(2)]
|
150
|
+
assert_node r.block_arg, Ruby::CodeBlock
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_call_splat_and_block
|
154
|
+
r = Ruby.parse('form_for(*args, &proc)')
|
155
|
+
|
156
|
+
assert_node r, Ruby::Call, name:'form_for'
|
157
|
+
assert_equal 1, r.args.count
|
158
|
+
assert_node r.args[0], Ruby::Splat
|
159
|
+
assert_node r.args[0].splatted, Ruby::Call, name: 'args'
|
160
|
+
assert_node r.block_arg, Ruby::BlockReference
|
161
|
+
assert_node r.block_arg.value, Ruby::Call, name: 'proc'
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_for
|
165
|
+
r = Ruby.parse 'for a in 2; 3; end'
|
166
|
+
assert_node r, Ruby::ForStatement, collection: Ruby.int(2), iterator: Ruby::LocalVarAssignment.build('a'), body: Ruby.int(3)
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
@@ -0,0 +1,240 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestTermsExtraction < Test::Unit::TestCase
|
4
|
+
|
5
|
+
include LightModels
|
6
|
+
include LightModels::Ruby
|
7
|
+
include TestHelper
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@addCommentsPermissions_model_node = Ruby.parse_code(read_test_data('012_add_comments_permissions.rb'))
|
11
|
+
@userCustomField_model_node = Ruby.parse_code(read_test_data('user_custom_field.rb'))
|
12
|
+
@statusTest_model_node = Ruby.parse_code(read_test_data('status_test.rb'))
|
13
|
+
@issuesHelperTest_model_node = Ruby.parse_code(read_test_data('issues_helper_test.rb'))
|
14
|
+
@darcsAdapter_model_node = Ruby.parse_code(read_test_data('darcs_adapter.rb'))
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_info_extraction_addCommentsPermissions_method_1
|
18
|
+
m = @addCommentsPermissions_model_node.contents[1]
|
19
|
+
assert_node m,Def,{name: 'up'}
|
20
|
+
assert_map_equal(
|
21
|
+
{'up'=>1, 'permission'=>2,'create'=>2,'controller'=>2,'news'=>2,
|
22
|
+
'action'=>2,'add'=>2,'delete'=>1,'comment'=>4,
|
23
|
+
'destroy'=>1,
|
24
|
+
'description'=>2,'label'=>2,'sort'=>2,'1130'=>1,'1133'=>1,
|
25
|
+
'is_public'=>2,'false'=>2,'option'=>2,'enabled'=>2,'0'=>4,'mail'=>4},
|
26
|
+
m.terms_map)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_info_extraction_addCommentsPermissions_method_2
|
30
|
+
m = @addCommentsPermissions_model_node.contents[2]
|
31
|
+
assert_node m,Def,{name: 'down'}
|
32
|
+
assert_map_equal(
|
33
|
+
{'down'=>1, 'permission'=>2,'where'=>2,'first'=>2,'destroy'=>3,
|
34
|
+
'controller=? and action=?'=>2,'news'=>2,
|
35
|
+
'add'=>1,'comment'=>2},
|
36
|
+
m.terms_map)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_info_extraction_userCustomField_method_1
|
40
|
+
m = @userCustomField_model_node.contents[0]
|
41
|
+
assert_node m,Def,{name: 'type_name'}
|
42
|
+
assert_map_equal(
|
43
|
+
{'type_name'=>1,'label'=>1,'user'=>1,'plural'=>1},
|
44
|
+
m.terms_map)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_info_extraction_userCustomField_class
|
48
|
+
m = @userCustomField_model_node
|
49
|
+
assert_map_equal(
|
50
|
+
{'type_name'=>1,'label'=>1,'user'=>2,'plural'=>1,'custom_field'=>2},
|
51
|
+
m.terms_map)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_info_extraction_statusTest_method_1
|
55
|
+
m = @statusTest_model_node.contents[1].contents[1]
|
56
|
+
assert_node m,Def,{name: 'test_state_conditional'}
|
57
|
+
#puts "#{LightModels::Serialization.jsonize_obj(m)}"
|
58
|
+
assert_map_equal(
|
59
|
+
{'test'=>1,'state_conditional'=>1,
|
60
|
+
'assert'=>5,'result'=>5,
|
61
|
+
'missing'=>4,'successful'=>4,'unsuccessful'=>2,
|
62
|
+
'[]'=>5,'!'=>2},
|
63
|
+
m.terms_map)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_info_extraction_issuesHelperTest_method_1
|
67
|
+
m = @issuesHelperTest_model_node.contents[1].contents[32]
|
68
|
+
assert_node m,Def,{name: 'test_show_detail_relation_added_with_inexistant_issue'}
|
69
|
+
assert_map_equal(
|
70
|
+
{"9999"=>1, #
|
71
|
+
"inexistant"=>6, #
|
72
|
+
"issue"=>7, #
|
73
|
+
"number"=>5, #
|
74
|
+
"find"=>1, #
|
75
|
+
"by"=>1, #
|
76
|
+
"id"=>1, #
|
77
|
+
"assert"=>3, #
|
78
|
+
"nil"=>1, #
|
79
|
+
"property"=>1, #
|
80
|
+
"relation"=>2, #
|
81
|
+
"prop_key"=>1, #
|
82
|
+
"label_precedes"=>1, #
|
83
|
+
"value"=>1, #
|
84
|
+
"journal"=>1, #
|
85
|
+
"detail"=>7, #
|
86
|
+
"new"=>1, #
|
87
|
+
"Precedes Issue #"=>1, #
|
88
|
+
"added"=>2, #
|
89
|
+
"true"=>1, #
|
90
|
+
"show"=>3, #
|
91
|
+
"equal"=>2, #
|
92
|
+
"<strong>Precedes</strong> <i>Issue #"=>1, #
|
93
|
+
"</i> added"=>1, #
|
94
|
+
"false"=>1, #
|
95
|
+
"test"=>1, #
|
96
|
+
"with"=>1}, #
|
97
|
+
m.terms_map)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_info_extraction_issuesHelperTest_method_2
|
101
|
+
m = @issuesHelperTest_model_node.contents[1].contents[34]
|
102
|
+
assert_node m,Def,{name: 'test_show_detail_relation_deleted'}
|
103
|
+
assert_map_equal(
|
104
|
+
{
|
105
|
+
"assert"=>2, #
|
106
|
+
"match"=>1, #
|
107
|
+
"property"=>1, #
|
108
|
+
"relation"=>2, #
|
109
|
+
"prop_key"=>1, #
|
110
|
+
"label_precedes"=>1, #
|
111
|
+
"1"=>1, #
|
112
|
+
'old'=>1,#
|
113
|
+
"value"=>1, #
|
114
|
+
"journal"=>1, #
|
115
|
+
"detail"=>7, #
|
116
|
+
"new"=>1, #
|
117
|
+
"Precedes deleted (Bug #1: Can't print recipes)"=>1, #
|
118
|
+
"deleted"=>1, #
|
119
|
+
"true"=>1, #
|
120
|
+
"show"=>3, #
|
121
|
+
"equal"=>1, #
|
122
|
+
%q{<strong>Precedes</strong> deleted \(<i><a href="/issues/1" class=".+">Bug #1</a>: Can't print recipes</i>\)}=>1, #
|
123
|
+
"false"=>1, #
|
124
|
+
"test"=>1 },
|
125
|
+
m.terms_map)
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_info_extraction_darcsAdapter_method_1
|
129
|
+
m = @darcsAdapter_model_node.contents[2].contents[0].contents[0].contents[0].contents[4]
|
130
|
+
assert_node m,Def,{name: 'info'}
|
131
|
+
assert_map_equal(
|
132
|
+
{
|
133
|
+
'info'=>2,
|
134
|
+
'rev'=>3,
|
135
|
+
'revisions'=>1,
|
136
|
+
'limit'=>1,
|
137
|
+
'1'=>1,
|
138
|
+
'new'=>1,
|
139
|
+
'root'=>1,
|
140
|
+
'url'=>2,
|
141
|
+
'lastrev'=>1,
|
142
|
+
'last'=>1
|
143
|
+
},m.terms_map)
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_info_extraction_darcsAdapter_method_2
|
147
|
+
m = @darcsAdapter_model_node.contents[2].contents[0].contents[0].contents[0].contents[5]
|
148
|
+
assert_node m,Def,{name: 'entries'}
|
149
|
+
assert_map_equal(
|
150
|
+
{
|
151
|
+
'entries'=>7,
|
152
|
+
'new'=>2,
|
153
|
+
'identifier'=>3,
|
154
|
+
'options'=>1,
|
155
|
+
'path'=>9,
|
156
|
+
'prefix'=>3,
|
157
|
+
'' => 2,
|
158
|
+
'/'=> 1,
|
159
|
+
'blank'=>2,
|
160
|
+
'class'=>2,
|
161
|
+
'client_version'=>1,
|
162
|
+
'above'=>1,
|
163
|
+
'2'=>2,
|
164
|
+
'0'=>2,
|
165
|
+
'url'=>2,
|
166
|
+
'.'=>1,
|
167
|
+
'cmd'=>4,
|
168
|
+
'sq_bin'=>1,
|
169
|
+
'annotate --repodir'=>1,
|
170
|
+
'shell_quote'=>3,
|
171
|
+
'--xml-output'=>1,
|
172
|
+
'--match'=>1,
|
173
|
+
'hash'=>1,
|
174
|
+
'shellout'=>1,
|
175
|
+
'io'=>2,
|
176
|
+
'doc'=>5,
|
177
|
+
'root'=>3,
|
178
|
+
'name'=>4,
|
179
|
+
'directory'=>2,
|
180
|
+
'element'=>3,
|
181
|
+
'elements'=>1,
|
182
|
+
'each'=>1,
|
183
|
+
'file'=>2,
|
184
|
+
'include'=>1,
|
185
|
+
'directory/*'=>1,
|
186
|
+
'rexml'=>1,
|
187
|
+
'document'=>1,
|
188
|
+
'entry'=>2,
|
189
|
+
'from'=>2,
|
190
|
+
'xml'=>2,
|
191
|
+
'?'=>2,
|
192
|
+
'exitstatus'=>1,
|
193
|
+
'compact'=>1,
|
194
|
+
'sort_by'=>1,
|
195
|
+
'<<'=>4,
|
196
|
+
'=='=>2,
|
197
|
+
'!='=>1
|
198
|
+
},m.terms_map)
|
199
|
+
end
|
200
|
+
|
201
|
+
def test_option_name_example
|
202
|
+
code = %q{
|
203
|
+
def option_name
|
204
|
+
OptionName
|
205
|
+
end
|
206
|
+
}
|
207
|
+
m = Ruby.parse_code(code)
|
208
|
+
assert_node m,Def,{name: 'option_name'}
|
209
|
+
assert_map_equal(
|
210
|
+
{
|
211
|
+
'option_name'=>2
|
212
|
+
},m.terms_map)
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_comment_sorting_example
|
216
|
+
code = %q{
|
217
|
+
def comments_sorting; self[:comments_sorting] end
|
218
|
+
}
|
219
|
+
m = Ruby.parse_code(code)
|
220
|
+
assert_node m,Def,{name: 'comments_sorting'}
|
221
|
+
assert_map_equal(
|
222
|
+
{
|
223
|
+
'comments_sorting'=>2, '[]'=>1
|
224
|
+
},m.terms_map)
|
225
|
+
end
|
226
|
+
|
227
|
+
def test_comment_sorting_assign_example
|
228
|
+
code = %q{
|
229
|
+
def comments_sorting=(order); self[:comments_sorting]=order end
|
230
|
+
}
|
231
|
+
m = Ruby.parse_code(code)
|
232
|
+
assert_node m,Def,{name: 'comments_sorting='}
|
233
|
+
assert_map_equal(
|
234
|
+
{
|
235
|
+
'comments_sorting'=>2,
|
236
|
+
'order' => 2
|
237
|
+
},m.terms_map)
|
238
|
+
end
|
239
|
+
|
240
|
+
end
|