[macruby-changes] [1265] MacRuby/branches/experimental

source_changes at macosforge.org source_changes at macosforge.org
Mon Mar 30 09:33:45 PDT 2009


Revision: 1265
          http://trac.macosforge.org/projects/ruby/changeset/1265
Author:   pthomson at apple.com
Date:     2009-03-30 09:33:45 -0700 (Mon, 30 Mar 2009)
Log Message:
-----------
Enabled one core/io test.

Modified Paths:
--------------
    MacRuby/branches/experimental/include/ruby/ruby.h
    MacRuby/branches/experimental/io.c
    MacRuby/branches/experimental/rakelib/spec.rake
    MacRuby/branches/experimental/spec/frozen/core/io/shared/pos.rb

Modified: MacRuby/branches/experimental/include/ruby/ruby.h
===================================================================
--- MacRuby/branches/experimental/include/ruby/ruby.h	2009-03-30 12:56:11 UTC (rev 1264)
+++ MacRuby/branches/experimental/include/ruby/ruby.h	2009-03-30 16:33:45 UTC (rev 1265)
@@ -1108,7 +1108,7 @@
 }
 #define NATIVE(obj) (rb_is_native((VALUE)obj))
 
-#define CONDITION_TO_BOOLEAN(c) (c ? Qtrue : Qfalse)
+#define CONDITION_TO_BOOLEAN(c) ((c) ? Qtrue : Qfalse)
 
 VALUE rb_box_fixnum(VALUE);
 

Modified: MacRuby/branches/experimental/io.c
===================================================================
--- MacRuby/branches/experimental/io.c	2009-03-30 12:56:11 UTC (rev 1264)
+++ MacRuby/branches/experimental/io.c	2009-03-30 16:33:45 UTC (rev 1265)
@@ -372,6 +372,22 @@
 	    || CFWriteStreamGetStatus(io_struct->writeStream) == kCFStreamStatusOpen);
 }
 
+static bool
+rb_io_is_closed_for_reading(rb_io_t *io_struct) 
+{
+	if (io_struct->readStream == NULL) return true;
+	CFStreamStatus s = CFReadStreamGetStatus(io_struct->readStream);
+	return ((s == kCFStreamStatusNotOpen) || (s == kCFStreamStatusClosed));
+}
+
+static bool
+rb_io_is_closed_for_writing(rb_io_t *io_struct) 
+{
+	if (io_struct->writeStream == NULL) return true;
+	CFStreamStatus s = CFWriteStreamGetStatus(io_struct->writeStream);
+	return ((s == kCFStreamStatusNotOpen) || (s == kCFStreamStatusClosed));
+}
+
 /*
  *  call-seq:
  *     IO.try_convert(obj) -> io or nil
@@ -1760,7 +1776,8 @@
 static VALUE
 rb_io_closed(VALUE io, SEL sel)
 {
-    rb_notimplement();
+	rb_io_t *ios = ExtractIOStruct(io);
+	return CONDITION_TO_BOOLEAN(rb_io_is_closed_for_writing(ios) && rb_io_is_closed_for_reading(ios));
 }
 
 /*
@@ -2191,7 +2208,13 @@
 rb_f_open(VALUE klass, SEL sel, int argc, VALUE *argv)
 {
     VALUE io = rb_class_new_instance(argc, argv, rb_cFile);
-    return rb_file_open(io, argc, argv);
+    io = rb_file_open(io, argc, argv);
+    if (rb_block_given_p()) {
+        VALUE ret = rb_vm_yield(1, &io);
+        rb_io_close_m(io, 0);
+        return ret;
+    }
+	return io;
 }
 
 /*

Modified: MacRuby/branches/experimental/rakelib/spec.rake
===================================================================
--- MacRuby/branches/experimental/rakelib/spec.rake	2009-03-30 12:56:11 UTC (rev 1264)
+++ MacRuby/branches/experimental/rakelib/spec.rake	2009-03-30 16:33:45 UTC (rev 1265)
@@ -27,6 +27,11 @@
     while
   }
   
+  KNOWN_GOOD_CORE_IO = %w{
+    closed
+    tell
+  }
+  
   desc "Run all language known good spec files which should be fully green (does not use tags)"
   task :green do
     files = FileList["spec/frozen/language/{#{KNOWN_GOOD.join(',')}}_spec.rb"]
@@ -44,6 +49,18 @@
     sh "./mspec/bin/mspec ci -B ./spec/frozen/macruby.mspec spec/frozen/language"
   end
   
+  desc "Try to run IO tests"
+  task :gdbio do
+    files = FileList["spec/frozen/core/io/{#{KNOWN_GOOD_CORE_IO.join(',')}}_spec.rb"]
+    sh "gdb --args ./miniruby -v -I./mspec/lib -I./lib ./mspec/bin/mspec-run #{files.join(' ')}"
+  end
+  
+  desc "Try to run IO tests"
+  task :io do
+    files = FileList["spec/frozen/core/io/{#{KNOWN_GOOD_CORE_IO.join(',')}}_spec.rb"]
+    sh "./miniruby -v -I./mspec/lib -I./lib ./mspec/bin/mspec-run #{files.join(' ')}"
+  end
+  
   desc "Run language examples that are known to fail"
   task :fails do
     sh "./mspec/bin/mspec run -g fails -B ./spec/frozen/macruby.mspec spec/frozen/language"

Modified: MacRuby/branches/experimental/spec/frozen/core/io/shared/pos.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/shared/pos.rb	2009-03-30 12:56:11 UTC (rev 1264)
+++ MacRuby/branches/experimental/spec/frozen/core/io/shared/pos.rb	2009-03-30 16:33:45 UTC (rev 1265)
@@ -1,4 +1,4 @@
-describe :io_pos, :shared => true do
+describe(:io_pos, {:shared => true}) do
   before :each do
     @fname = 'test.txt'
     File.open @fname, 'w' do |f| f.write "123" end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090330/996f1bc4/attachment.html>


More information about the macruby-changes mailing list