[macruby-changes] [1500] MacRuby/branches/experimental/spec/macruby
source_changes at macosforge.org
source_changes at macosforge.org
Mon Apr 27 22:53:14 PDT 2009
Revision: 1500
http://trac.macosforge.org/projects/ruby/changeset/1500
Author: lsansonetti at apple.com
Date: 2009-04-27 22:53:14 -0700 (Mon, 27 Apr 2009)
Log Message:
-----------
added specs for BS constants
Modified Paths:
--------------
MacRuby/branches/experimental/spec/macruby/objc_method_spec.rb
Added Paths:
-----------
MacRuby/branches/experimental/spec/macruby/constant_spec.rb
MacRuby/branches/experimental/spec/macruby/fixtures/constant.bridgesupport
MacRuby/branches/experimental/spec/macruby/fixtures/constant.m
Added: MacRuby/branches/experimental/spec/macruby/constant_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/constant_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/macruby/constant_spec.rb 2009-04-28 05:53:14 UTC (rev 1500)
@@ -0,0 +1,92 @@
+require File.dirname(__FILE__) + '/../spec_helper'
+
+framework 'Foundation'
+
+fixture_source = File.dirname(__FILE__) + '/fixtures/constant.m'
+fixture_ext = '/tmp/constant.bundle'
+if !File.exist?(fixture_ext) or File.mtime(fixture_source) > File.mtime(fixture_ext)
+ `/usr/bin/gcc #{fixture_source} -o #{fixture_ext} -g -framework Foundation -dynamiclib -fobjc-gc -arch i386 -arch x86_64 -arch ppc`
+end
+require '/tmp/constant'
+load_bridge_support_file File.dirname(__FILE__) + '/fixtures/constant.bridgesupport'
+
+describe "A BridgeSupport constant" do
+ it "of type 'id' is available as an Object in Ruby" do
+ ConstantObject.class.should == NSString
+ ConstantObject.should == 'foo'
+ end
+
+ it "of type 'Class' is available as a Class in Ruby" do
+ ConstantClass.class.should == Class
+ ConstantClass.should == NSObject
+ end
+
+ it "of type 'SEL' is available as a Symbol in Ruby" do
+ ConstantSEL.class.should == Symbol
+ ConstantSEL.should == :'foo:with:with:'
+ end
+
+ it "of type 'char' or 'unsigned char' is available as a Fixnum in Ruby" do
+ ConstantChar.class.should == Fixnum
+ ConstantUnsignedChar.class.should == Fixnum
+ ConstantChar.should == 42
+ ConstantUnsignedChar.should == 42
+ end
+
+ it "of type 'short' or 'unsigned short' is available as a Fixnum in Ruby" do
+ ConstantShort.class.should == Fixnum
+ ConstantUnsignedShort.class.should == Fixnum
+ ConstantShort.should == 42
+ ConstantUnsignedShort.should == 42
+ end
+
+ it "of type 'int' or 'unsigned int' is available as a Fixnum in Ruby" do
+ ConstantInt.class.should == Fixnum
+ ConstantUnsignedInt.class.should == Fixnum
+ ConstantInt.should == 42
+ ConstantUnsignedInt.should == 42
+ end
+
+ it "of type 'long' or 'unsigned long' is available as a Fixnum in Ruby" do
+ ConstantLong.class.should == Fixnum
+ ConstantUnsignedLong.class.should == Fixnum
+ ConstantLong.should == 42
+ ConstantUnsignedLong.should == 42
+ end
+
+ it "of type 'long long' or 'unsigned long long' is available as a Fixnum in Ruby" do
+ ConstantLongLong.class.should == Fixnum
+ ConstantUnsignedLongLong.class.should == Fixnum
+ ConstantLongLong.should == 42
+ ConstantUnsignedLongLong.should == 42
+ end
+
+ it "of type 'float' or 'double' is available as a Float in Ruby" do
+ ConstantFloat.class.should == Float
+ ConstantDouble.class.should == Float
+ ConstantFloat.should.be_close(3.1415, 0.0001)
+ ConstantDouble.should.be_close(3.1415, 0.0001)
+ end
+
+ it "of type 'BOOL' is available as true/false in Ruby" do
+ ConstantYES.class.should == TrueClass
+ ConstantNO.class.should == FalseClass
+ ConstantYES.should == true
+ ConstantNO.should == false
+ end
+
+ it "of type 'NSPoint' is available as an NSPoint boxed instance in Ruby" do
+ ConstantNSPoint.class.should == NSPoint
+ ConstantNSPoint.should == NSPoint.new(1, 2)
+ end
+
+ it "of type 'NSSize' is available as an NSSize boxed instance in Ruby" do
+ ConstantNSSize.class.should == NSSize
+ ConstantNSSize.should == NSSize.new(3, 4)
+ end
+
+ it "of type 'NSRect' is available as an NSRect boxed instance in Ruby" do
+ ConstantNSRect.class.should == NSRect
+ ConstantNSRect.should == NSRect.new(NSPoint.new(1, 2), NSSize.new(3, 4))
+ end
+end
Added: MacRuby/branches/experimental/spec/macruby/fixtures/constant.bridgesupport
===================================================================
--- MacRuby/branches/experimental/spec/macruby/fixtures/constant.bridgesupport (rev 0)
+++ MacRuby/branches/experimental/spec/macruby/fixtures/constant.bridgesupport 2009-04-28 05:53:14 UTC (rev 1500)
@@ -0,0 +1,24 @@
+<?xml version='1.0'?>
+<!DOCTYPE signatures SYSTEM "file://localhost/System/Library/DTDs/BridgeSupport.dtd">
+<signatures version='0.9'>
+ <constant name='ConstantChar' type='c'/>
+ <constant name='ConstantClass' type='#'/>
+ <constant name='ConstantDouble' type='d'/>
+ <constant name='ConstantFloat' type='f'/>
+ <constant name='ConstantInt' type='i'/>
+ <constant name='ConstantLong' type='l'/>
+ <constant name='ConstantLongLong' type='q'/>
+ <constant name='ConstantNO' type='B'/>
+ <constant name='ConstantNSPoint' type='{_NSPoint=ff}' type64='{CGPoint=dd}'/>
+ <constant name='ConstantNSRect' type='{_NSRect={_NSPoint=ff}{_NSSize=ff}}' type64='{CGRect={CGPoint=dd}{CGSize=dd}}'/>
+ <constant name='ConstantNSSize' type='{_NSSize=ff}' type64='{CGSize=dd}'/>
+ <constant name='ConstantObject' type='@'/>
+ <constant name='ConstantSEL' type=':'/>
+ <constant name='ConstantShort' type='s'/>
+ <constant name='ConstantUnsignedChar' type='C'/>
+ <constant name='ConstantUnsignedInt' type='I'/>
+ <constant name='ConstantUnsignedLong' type='L'/>
+ <constant name='ConstantUnsignedLongLong' type='Q'/>
+ <constant name='ConstantUnsignedShort' type='S'/>
+ <constant name='ConstantYES' type='B'/>
+</signatures>
Added: MacRuby/branches/experimental/spec/macruby/fixtures/constant.m
===================================================================
--- MacRuby/branches/experimental/spec/macruby/fixtures/constant.m (rev 0)
+++ MacRuby/branches/experimental/spec/macruby/fixtures/constant.m 2009-04-28 05:53:14 UTC (rev 1500)
@@ -0,0 +1,47 @@
+#import <Foundation/Foundation.h>
+
+id ConstantObject;
+Class ConstantClass;
+SEL ConstantSEL;
+char ConstantChar;
+unsigned char ConstantUnsignedChar;
+short ConstantShort;
+unsigned short ConstantUnsignedShort;
+int ConstantInt;
+unsigned int ConstantUnsignedInt;
+long ConstantLong;
+unsigned long ConstantUnsignedLong;
+long long ConstantLongLong;
+unsigned long long ConstantUnsignedLongLong;
+float ConstantFloat;
+double ConstantDouble;
+BOOL ConstantYES;
+BOOL ConstantNO;
+NSPoint ConstantNSPoint;
+NSSize ConstantNSSize;
+NSRect ConstantNSRect;
+
+void
+Init_constant(void)
+{
+ ConstantObject = @"foo";
+ ConstantClass = [NSObject class];
+ ConstantSEL = @selector(foo:with:with:);
+ ConstantChar = 42;
+ ConstantUnsignedChar = 42;
+ ConstantShort = 42;
+ ConstantUnsignedShort = 42;
+ ConstantInt = 42;
+ ConstantUnsignedInt = 42;
+ ConstantLong = 42;
+ ConstantUnsignedLong = 42;
+ ConstantLongLong = 42;
+ ConstantUnsignedLongLong = 42;
+ ConstantFloat = 3.1415;
+ ConstantDouble = 3.1415;
+ ConstantYES = YES;
+ ConstantNO = NO;
+ ConstantNSPoint = NSMakePoint(1, 2);
+ ConstantNSSize = NSMakeSize(3, 4);
+ ConstantNSRect = NSMakeRect(1, 2, 3, 4);
+}
Modified: MacRuby/branches/experimental/spec/macruby/objc_method_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/objc_method_spec.rb 2009-04-28 05:13:10 UTC (rev 1499)
+++ MacRuby/branches/experimental/spec/macruby/objc_method_spec.rb 2009-04-28 05:53:14 UTC (rev 1500)
@@ -5,13 +5,6 @@
fixture_source = File.dirname(__FILE__) + '/fixtures/method.m'
fixture_ext = '/tmp/method.bundle'
if !File.exist?(fixture_ext) or File.mtime(fixture_source) > File.mtime(fixture_ext)
-=begin
- # #system is currently broken
- unless system("/usr/bin/gcc #{fixture_source} -o #{fixture_ext} -g -framework Foundation -dynamiclib -fobjc-gc -arch i386 -arch x86_64 -arch ppc")
- $stderr.puts "cannot compile fixture source file `#{fixture_source}' - aborting"
- exit 1
- end
-=end
`/usr/bin/gcc #{fixture_source} -o #{fixture_ext} -g -framework Foundation -dynamiclib -fobjc-gc -arch i386 -arch x86_64 -arch ppc`
end
require '/tmp/method'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090427/48c96c43/attachment.html>
More information about the macruby-changes
mailing list