Author: kclark
Date: Tue Jun 17 18:19:51 2008
New Revision: 669034
URL: http://svn.apache.org/viewvc?rev=669034&view=rev
Log:
rb: Fix the binaryprotocol spec to run under jruby
Stop testing for RangeErrors with bignums in i64, that was just an artifact of
the MRI interpreter that has different behavior under jruby.
JRuby uses a different Float::MIN/MAX so stop hard-coding the binary
representation
Modified:
incubator/thrift/trunk/lib/rb/spec/binaryprotocol_spec.rb
Modified: incubator/thrift/trunk/lib/rb/spec/binaryprotocol_spec.rb
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/binaryprotocol_spec.rb?rev=669034&r1=669033&r2=669034&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/binaryprotocol_spec.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/binaryprotocol_spec.rb Tue Jun 17
18:19:51 2008
@@ -102,7 +102,7 @@
@trans.should_receive(:write).with("\200\005").ordered
@prot.write_i16(2**15 + 5)
# a Bignum should error
- lambda { @prot.write_i16(2**65) }.should raise_error(RangeError)
+ # lambda { @prot.write_i16(2**65) }.should raise_error(RangeError)
end
it "should write an i32" do
@@ -122,7 +122,7 @@
# try something out of signed range, it should clip
@trans.should_receive(:write).with("\200\000\000\005").ordered
@prot.write_i32(2 ** 31 + 5)
- lambda { @prot.write_i32(2 ** 65 + 5) }.should raise_error(RangeError)
+ # lambda { @prot.write_i32(2 ** 65 + 5) }.should raise_error(RangeError)
end
it "should write an i64" do
@@ -143,19 +143,19 @@
# try something out of signed range, it should clip
@trans.should_receive(:write).with("\200\000\000\000\000\000\000\005").ordered
@prot.write_i64(2**63 + 5)
- lambda { @prot.write_i64(2 ** 65 + 5) }.should raise_error(RangeError)
+ # lambda { @prot.write_i64(2 ** 65 + 5) }.should raise_error(RangeError)
end
it "should write a double" do
# try a random scattering of values, including min/max
-
@trans.should_receive(:write).with("\000\020\000\000\000\000\000\000").ordered
+ @trans.should_receive(:write).with([Float::MIN].pack('G')).ordered
@trans.should_receive(:write).with("\300\223<\234\355\221hs").ordered
@trans.should_receive(:write).with("\300\376\0173\256\024z\341").ordered
@trans.should_receive(:write).with("\3007<2\336\372v\324").ordered
@trans.should_receive(:write).with("\000\000\000\000\000\000\000\000").ordered
@trans.should_receive(:write).with("@\310\037\220\365\302\217\\").ordered
@trans.should_receive(:write).with("@\200Y\327\n=p\244").ordered
-
@trans.should_receive(:write).with("\177\357\377\377\377\377\377\377").ordered
+ @trans.should_receive(:write).with([Float::MAX].pack('G')).ordered
[Float::MIN, -1231.15325, -123123.23, -23.23515123, 0, 12351.1325,
523.23, Float::MAX].each do |f|
@prot.write_double(f)
end
@@ -274,9 +274,9 @@
it "should read a double" do
# try a random scattering of values, including min/max
@trans.should_receive(:read_all).with(8).and_return(
- "\000\020\000\000\000\000\000\000", "\301\f9\370\374\362\317\226",
+ [Float::MIN].pack('G'), "\301\f9\370\374\362\317\226",
"\300t3\274x \243\016", "\000\000\000\000\000\000\000\000",
"@^\317\fCo\301Y",
- "[EMAIL PROTECTED]", "\177\357\377\377\377\377\377\377"
+ "[EMAIL PROTECTED]", [Float::MAX].pack('G')
)
[Float::MIN, -231231.12351, -323.233513, 0, 123.2351235,
2351235.12351235, Float::MAX].each do |f|
@prot.read_double.should == f