public
Description: Reia is a Ruby/Python-like language for BEAM, the Erlang VM
Homepage: http://reia-lang.org
Clone URL: git://github.com/tarcieri/reia.git
Fix Tuple.inspect to add the trailing comma on 1-tuples, e.g. (1,)
mgood (author)
Tue Oct 14 22:54:09 -0700 2008
Tony Arcieri (committer)
Tue Oct 14 23:45:19 -0700 2008
commit  f7f2abc85a42e7c8eafab7cdfd1a5e5d1c09dc87
tree    4e785c6224a25a6f7d1ae4200c8c52d6c57a81e5
parent  1838639a85d96721f8b3872bff9933a88dd072e1
...
27
28
29
30
 
 
 
 
 
 
31
32
33
...
27
28
29
 
30
31
32
33
34
35
36
37
38
0
@@ -27,7 +27,12 @@ module Tuple
0
   # Tuple#inspect
0
   # Inspect the contents of a Tuple
0
   def funcall(tuple, ~inspect, [])
0
- ["(", tuple.to_list().map { |e| e.inspect() }.join(","), ")"].join()
0
+ elems = tuple.to_list().map { |e| e.inspect() }.join(",")
0
+ # special-case trailing comma
0
+ if tuple.size() == 1
0
+ ["(", elems, ",)"].join()
0
+ else
0
+ ["(", elems, ")"].join()
0
     
0
   # Tuple#size
0
   # Return the number of elements in a Tuple
...
4
5
6
 
7
8
9
...
17
18
19
 
 
 
 
 
20
...
4
5
6
7
8
9
10
...
18
19
20
21
22
23
24
25
26
0
@@ -4,6 +4,7 @@ module TupleTest
0
     
0
     nth_test()
0
     to_list_test()
0
+ inspect_test()
0
     
0
   # retrieves the nth element correctly
0
   def nth_test
0
@@ -17,3 +18,8 @@ module TupleTest
0
     TestHelper.expect("converts to a list", fun do
0
       ([1,2,3].to_s(), (1,2,3).to_list().to_s())
0
     )
0
+
0
+ def inspect_test
0
+ TestHelper.expect("inspect returns valid tuple syntax", fun do
0
+ (true, ().inspect() == "()" and (1,).inspect() == "(1,)" and (1,2).inspect() == "(1,2)")
0
+ )
0
\ No newline at end of file

Comments

    No one has commented yet.