sexpistol 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
@@ -118,20 +118,30 @@ class Sexpistol
118
118
 
119
119
  # Convert a set of nested arrays back into an S-Expression
120
120
  def to_sexp( data )
121
- mapped = data.map do |item|
122
- if( item.is_a?(Array))
123
- to_sexp(item)
124
- else
125
- if(item === false)
126
- "#f"
127
- elsif(item === true)
128
- "#t"
121
+ if( data.is_a?(Array))
122
+ mapped = data.map do |item|
123
+ if( item.is_a?(Array))
124
+ to_sexp(item)
129
125
  else
130
- item.to_s
126
+ if(item === false)
127
+ "#f"
128
+ elsif(item === true)
129
+ "#t"
130
+ else
131
+ item.to_s
132
+ end
131
133
  end
132
134
  end
135
+ "(" + mapped.join(" ") + ")"
136
+ else
137
+ if(data === false)
138
+ "#f"
139
+ elsif(data === true)
140
+ "#t"
141
+ else
142
+ data.to_s
143
+ end
133
144
  end
134
- "(" + mapped.join(" ") + ")"
135
145
  end
136
146
 
137
147
  private
data/sexpistol.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sexpistol}
8
- s.version = "0.0.5"
8
+ s.version = "0.0.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Gough"]
@@ -23,5 +23,29 @@ class ToSexpTest < Test::Unit::TestCase
23
23
  sexp = @parser.to_sexp(ast)
24
24
  assert_equal "(#t (#f (#t #f)))", sexp
25
25
  end
26
+
27
+ test "when not passed array to_sexp should print value (integer)" do
28
+ ast = 1
29
+ sexp = @parser.to_sexp(ast)
30
+ assert_equal "1", sexp
31
+ end
32
+
33
+ test "when not passed array to_sexp should print value (string)" do
34
+ ast = "test"
35
+ sexp = @parser.to_sexp(ast)
36
+ assert_equal "test", sexp
37
+ end
38
+
39
+ test "when not passed array to_sexp should print value (symbol)" do
40
+ ast = :test
41
+ sexp = @parser.to_sexp(ast)
42
+ assert_equal "test", sexp
43
+ end
44
+
45
+ test "lists passed to to_sexp should have not extraneous spaces" do
46
+ ast = [1, 2, 3]
47
+ sexp = @parser.to_sexp(ast)
48
+ assert_equal "(1 2 3)", sexp
49
+ end
26
50
 
27
51
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 5
9
- version: 0.0.5
8
+ - 6
9
+ version: 0.0.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aaron Gough