From afce21ffad516af6a6898d18fa3c76285b5f028e Mon Sep 17 00:00:00 2001 From: Watson Date: Thu, 14 Nov 2013 17:31:07 +0900 Subject: [PATCH] add Struct spec for converting Fixnum/Float to Objective-C value Relate to https://github.com/lrz/RubyMotionVM/commit/01311e1f88ff1e634d1d7c7b56640125d1b45bc4 --- test/test/spec/struct_spec.rb | 31 +++++++++++++++++++++++++++++++ test/test/vendor/code/code.h | 8 ++++++++ vm | 2 +- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/test/test/spec/struct_spec.rb b/test/test/spec/struct_spec.rb index c0ed962f..4b87268c 100644 --- a/test/test/spec/struct_spec.rb +++ b/test/test/spec/struct_spec.rb @@ -19,3 +19,34 @@ # lambda { Struct.new(*fields) }.should.raise(ArgumentError) # end # end + +describe "Struct" do + it "values are stored depending on the member type" do + struct = MyStructTestConvert.new + + struct.m_long = 123 + struct.m_long.should == 123 + struct.m_long = 123.0 + struct.m_long.should == 123 + + struct.m_ulong = 123 + struct.m_ulong.should == 123 + struct.m_ulong = 123.0 + struct.m_ulong.should == 123 + + struct.m_longlong = 123 + struct.m_longlong.should == 123 + struct.m_longlong = 123.0 + struct.m_longlong.should == 123 + + struct.m_ulonglong = 123 + struct.m_ulonglong.should == 123 + struct.m_ulonglong = 123.0 + struct.m_ulonglong.should == 123 + + struct.m_double = 123 + struct.m_double.should == 123.0 + struct.m_double = 123.0 + struct.m_double.should == 123.0 + end +end \ No newline at end of file diff --git a/test/test/vendor/code/code.h b/test/test/vendor/code/code.h index c959dd08..cdb40e86 100644 --- a/test/test/vendor/code/code.h +++ b/test/test/vendor/code/code.h @@ -1,5 +1,13 @@ #import +struct MyStructTestConvert { + long m_long; + unsigned long m_ulong; + long long m_longlong; + unsigned long long m_ulonglong; + double m_double; +}; + struct MyStruct4C { char a, b, c, d; }; diff --git a/vm b/vm index 9d8885ec..01311e1f 160000 --- a/vm +++ b/vm @@ -1 +1 @@ -Subproject commit 9d8885ec3968a441d417acb1e7cff2a0fb33e679 +Subproject commit 01311e1f88ff1e634d1d7c7b56640125d1b45bc4