Sha256: 74d8cfba9d7bb94d06ad00f035f73610cf835b9721ff328bf0e354479fefacdc

Contents?: true

Size: 648 Bytes

Versions: 21

Compression:

Stored size: 648 Bytes

Contents

require "spec_helper"

RSpec.describe "if" do
  let(:timeout) { 0 }
  subject { Code.evaluate(input, timeout: timeout).to_s }

  [
    ["if true 1", "1"],
    ["unless false 1", "1"],
    ["if false 1", ""],
    ["unless true 1", ""],
    ["if false 1 else 2", "2"],
    ["if false 1 elsif true 2", "2"],
    ["if false 1 elsif false 2", ""],
    ["if false 1 else if true 2", "2"],
    ["if false 1 else if false 2", ""],
    ["if false 1 else unless false 2", "2"],
    ["if false 1 else unless true 2", ""]
  ].each do |input, output|
    context input do
      let(:input) { input }
      it { expect(subject).to eq(output) }
    end
  end
end

Version data entries

21 entries across 21 versions & 3 rubygems

Version Path
template-ruby-0.5.6 spec/code/if_spec.rb
language-ruby-0.5.6 spec/code/if_spec.rb
code-ruby-0.5.6 spec/code/if_spec.rb
template-ruby-0.5.5 spec/code/if_spec.rb
language-ruby-0.5.5 spec/code/if_spec.rb
code-ruby-0.5.5 spec/code/if_spec.rb
template-ruby-0.5.4 spec/code/if_spec.rb
language-ruby-0.5.4 spec/code/if_spec.rb
code-ruby-0.5.4 spec/code/if_spec.rb
template-ruby-0.5.3 spec/code/if_spec.rb
language-ruby-0.5.3 spec/code/if_spec.rb
code-ruby-0.5.3 spec/code/if_spec.rb
template-ruby-0.5.2 spec/code/if_spec.rb
language-ruby-0.5.2 spec/code/if_spec.rb
code-ruby-0.5.2 spec/code/if_spec.rb
language-ruby-0.5.1 spec/code/if_spec.rb
template-ruby-0.5.1 spec/code/if_spec.rb
code-ruby-0.5.1 spec/code/if_spec.rb
template-ruby-0.5.0 spec/code/if_spec.rb
language-ruby-0.5.0 spec/code/if_spec.rb