Sha256: dbef97ed0942d5011e8ed466f46ba69b9e6936a293772f97bb4fe91bbe31cf42

Contents?: true

Size: 766 Bytes

Versions: 1

Compression:

Stored size: 766 Bytes

Contents

require "rly"
require "rly/helpers"

describe "Rly::Lex Helpers" do
  it "has a helper to use a common whitespace ignore pattern" do
    testLexer = Class.new(Rly::Lex) do
      ignore_spaces_and_tabs
    end

    expect { testLexer.new(" \t \t").next }.not_to raise_exception
  end

  it "has a helper to parse numeric tokens" do
    testLexer = Class.new(Rly::Lex) do
      lex_number_tokens
    end

    tok = testLexer.new("123").next
    tok.type.should == :NUMBER
    tok.value.should == 123
  end

  it "has a helper to parse double-quoted string tokens" do
    testLexer = Class.new(Rly::Lex) do
      lex_double_quoted_string_tokens
    end

    tok = testLexer.new('"a test"').next
    tok.type.should == :STRING
    tok.value.should == 'a test'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rly-0.2.3 spec/lex/lex_helpers_spec.rb