public
Description: The Ruby Implementation of SWX RPC
Homepage: http://swxruby.org
Clone URL: git://github.com/meekish/swxruby.git
Added specs to ensure the BytecodeConverter#symbol_to_bytecode is working 
properly
Jed Hurt (author)
Tue Mar 11 22:09:15 -0700 2008
commit  3946f1992e244e04c0789e58a47161169c89794a
tree    862139c0185180e7369ecd4ecf02902d08ee474c
parent  0ad086665fe4960d9b36eba331214064b94533fb
...
128
129
130
131
 
132
133
 
134
135
136
...
128
129
130
 
131
132
 
133
134
135
136
0
@@ -128,9 +128,9 @@ class BytecodeConverter
0
    DataTypeCodes::STRING + string.unpack('H*').join.upcase + NULL_TERMINATOR
0
    end
0
   
0
- def symbol_to_bytecode(symbol)
0
+ def symbol_to_bytecode(symbol)
0
       string_to_bytecode(symbol.to_s)
0
- end
0
+ end
0
   
0
    def trueclass_to_bytecode(*args) #:nodoc#
0
       DataTypeCodes::BOOLEAN + '01'
...
87
88
89
 
 
 
 
90
91
92
...
138
139
140
 
 
 
 
 
 
 
 
 
 
 
 
141
142
143
...
87
88
89
90
91
92
93
94
95
96
...
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
0
@@ -87,6 +87,10 @@ describe BytecodeConverter, 'in regard to hashes' do
0
   it %q[should convert a hash with string and integer values to bytecode] do
0
     BytecodeConverter.convert({'it' => 'works', 'number' => 42}).should == '961D00006E756D62657200072A0000000069740000776F726B7300070200000043'
0
   end
0
+
0
+ it %q[should convert a hash with symbols for keys to bytecode] do
0
+ BytecodeConverter.convert({:it => 'works', :number => 42}).should == '961D00006E756D62657200072A0000000069740000776F726B7300070200000043'
0
+ end
0
 
0
   it %q[should convert a hash with nested arrays to bytecode] do
0
     BytecodeConverter.convert({'they' => ['really', 'work'], 'numbers' => [1, 2, 3]}).should == '960900006E756D626572730096140007030000000702000000070100000007030000004296060000746865790096130000776F726B00007265616C6C7900070200000042960500070200000043'
0
@@ -138,6 +142,18 @@ describe BytecodeConverter, 'in regard to strings' do
0
     BytecodeConverter.convert('').should == '0000'
0
   end
0
 end
0
+
0
+describe BytecodeConverter, 'in regard to symbols' do
0
+ it 'should convert :hello to bytecode' do
0
+ BytecodeConverter.convert(:hello).should == '0068656C6C6F00'
0
+ end
0
+
0
+ it 'should convert :goodbye to bytecode' do
0
+ BytecodeConverter.convert(:goodbye).should == '00676F6F6462796500'
0
+ end
0
+end
0
+
0
+
0
     
0
 describe BytecodeConverter, 'in regard to unhandled datatypes' do
0
   it 'should raise an exception when asked to convert an unhandled data type' do

Comments

    No one has commented yet.