Sha256: f0266c68907699aa948639f731b4e80f091af4824ef604b560c6d56f037c7bdb

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper.rb'))

class StringLiteralTest < Test::Unit::TestCase

  def setup
    @parser = Sexpistol.new
  end

  test "should parse empty string literal" do
    ast = @parser.parse_string('("")')
    assert_equal [[""]], ast
  end

  test "should parse string literal" do
    ast = @parser.parse_string('("test")')
    assert_equal [["test"]], ast
  end
  
  test "should parse string literal containing escaped quotes" do
    ast = @parser.parse_string('("te\"st")')
    assert_equal [["te\"st"]], ast
  end
  
  test "should parse string literal containing escaped characters" do
    ast = @parser.parse_string('("\n\t\r")')
    assert_equal [["\n\t\r"]], ast
  end
  
  test "should parse string literal containing spaces" do
    ast = @parser.parse_string('("blah foo")')
    assert_equal [["blah foo"]], ast
  end
  
  test "should parse string literal containing newlines" do
    ast = @parser.parse_string('("blah' + "\n" + 'foo")')
    assert_equal [["blah\nfoo"]], ast
  end
    
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
deil_sexpistol-0.0.9 test/unit/string_literal_test.rb
deil_sexpistol-0.0.8 test/unit/string_literal_test.rb
sexpistol-0.0.7 test/unit/string_literal_test.rb