Skip to content
Merged
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
17 changes: 17 additions & 0 deletions language/if_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
require File.expand_path('../../spec_helper', __FILE__)

describe "The if expression" do
ruby_version_is '2.4' do
describe "accepts multiple assignments in conditional expression" do
before(:each) { ScratchPad.record([]) }
after(:each) { ScratchPad.clear }

it 'with non-nil values' do
eval "if (a, b = [1, 2]); ScratchPad << 123; end"
ScratchPad.recorded.should == [123]
end

it 'with nil values' do
eval "if (a, b = nil); ScratchPad << 123; end"
ScratchPad.recorded.should == []
end
end
end

it "evaluates body if expression is true" do
a = []
if true
Expand Down