Sha256: 6617eb47e9a344e7f6a9a6d3ef52136f39421a8ed6f374125770eb0642e51466

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

require "spec_helper"

describe Nydp::StringAtom do
  let(:bar) { "BAR" }
  let(:foo) { "FOO" }

  it "is not equal to a symbol with the same represenation" do
    string = "harrypotter"
    symbol = :harrypotter
    compare = symbol.to_s
    expect(string == compare).to eq true
    expect(string == symbol) .to eq false
  end

  it "is not equal to a list with the same represenation" do
    string = '("FOO" "BAR")'
    list   = Nydp::Pair.from_list [foo, bar]
    compare = list.to_s
    expect(string == compare).to eq true
    expect(string == list)   .to eq false
  end

  it "returns its string in #to_ruby" do
    s = Nydp::StringAtom.new "harrypotter"
    expect(s.to_ruby).to eq "harrypotter"
    expect(s.to_ruby.class).to eq String
  end

  it "works with builtin greater-than when true" do
    f = Nydp::Builtin::GreaterThan.instance

    a = f.call foo, bar

    expect(a).to eq bar
  end

  it "works with builtin greater-than when false" do
    f = Nydp::Builtin::GreaterThan.instance

    a = f.call bar, foo

    expect(a).to eq Nydp::NIL
  end

  it "works with builtin less-than when true" do
    f = Nydp::Builtin::LessThan.instance

    a = f.call bar, foo

    expect(a).to eq foo
  end

  it "works with builtin less-than when false" do
    f = Nydp::Builtin::LessThan.instance

    a = f.call foo, bar

    expect(a).to eq Nydp::NIL
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nydp-0.6.0 spec/string_atom_spec.rb