Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
module RuboCop | ||
module AST | ||
# A node extension for `irange` and `erange` nodes. This will be used in | ||
# place of a plain node when the builder constructs the AST, making its | ||
# methods available to all `irange` and `erange` nodes within RuboCop. | ||
class RangeNode < Node | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe RuboCop::AST::RangeNode do | ||
let(:range_node) { parse_source(source).ast } | ||
|
||
describe '.new' do | ||
context 'with an inclusive range' do | ||
let(:source) do | ||
'1..2' | ||
end | ||
|
||
it { expect(range_node.is_a?(described_class)).to be(true) } | ||
end | ||
|
||
context 'with an exclusive range' do | ||
let(:source) do | ||
'1...2' | ||
end | ||
|
||
it { expect(range_node.is_a?(described_class)).to be(true) } | ||
end | ||
|
||
context 'with an infinite range' do | ||
let(:ruby_version) { 2.6 } | ||
let(:source) do | ||
'1..' | ||
end | ||
|
||
it { expect(range_node.is_a?(described_class)).to be(true) } | ||
end | ||
end | ||
end |