Sha256: 72fd0ffb7e039493d11567468efb7b9e885222904c24cbc6b391e83c3bb79a87

Contents?: true

Size: 1.43 KB

Versions: 3

Compression:

Stored size: 1.43 KB

Contents

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

class ToSexpTest < Test::Unit::TestCase

  def setup
    @parser = Sexpistol.new
  end

  test "should convert nested arrays back into an S-Expression" do
    ast = [:string, [:is, [:parsed]]]
    sexp = @parser.to_sexp(ast)
    assert_equal "(string (is (parsed)))", sexp
  end
  
  test "should structure containing integers and strings back into an S-Expression" do
    ast = ["String!", [1, [2, "Other string."]]]
    sexp = @parser.to_sexp(ast)
    assert_equal "(String! (1 (2 Other string.)))", sexp
  end
  
  test "should not output true and false using scheme notation when scheme compat is off" do
    ast = [true, [false, [true, false]]]
    sexp = @parser.to_sexp(ast)
    assert_equal "(true (false (true false)))", sexp
  end
  
  test "when not passed array to_sexp should print value (integer)" do
    ast = 1
    sexp = @parser.to_sexp(ast)
    assert_equal "1", sexp
  end
  
  test "when not passed array to_sexp should print value (string)" do
    ast = "test"
    sexp = @parser.to_sexp(ast)
    assert_equal "test", sexp
  end
  
  test "when not passed array to_sexp should print value (symbol)" do
    ast = :test
    sexp = @parser.to_sexp(ast)
    assert_equal "test", sexp
  end
  
  test "lists passed to to_sexp should have not extraneous spaces" do
    ast = [1, 2, 3]
    sexp = @parser.to_sexp(ast)
    assert_equal "(1 2 3)", sexp
  end
    
end

Version data entries

3 entries across 3 versions & 2 rubygems

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