Sha256: d42fbb7e5f68495ee1fad37ec9946700a06f545649ee45d24223ad5c22a6f4a5

Contents?: true

Size: 841 Bytes

Versions: 2

Compression:

Stored size: 841 Bytes

Contents

require "rspec"
require "shuwar"

describe Shuwar::Tokenizer do
  def ts(text)
    Shuwar::Tokenizer.new(text).enum_for(:each_token).to_a
  end

  def op; Shuwar::Tokenizer::OpenParen.new; end
  def cp; Shuwar::Tokenizer::CloseParen.new; end
  def quote; Shuwar::Tokenizer::Quote.new; end

  it %q{should handle lists} do
    expect(ts "[a b]").to eq [op, :a, :b, cp]
  end

  it %q{should handle quotes} do
    expect(ts "#a").to eq [quote, :a]
  end

  it %q{should handle oneline text without tags} do
    expect(ts "| text").to eq ["text"]
  end

  it %q{should handle oneline text with tags} do
    expect(ts "a:b | t").to eq [op, :a, op, :b, "t", cp, cp]
  end

  it %q{should handle opening and closing tags well} do
    expect(ts <<END).to eq [op, :a ,"x", "y", op, :b, "z", cp, "w", cp]
a   | x
a   | y
a:b | z
a   | w
END
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shuwar-1.3.0 spec/tokens_spec.rb
shuwar-1.2.0 spec/tokens_spec.rb