Sha256: 39cadb30ce18b9bd02114e39cd60b7bc6624d78b2b3b8af1c7dca98eb8d41431

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 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

5 entries across 5 versions & 1 rubygems

Version Path
sexpistol-0.0.6 test/unit/string_literal_test.rb
sexpistol-0.0.5 test/unit/string_literal_test.rb
sexpistol-0.0.4 test/unit/string_literal_test.rb
sexpistol-0.0.3 test/unit/string_literal_test.rb
sexpistol-0.0.2 test/unit/string_literal_test.rb