test/decode_spec.rb in erlectricity-1.0.1 vs test/decode_spec.rb in erlectricity-1.1.0

- old
+ new

@@ -88,19 +88,22 @@ ref.length.should == 512 ref.each{|r| r.should == 3} end specify "an empty erlang list encoded as a nil should decode to an array" do + get("[]").class.should == Erl::List get("[]").should == [] end specify "an erlang list encoded as a string should decode to an array of bytes (less than ideal, but consistent)" do + get("\"asdasd\"").class.should == Erl::List get("\"asdasd\"").should == "asdasd".split('').map{|c| c[0]} get("\"#{'a' * 65534}\"").should == ['a'[0]] * 65534 end - specify "an erlang list encoded as a list should decode to a array" do + specify "an erlang list encoded as a list should decode to an erl::list" do + get("[3,4,256]").class.should == Erl::List get("[3,4,256]").should == [3,4,256] get("\"#{'a' * 65535 }\"").should == [97] * 65535 get("[3,4, foo, {3,4,5,bar}, 256]").should == [3,4, :foo, [3,4,5,:bar], 256] end @@ -108,13 +111,21 @@ get("<< 3,4,255 >>").should == "\003\004\377" get("<< \"whatup\" >>").should == "whatup" get("<< 99,0,99 >>").should == "c\000c" end + specify "the empty atom should decode to the empty symbol" do + empty_symbol = get("''") + empty_symbol.should.be.instance_of Symbol + empty_symbol.to_s.should == "" + end + specify "erlang atomic booleans should decode to ruby booleans" do get("true").should == true get("false").should == false get("falsereio").should == :falsereio + get("t").should == :t + get("f").should == :f end specify "a good thing should be awesome" do get(%Q-[{options,{struct,[{test,<<"I'm chargin' mah lazer">>}]}},{passage,<<"Why doesn't this work?">>}]-).should == [[:options, [:struct, [[:test, "I'm chargin' mah lazer"]]]], [:passage, "Why doesn't this work?"]] \ No newline at end of file