Sha256: 28235dc65b97b6c41d9885cf09f7e0ee77166d47595e2ce0a16626de83b41beb

Contents?: true

Size: 955 Bytes

Versions: 6

Compression:

Stored size: 955 Bytes

Contents

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

class StructureTest < Test::Unit::TestCase

  def setup
    @parser = Sexpistol.new
  end
  
  test "should create nested set of arrays from s-expression" do
    ast = @parser.parse_string('(this (is (an (s_expression) (also) blah) foo) (test))')
    assert_equal [[:this, [:is, [:an, [:s_expression], [:also], :blah], :foo], [:test]]], ast
  end
  
  test "should create nested set of arrays from s-expression with string literals" do
    ast = @parser.parse_string('(this (is (an ("s_expression"))))')
    assert_equal [[:this, [:is, [:an, ["s_expression"]]]]], ast
  end
  
  test "should raise error on broken s-expression" do
    assert_raises Exception do
      ast = @parser.parse_string('(this (is (an (s_expression) too)')
    end
  end
  
  test "should parser () as empty list" do
    ast = @parser.parse_string('()')
    assert_equal [[]], ast
  end
    
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
deil_sexpistol-0.0.9 test/unit/structure_test.rb
deil_sexpistol-0.0.8 test/unit/structure_test.rb
sexpistol-0.0.7 test/unit/structure_test.rb
sexpistol-0.0.6 test/unit/structure_test.rb
sexpistol-0.0.5 test/unit/structure_test.rb
sexpistol-0.0.4 test/unit/structure_test.rb