sexpistol 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/sexpistol/sexpistol.rb +8 -2
- data/sexpistol.gemspec +1 -1
- data/test/unit/to_sexp_test.rb +13 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/lib/sexpistol/sexpistol.rb
CHANGED
@@ -122,10 +122,16 @@ class Sexpistol
|
|
122
122
|
if( item.is_a?(Array))
|
123
123
|
to_sexp(item)
|
124
124
|
else
|
125
|
-
item
|
125
|
+
if(item === false)
|
126
|
+
"#f"
|
127
|
+
elsif(item === true)
|
128
|
+
"#t"
|
129
|
+
else
|
130
|
+
item.to_s
|
131
|
+
end
|
126
132
|
end
|
127
133
|
end
|
128
|
-
"(
|
134
|
+
"(" + mapped.join(" ") + ")"
|
129
135
|
end
|
130
136
|
|
131
137
|
private
|
data/sexpistol.gemspec
CHANGED
data/test/unit/to_sexp_test.rb
CHANGED
@@ -9,7 +9,19 @@ class ToSexpTest < Test::Unit::TestCase
|
|
9
9
|
test "should convert nested arrays back into an S-Expression" do
|
10
10
|
ast = [:string, [:is, [:parsed]]]
|
11
11
|
sexp = @parser.to_sexp(ast)
|
12
|
-
assert_equal "(
|
12
|
+
assert_equal "(string (is (parsed)))", sexp
|
13
|
+
end
|
14
|
+
|
15
|
+
test "should structure containing integers and strings back into an S-Expression" do
|
16
|
+
ast = ["String!", [1, [2, "Other string."]]]
|
17
|
+
sexp = @parser.to_sexp(ast)
|
18
|
+
assert_equal "(String! (1 (2 Other string.)))", sexp
|
19
|
+
end
|
20
|
+
|
21
|
+
test "should output true and false using scheme notation" do
|
22
|
+
ast = [true, [false, [true, false]]]
|
23
|
+
sexp = @parser.to_sexp(ast)
|
24
|
+
assert_equal "(#t (#f (#t #f)))", sexp
|
13
25
|
end
|
14
26
|
|
15
27
|
end
|