[macruby-changes] [1461] MacRuby/branches/experimental/spec/frozen/core/array/sample_spec.rb

source_changes at macosforge.org source_changes at macosforge.org
Wed Apr 22 15:11:05 PDT 2009


Revision: 1461
          http://trac.macosforge.org/projects/ruby/changeset/1461
Author:   eloy.de.enige at gmail.com
Date:     2009-04-22 15:11:05 -0700 (Wed, 22 Apr 2009)
Log Message:
-----------
Spec for Array#sample in Ruby 1.9

Added Paths:
-----------
    MacRuby/branches/experimental/spec/frozen/core/array/sample_spec.rb

Added: MacRuby/branches/experimental/spec/frozen/core/array/sample_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/sample_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/array/sample_spec.rb	2009-04-22 22:11:05 UTC (rev 1461)
@@ -0,0 +1,20 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+
+describe "Array#sample" do
+  ruby_version_is "1.9" do
+    it "should select an value from the array" do
+      a = [1,2,3,4]
+      b = [4,3,2,1]
+      10.times {
+        b.include?(a.sample).should be_true
+      }
+    end
+
+    it "should return a nil value if the array is empty" do
+      a = []
+      a.sample.should be_nil
+    end
+  end
+end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090422/3252cae4/attachment-0001.html>


More information about the macruby-changes mailing list