ruby-lint 0.0.1a → 0.0.1a1
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +1 -1
- data/MANIFEST +65 -62
- data/README.md +114 -13
- data/bin/ruby-lint +6 -0
- data/lib/ruby-lint.rb +36 -0
- data/lib/{rlint → ruby-lint}/analyze/coding_style.rb +32 -32
- data/lib/{rlint → ruby-lint}/analyze/definitions.rb +13 -13
- data/lib/{rlint → ruby-lint}/analyze/method_validation.rb +5 -5
- data/lib/{rlint → ruby-lint}/analyze/shadowing_variables.rb +5 -5
- data/lib/{rlint → ruby-lint}/analyze/undefined_variables.rb +7 -7
- data/lib/{rlint → ruby-lint}/analyze/unused_variables.rb +6 -6
- data/lib/{rlint → ruby-lint}/callback.rb +11 -11
- data/lib/{rlint → ruby-lint}/cli.rb +17 -17
- data/lib/{rlint → ruby-lint}/constant_importer.rb +18 -8
- data/lib/{rlint → ruby-lint}/definition.rb +10 -10
- data/lib/{rlint → ruby-lint}/formatter/text.rb +6 -6
- data/lib/{rlint → ruby-lint}/helper/definition_resolver.rb +11 -11
- data/lib/{rlint → ruby-lint}/helper/scoping.rb +14 -14
- data/lib/{rlint → ruby-lint}/iterator.rb +22 -22
- data/lib/{rlint → ruby-lint}/options.rb +9 -9
- data/lib/{rlint → ruby-lint}/parser.rb +111 -111
- data/lib/{rlint → ruby-lint}/parser_error.rb +3 -3
- data/lib/{rlint → ruby-lint}/report.rb +8 -8
- data/lib/{rlint → ruby-lint}/token/assignment_token.rb +4 -4
- data/lib/{rlint → ruby-lint}/token/begin_rescue_token.rb +7 -7
- data/lib/{rlint → ruby-lint}/token/block_token.rb +12 -3
- data/lib/{rlint → ruby-lint}/token/case_token.rb +5 -5
- data/lib/{rlint → ruby-lint}/token/class_token.rb +3 -3
- data/lib/{rlint → ruby-lint}/token/method_definition_token.rb +8 -8
- data/lib/{rlint → ruby-lint}/token/method_token.rb +9 -7
- data/lib/{rlint → ruby-lint}/token/parameters_token.rb +6 -6
- data/lib/{rlint → ruby-lint}/token/regexp_token.rb +2 -2
- data/lib/{rlint → ruby-lint}/token/statement_token.rb +6 -6
- data/lib/{rlint → ruby-lint}/token/token.rb +8 -6
- data/lib/{rlint → ruby-lint}/token/variable_token.rb +3 -3
- data/lib/ruby-lint/version.rb +3 -0
- data/ruby-lint.gemspec +5 -5
- data/spec/benchmarks/memory.rb +7 -7
- data/spec/benchmarks/parse_parser.rb +5 -5
- data/spec/fixtures/stdlib/un.rb +348 -0
- data/spec/helper.rb +3 -1
- data/spec/{rlint → ruby-lint}/analyze/coding_style.rb +30 -30
- data/spec/ruby-lint/analyze/complex/un.rb +29 -0
- data/spec/{rlint → ruby-lint}/analyze/definitions/classes.rb +25 -25
- data/spec/{rlint → ruby-lint}/analyze/definitions/methods.rb +22 -22
- data/spec/{rlint → ruby-lint}/analyze/definitions/modules.rb +42 -42
- data/spec/{rlint → ruby-lint}/analyze/definitions/variables.rb +27 -27
- data/spec/{rlint → ruby-lint}/analyze/method_validation.rb +31 -31
- data/spec/{rlint → ruby-lint}/analyze/shadowing_variables.rb +6 -6
- data/spec/{rlint → ruby-lint}/analyze/undefined_variables.rb +37 -37
- data/spec/{rlint → ruby-lint}/analyze/unused_variables.rb +21 -21
- data/spec/{rlint → ruby-lint}/callback.rb +7 -7
- data/spec/{rlint → ruby-lint}/constant_importer.rb +6 -6
- data/spec/{rlint → ruby-lint}/definition.rb +25 -25
- data/spec/{rlint → ruby-lint}/formatter/text.rb +4 -4
- data/spec/{rlint → ruby-lint}/iterator.rb +38 -38
- data/spec/{rlint → ruby-lint}/parser/arrays.rb +28 -28
- data/spec/{rlint → ruby-lint}/parser/classes.rb +23 -23
- data/spec/{rlint → ruby-lint}/parser/errors.rb +4 -4
- data/spec/{rlint → ruby-lint}/parser/hashes.rb +24 -24
- data/spec/{rlint → ruby-lint}/parser/methods.rb +50 -50
- data/spec/{rlint → ruby-lint}/parser/modules.rb +8 -8
- data/spec/{rlint → ruby-lint}/parser/objects.rb +8 -8
- data/spec/{rlint → ruby-lint}/parser/operators.rb +14 -14
- data/spec/{rlint → ruby-lint}/parser/procs.rb +26 -26
- data/spec/{rlint → ruby-lint}/parser/ranges.rb +9 -9
- data/spec/{rlint → ruby-lint}/parser/regexp.rb +5 -5
- data/spec/{rlint → ruby-lint}/parser/scalars.rb +17 -17
- data/spec/{rlint → ruby-lint}/parser/statements.rb +94 -94
- data/spec/{rlint → ruby-lint}/parser/variables.rb +37 -37
- data/spec/{rlint → ruby-lint}/report.rb +4 -4
- data/task/manifest.rake +8 -0
- data/task/test.rake +1 -1
- metadata +69 -66
- data/bin/rlint +0 -6
- data/lib/rlint.rb +0 -36
- data/lib/rlint/version.rb +0 -3
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path('../../../helper', __FILE__)
|
2
2
|
|
3
|
-
describe '
|
3
|
+
describe 'RubyLint::Parser' do
|
4
4
|
it 'Parse a module' do
|
5
5
|
code = <<-CODE
|
6
6
|
module Foo
|
@@ -10,9 +10,9 @@ module Foo
|
|
10
10
|
end
|
11
11
|
CODE
|
12
12
|
|
13
|
-
token =
|
13
|
+
token = RubyLint::Parser.new(code).parse[0]
|
14
14
|
|
15
|
-
token.class.should ==
|
15
|
+
token.class.should == RubyLint::Token::Token
|
16
16
|
token.type.should == :module
|
17
17
|
token.name.should == ['Foo']
|
18
18
|
token.line.should == 1
|
@@ -21,14 +21,14 @@ end
|
|
21
21
|
token.value.class.should == Array
|
22
22
|
token.value.length.should == 1
|
23
23
|
|
24
|
-
token.value[0].class.should ==
|
24
|
+
token.value[0].class.should == RubyLint::Token::MethodDefinitionToken
|
25
25
|
token.value[0].name.should == 'foo'
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'Parse a module with multiple name segments' do
|
29
|
-
token =
|
29
|
+
token = RubyLint::Parser.new('module A::B; end').parse[0]
|
30
30
|
|
31
|
-
token.class.should ==
|
31
|
+
token.class.should == RubyLint::Token::Token
|
32
32
|
token.type.should == :module
|
33
33
|
token.name.should == ['A', 'B']
|
34
34
|
|
@@ -37,9 +37,9 @@ end
|
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'Parse a top level module' do
|
40
|
-
token =
|
40
|
+
token = RubyLint::Parser.new('module ::A::B; end').parse[0]
|
41
41
|
|
42
|
-
token.class.should ==
|
42
|
+
token.class.should == RubyLint::Token::Token
|
43
43
|
token.type.should == :module
|
44
44
|
token.name.should == ['A', 'B']
|
45
45
|
|
@@ -1,18 +1,18 @@
|
|
1
1
|
require File.expand_path('../../../helper', __FILE__)
|
2
2
|
|
3
|
-
describe '
|
3
|
+
describe 'RubyLint::Parser' do
|
4
4
|
it 'Parse the reference of an object attribute' do
|
5
5
|
code = <<-CODE
|
6
6
|
obj = Struct.new(:name).new('Ruby')
|
7
7
|
obj.name
|
8
8
|
CODE
|
9
9
|
|
10
|
-
token =
|
10
|
+
token = RubyLint::Parser.new(code).parse[1]
|
11
11
|
|
12
|
-
token.class.should ==
|
12
|
+
token.class.should == RubyLint::Token::MethodToken
|
13
13
|
token.name.should == 'name'
|
14
14
|
|
15
|
-
token.receiver.class.should ==
|
15
|
+
token.receiver.class.should == RubyLint::Token::VariableToken
|
16
16
|
token.receiver.name.should == 'obj'
|
17
17
|
token.receiver.type.should == :local_variable
|
18
18
|
end
|
@@ -23,16 +23,16 @@ obj = Struct.new(:name).new('Ruby')
|
|
23
23
|
obj.name = 'Ruby'
|
24
24
|
CODE
|
25
25
|
|
26
|
-
token =
|
26
|
+
token = RubyLint::Parser.new(code).parse[1]
|
27
27
|
|
28
|
-
token.class.should ==
|
28
|
+
token.class.should == RubyLint::Token::AssignmentToken
|
29
29
|
token.name.should == 'name'
|
30
30
|
|
31
|
-
token.value.class.should ==
|
31
|
+
token.value.class.should == RubyLint::Token::Token
|
32
32
|
token.value.type.should == :string
|
33
33
|
token.value.value.should == 'Ruby'
|
34
34
|
|
35
|
-
token.receiver.class.should ==
|
35
|
+
token.receiver.class.should == RubyLint::Token::VariableToken
|
36
36
|
token.receiver.name.should == 'obj'
|
37
37
|
token.receiver.type.should == :local_variable
|
38
38
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require File.expand_path('../../../helper', __FILE__)
|
2
2
|
|
3
|
-
describe '
|
3
|
+
describe 'RubyLint::Parser' do
|
4
4
|
it 'Parse the use of various operators' do
|
5
5
|
['*', '-', '+', '/', '%', '^'].each do |operator|
|
6
|
-
token =
|
6
|
+
token = RubyLint::Parser.new("10 #{operator} 2").parse[0]
|
7
7
|
|
8
|
-
token.class.should ==
|
8
|
+
token.class.should == RubyLint::Token::Token
|
9
9
|
token.type.should == :binary
|
10
10
|
|
11
11
|
token.value.class.should == Array
|
@@ -13,22 +13,22 @@ describe 'Rlint::Parser' do
|
|
13
13
|
|
14
14
|
left, op, right = token.value
|
15
15
|
|
16
|
-
left.class.should ==
|
16
|
+
left.class.should == RubyLint::Token::Token
|
17
17
|
left.type.should == :integer
|
18
18
|
left.value.should == '10'
|
19
19
|
|
20
20
|
op.should == operator.to_sym
|
21
21
|
|
22
|
-
right.class.should ==
|
22
|
+
right.class.should == RubyLint::Token::Token
|
23
23
|
right.type.should == :integer
|
24
24
|
right.value.should == '2'
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'Parse the use of multiple operators' do
|
29
|
-
token =
|
29
|
+
token = RubyLint::Parser.new('10 and 20 and 30').parse[0]
|
30
30
|
|
31
|
-
token.class.should ==
|
31
|
+
token.class.should == RubyLint::Token::Token
|
32
32
|
token.type.should == :binary
|
33
33
|
|
34
34
|
token.value.class.should == Array
|
@@ -37,31 +37,31 @@ describe 'Rlint::Parser' do
|
|
37
37
|
first = token.value[0]
|
38
38
|
last = token.value[2]
|
39
39
|
|
40
|
-
first.class.should ==
|
40
|
+
first.class.should == RubyLint::Token::Token
|
41
41
|
first.type.should == :binary
|
42
42
|
first.value.length.should == 3
|
43
43
|
|
44
|
-
first.value[0].class.should ==
|
44
|
+
first.value[0].class.should == RubyLint::Token::Token
|
45
45
|
first.value[0].type.should == :integer
|
46
46
|
first.value[0].value.should == '10'
|
47
47
|
|
48
48
|
first.value[1].should == :and
|
49
49
|
|
50
|
-
first.value[2].class.should ==
|
50
|
+
first.value[2].class.should == RubyLint::Token::Token
|
51
51
|
first.value[2].type.should == :integer
|
52
52
|
first.value[2].value.should == '20'
|
53
53
|
|
54
54
|
token.value[1].should == :and
|
55
55
|
|
56
|
-
last.class.should ==
|
56
|
+
last.class.should == RubyLint::Token::Token
|
57
57
|
last.type.should == :integer
|
58
58
|
last.value.should == '30'
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'Parse unary operators' do
|
62
|
-
token =
|
62
|
+
token = RubyLint::Parser.new('!foobar').parse[0]
|
63
63
|
|
64
|
-
token.class.should ==
|
64
|
+
token.class.should == RubyLint::Token::Token
|
65
65
|
token.type.should == :unary
|
66
66
|
|
67
67
|
token.value.class.should == Array
|
@@ -69,7 +69,7 @@ describe 'Rlint::Parser' do
|
|
69
69
|
|
70
70
|
token.value[0].should == :!
|
71
71
|
|
72
|
-
token.value[1].class.should ==
|
72
|
+
token.value[1].class.should == RubyLint::Token::MethodToken
|
73
73
|
token.value[1].name.should == 'foobar'
|
74
74
|
end
|
75
75
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require File.expand_path('../../../helper', __FILE__)
|
2
2
|
|
3
|
-
describe '
|
3
|
+
describe 'RubyLint::Parser' do
|
4
4
|
it 'Parse a Proc' do
|
5
|
-
token =
|
5
|
+
token = RubyLint::Parser.new('proc { |example| example }').parse[0]
|
6
6
|
|
7
|
-
token.class.should ==
|
7
|
+
token.class.should == RubyLint::Token::MethodToken
|
8
8
|
token.name.should == 'proc'
|
9
9
|
|
10
|
-
token.block.class.should ==
|
11
|
-
token.block.parameters.class.should ==
|
10
|
+
token.block.class.should == RubyLint::Token::BlockToken
|
11
|
+
token.block.parameters.class.should == RubyLint::Token::ParametersToken
|
12
12
|
token.block.type.should == :block
|
13
13
|
|
14
14
|
params = token.block.parameters
|
@@ -16,7 +16,7 @@ describe 'Rlint::Parser' do
|
|
16
16
|
params.value.class.should == Array
|
17
17
|
params.value.length.should == 1
|
18
18
|
|
19
|
-
params.value[0].class.should ==
|
19
|
+
params.value[0].class.should == RubyLint::Token::VariableToken
|
20
20
|
params.value[0].type.should == :local_variable
|
21
21
|
params.value[0].name.should == 'example'
|
22
22
|
|
@@ -25,13 +25,13 @@ describe 'Rlint::Parser' do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'Parse a proc using do/end instead of curly braces' do
|
28
|
-
token =
|
28
|
+
token = RubyLint::Parser.new('proc do |example|; example; end').parse[0]
|
29
29
|
|
30
|
-
token.class.should ==
|
30
|
+
token.class.should == RubyLint::Token::MethodToken
|
31
31
|
token.name.should == 'proc'
|
32
32
|
|
33
|
-
token.block.class.should ==
|
34
|
-
token.block.parameters.class.should ==
|
33
|
+
token.block.class.should == RubyLint::Token::BlockToken
|
34
|
+
token.block.parameters.class.should == RubyLint::Token::ParametersToken
|
35
35
|
token.block.type.should == :block
|
36
36
|
|
37
37
|
params = token.block.parameters
|
@@ -39,7 +39,7 @@ describe 'Rlint::Parser' do
|
|
39
39
|
params.value.class.should == Array
|
40
40
|
params.value.length.should == 1
|
41
41
|
|
42
|
-
params.value[0].class.should ==
|
42
|
+
params.value[0].class.should == RubyLint::Token::VariableToken
|
43
43
|
params.value[0].type.should == :local_variable
|
44
44
|
params.value[0].name.should == 'example'
|
45
45
|
|
@@ -48,17 +48,17 @@ describe 'Rlint::Parser' do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'Parse a Proc using Proc.new' do
|
51
|
-
token =
|
51
|
+
token = RubyLint::Parser.new('Proc.new { |example| example }').parse[0]
|
52
52
|
|
53
|
-
token.class.should ==
|
53
|
+
token.class.should == RubyLint::Token::MethodToken
|
54
54
|
token.name.should == 'new'
|
55
55
|
|
56
|
-
token.receiver.class.should ==
|
56
|
+
token.receiver.class.should == RubyLint::Token::VariableToken
|
57
57
|
token.receiver.name.should == 'Proc'
|
58
58
|
token.receiver.type.should == :constant
|
59
59
|
|
60
|
-
token.block.class.should ==
|
61
|
-
token.block.parameters.class.should ==
|
60
|
+
token.block.class.should == RubyLint::Token::BlockToken
|
61
|
+
token.block.parameters.class.should == RubyLint::Token::ParametersToken
|
62
62
|
token.block.type.should == :block
|
63
63
|
|
64
64
|
token.block.parameters.value.class.should == Array
|
@@ -66,44 +66,44 @@ describe 'Rlint::Parser' do
|
|
66
66
|
|
67
67
|
param = token.block.parameters.value[0]
|
68
68
|
|
69
|
-
param.class.should ==
|
69
|
+
param.class.should == RubyLint::Token::VariableToken
|
70
70
|
param.name.should == 'example'
|
71
71
|
param.type.should == :local_variable
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'Parse a Lambda' do
|
75
|
-
token =
|
75
|
+
token = RubyLint::Parser.new('lambda { |example| example }').parse[0]
|
76
76
|
|
77
|
-
token.class.should ==
|
77
|
+
token.class.should == RubyLint::Token::MethodToken
|
78
78
|
token.name.should == 'lambda'
|
79
79
|
|
80
|
-
token.block.class.should ==
|
80
|
+
token.block.class.should == RubyLint::Token::BlockToken
|
81
81
|
token.block.type.should == :block
|
82
82
|
|
83
|
-
token.block.parameters.class.should ==
|
83
|
+
token.block.parameters.class.should == RubyLint::Token::ParametersToken
|
84
84
|
token.block.parameters.value.class.should == Array
|
85
85
|
token.block.parameters.value.length.should == 1
|
86
86
|
|
87
87
|
param = token.block.parameters.value[0]
|
88
88
|
|
89
|
-
param.class.should ==
|
89
|
+
param.class.should == RubyLint::Token::VariableToken
|
90
90
|
param.name.should == 'example'
|
91
91
|
param.type.should == :local_variable
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'Parse a Lambda using the dash rocket syntax' do
|
95
|
-
token =
|
95
|
+
token = RubyLint::Parser.new('-> example { example }').parse[0]
|
96
96
|
|
97
|
-
token.class.should ==
|
97
|
+
token.class.should == RubyLint::Token::BlockToken
|
98
98
|
token.type.should == :lambda
|
99
99
|
|
100
|
-
token.parameters.class.should ==
|
100
|
+
token.parameters.class.should == RubyLint::Token::ParametersToken
|
101
101
|
token.parameters.value.class.should == Array
|
102
102
|
token.parameters.value.length.should == 1
|
103
103
|
|
104
104
|
param = token.parameters.value[0]
|
105
105
|
|
106
|
-
param.class.should ==
|
106
|
+
param.class.should == RubyLint::Token::VariableToken
|
107
107
|
param.name.should == 'example'
|
108
108
|
param.type.should == :local_variable
|
109
109
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require File.expand_path('../../../helper', __FILE__)
|
2
2
|
|
3
|
-
describe '
|
3
|
+
describe 'RubyLint::Parser' do
|
4
4
|
it 'Parse a Range' do
|
5
|
-
token =
|
5
|
+
token = RubyLint::Parser.new('0..10').parse[0]
|
6
6
|
|
7
|
-
token.class.should ==
|
7
|
+
token.class.should == RubyLint::Token::Token
|
8
8
|
token.type.should == :range
|
9
9
|
token.line.should == 1
|
10
10
|
token.column.should == 1
|
@@ -15,19 +15,19 @@ describe 'Rlint::Parser' do
|
|
15
15
|
start = token.value[0]
|
16
16
|
stop = token.value[1]
|
17
17
|
|
18
|
-
start.class.should ==
|
18
|
+
start.class.should == RubyLint::Token::Token
|
19
19
|
start.type.should == :integer
|
20
20
|
start.value.should == '0'
|
21
21
|
|
22
|
-
stop.class.should ==
|
22
|
+
stop.class.should == RubyLint::Token::Token
|
23
23
|
stop.type.should == :integer
|
24
24
|
stop.value.should == '10'
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'Parse a Range of Strings' do
|
28
|
-
token =
|
28
|
+
token = RubyLint::Parser.new('"a".."z"').parse[0]
|
29
29
|
|
30
|
-
token.class.should ==
|
30
|
+
token.class.should == RubyLint::Token::Token
|
31
31
|
token.type.should == :range
|
32
32
|
token.line.should == 1
|
33
33
|
token.column.should == 1
|
@@ -38,11 +38,11 @@ describe 'Rlint::Parser' do
|
|
38
38
|
start = token.value[0]
|
39
39
|
stop = token.value[1]
|
40
40
|
|
41
|
-
start.class.should ==
|
41
|
+
start.class.should == RubyLint::Token::Token
|
42
42
|
start.type.should == :string
|
43
43
|
start.value.should == 'a'
|
44
44
|
|
45
|
-
stop.class.should ==
|
45
|
+
stop.class.should == RubyLint::Token::Token
|
46
46
|
stop.type.should == :string
|
47
47
|
stop.value.should == 'z'
|
48
48
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require File.expand_path('../../../helper', __FILE__)
|
2
2
|
|
3
|
-
describe '
|
3
|
+
describe 'RubyLint::Parser' do
|
4
4
|
it 'Parse a regular expression' do
|
5
|
-
token =
|
5
|
+
token = RubyLint::Parser.new('/foo/im').parse[0]
|
6
6
|
|
7
|
-
token.class.should ==
|
7
|
+
token.class.should == RubyLint::Token::RegexpToken
|
8
8
|
token.type.should == :regexp
|
9
9
|
token.value.should == 'foo'
|
10
10
|
|
@@ -16,9 +16,9 @@ describe 'Rlint::Parser' do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'Parse a regular expression using %r{}' do
|
19
|
-
token =
|
19
|
+
token = RubyLint::Parser.new('%r{foo}im').parse[0]
|
20
20
|
|
21
|
-
token.class.should ==
|
21
|
+
token.class.should == RubyLint::Token::RegexpToken
|
22
22
|
token.type.should == :regexp
|
23
23
|
token.value.should == 'foo'
|
24
24
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require File.expand_path('../../../helper', __FILE__)
|
2
2
|
|
3
|
-
describe '
|
3
|
+
describe 'RubyLint::Parser' do
|
4
4
|
it 'Parse a String' do
|
5
5
|
['"hello"', "'hello'"].each do |string|
|
6
|
-
token =
|
6
|
+
token = RubyLint::Parser.new(string).parse[0]
|
7
7
|
|
8
|
-
token.class.should ==
|
8
|
+
token.class.should == RubyLint::Token::Token
|
9
9
|
token.type.should == :string
|
10
10
|
token.value.should == 'hello'
|
11
11
|
token.line.should == 1
|
@@ -15,18 +15,18 @@ describe 'Rlint::Parser' do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'Parse a Symbol' do
|
18
|
-
token =
|
18
|
+
token = RubyLint::Parser.new(':hello').parse[0]
|
19
19
|
|
20
|
-
token.class.should ==
|
20
|
+
token.class.should == RubyLint::Token::Token
|
21
21
|
token.type.should == :symbol
|
22
22
|
token.value.should == 'hello'
|
23
23
|
token.line.should == 1
|
24
24
|
token.column.should == 1
|
25
25
|
token.code.should == ':hello'
|
26
26
|
|
27
|
-
token =
|
27
|
+
token = RubyLint::Parser.new(':"hello"').parse[0]
|
28
28
|
|
29
|
-
token.class.should ==
|
29
|
+
token.class.should == RubyLint::Token::Token
|
30
30
|
token.type.should == :symbol
|
31
31
|
token.value.should == 'hello'
|
32
32
|
token.line.should == 1
|
@@ -36,9 +36,9 @@ describe 'Rlint::Parser' do
|
|
36
36
|
|
37
37
|
it 'Parse a string using %q{} and %Q{}' do
|
38
38
|
['%q{hello}', '%Q{hello}'].each do |string|
|
39
|
-
token =
|
39
|
+
token = RubyLint::Parser.new(string).parse[0]
|
40
40
|
|
41
|
-
token.class.should ==
|
41
|
+
token.class.should == RubyLint::Token::Token
|
42
42
|
token.type.should == :string
|
43
43
|
token.value.should == 'hello'
|
44
44
|
token.line.should == 1
|
@@ -48,9 +48,9 @@ describe 'Rlint::Parser' do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'Parse a Fixnum' do
|
51
|
-
token =
|
51
|
+
token = RubyLint::Parser.new('10').parse[0]
|
52
52
|
|
53
|
-
token.class.should ==
|
53
|
+
token.class.should == RubyLint::Token::Token
|
54
54
|
token.type.should == :integer
|
55
55
|
token.value.should == '10'
|
56
56
|
token.line.should == 1
|
@@ -59,9 +59,9 @@ describe 'Rlint::Parser' do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'Parse a Float' do
|
62
|
-
token =
|
62
|
+
token = RubyLint::Parser.new('10.2').parse[0]
|
63
63
|
|
64
|
-
token.class.should ==
|
64
|
+
token.class.should == RubyLint::Token::Token
|
65
65
|
token.type.should == :float
|
66
66
|
token.value.should == '10.2'
|
67
67
|
token.line.should == 1
|
@@ -70,9 +70,9 @@ describe 'Rlint::Parser' do
|
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'Parse a boolean' do
|
73
|
-
token =
|
73
|
+
token = RubyLint::Parser.new('true').parse[0]
|
74
74
|
|
75
|
-
token.class.should ==
|
75
|
+
token.class.should == RubyLint::Token::VariableToken
|
76
76
|
token.type.should == :keyword
|
77
77
|
token.name.should == 'true'
|
78
78
|
token.line.should == 1
|
@@ -81,9 +81,9 @@ describe 'Rlint::Parser' do
|
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'Parse a nil value' do
|
84
|
-
token =
|
84
|
+
token = RubyLint::Parser.new('nil').parse[0]
|
85
85
|
|
86
|
-
token.class.should ==
|
86
|
+
token.class.should == RubyLint::Token::VariableToken
|
87
87
|
token.type.should == :keyword
|
88
88
|
token.name.should == 'nil'
|
89
89
|
token.line.should == 1
|