Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/fix_numeric_node_sign_to_return_boolean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#380](https://github.com/rubocop/rubocop-ast/pull/380): Fix `RuboCop::AST::NumericNode#sign?` to return boolean. ([@viralpraxis][])
2 changes: 1 addition & 1 deletion lib/rubocop/ast/node/mixin/numeric_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module NumericNode
#
# @return [Boolean] whether this literal has a sign.
def sign?
source.match(SIGN_REGEX)
source.match?(SIGN_REGEX)
end
end
end
Expand Down
6 changes: 4 additions & 2 deletions spec/rubocop/ast/float_node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
end

describe '#sign?' do
subject { float_node.sign? }

context 'explicit positive float' do
let(:source) { '+42.0' }

it { is_expected.to be_sign }
it { is_expected.to be(true) }
end

context 'explicit negative float' do
let(:source) { '-42.0' }

it { is_expected.to be_sign }
it { is_expected.to be(true) }
end
end

Expand Down
6 changes: 4 additions & 2 deletions spec/rubocop/ast/int_node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
end

describe '#sign?' do
subject { int_node.sign? }

context 'explicit positive int' do
let(:source) { '+42' }

it { is_expected.to be_sign }
it { is_expected.to be(true) }
end

context 'explicit negative int' do
let(:source) { '-42' }

it { is_expected.to be_sign }
it { is_expected.to be(true) }
end
end

Expand Down
6 changes: 4 additions & 2 deletions spec/rubocop/ast/rational_node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
end

describe '#sign?' do
subject { rational_node.sign? }

context 'when explicit positive rational' do
let(:source) { '+0.2r' }

it { is_expected.to be_sign }
it { is_expected.to be(true) }
end

context 'when explicit negative rational' do
let(:source) { '-0.2r' }

it { is_expected.to be_sign }
it { is_expected.to be(true) }
end
end

Expand Down
Loading