Sha256: e301fc5e5e892beb9dd7b6450db9bb5b4ff414a7c4aae25dbb5f08b060e56c04

Contents?: true

Size: 1.01 KB

Versions: 26

Compression:

Stored size: 1.01 KB

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

require 'spec_helper'

include TwitterCldr::Utils

describe RegexpAst do
  let(:ast) do
    RegexpAst::Root.new(
      [RegexpAst::Literal.new([], nil, 'foobar')], nil
    )
  end

  let(:ast_dump) do
    "BAhvOihUd2l0dGVyQ2xkcjo6VXRpbHM6OlJlZ2V4cEFzdDo6Um9vdAc6EUBl\n" +
    "eHByZXNzaW9uc1sGbzorVHdpdHRlckNsZHI6OlV0aWxzOjpSZWdleHBBc3Q6\n" +
    "OkxpdGVyYWwIOgpAdGV4dEkiC2Zvb2JhcgY6BkVUOwZbADoQQHF1YW50aWZp\n" +
    "ZXIwOwow\n"
  end

  def check_ast(obj)
    obj.should be_a(RegexpAst::Root)
    expr = obj.expressions.first
    expr.should be_a(RegexpAst::Literal)
    expr.text.should == 'foobar'
  end

  describe "#dump" do
    it "should correctly serialize the ast" do
      obj = Marshal.load(Base64.decode64(RegexpAst.dump(ast)))
      check_ast(obj)
    end
  end

  describe "#load" do
    it "should load the dumped ast and construct a valid object" do
      obj = RegexpAst.load(ast_dump)
      check_ast(obj)
    end
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
twitter_cldr-4.3.1 spec/utils/regexp_ast_spec.rb
twitter_cldr-4.3.0 spec/utils/regexp_ast_spec.rb
twitter_cldr-4.2.0 spec/utils/regexp_ast_spec.rb
twitter_cldr-4.1.0 spec/utils/regexp_ast_spec.rb
twitter_cldr-4.0.0 spec/utils/regexp_ast_spec.rb
twitter_cldr-3.6.0 spec/utils/regexp_ast_spec.rb
twitter_cldr-3.5.0 spec/utils/regexp_ast_spec.rb
twitter_cldr-3.4.0 spec/utils/regexp_ast_spec.rb
twitter_cldr-3.3.0 spec/utils/regexp_ast_spec.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/twitter_cldr-3.2.1/spec/utils/regexp_ast_spec.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/twitter_cldr-3.2.1/spec/utils/regexp_ast_spec.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/twitter_cldr-3.1.2/spec/utils/regexp_ast_spec.rb
twitter_cldr-3.2.1 spec/utils/regexp_ast_spec.rb
twitter_cldr-3.2.0 spec/utils/regexp_ast_spec.rb
twitter_cldr-3.1.2 spec/utils/regexp_ast_spec.rb
twitter_cldr-3.1.1 spec/utils/regexp_ast_spec.rb
twitter_cldr-3.1.0 spec/utils/regexp_ast_spec.rb
twitter_cldr-3.0.10 spec/utils/regexp_ast_spec.rb
twitter_cldr-3.0.9 spec/utils/regexp_ast_spec.rb
twitter_cldr-3.0.8 spec/utils/regexp_ast_spec.rb