[macruby-changes] [1879] MacRuby/branches/experimental/spec/frozen
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jun 18 13:38:26 PDT 2009
Revision: 1879
http://trac.macosforge.org/projects/ruby/changeset/1879
Author: eloy.de.enige at gmail.com
Date: 2009-06-18 13:38:24 -0700 (Thu, 18 Jun 2009)
Log Message:
-----------
Updated RubySpec to 7072d6def04d6fd23244839986e234da76d9a5a0
Modified Paths:
--------------
MacRuby/branches/experimental/spec/frozen/TODO
MacRuby/branches/experimental/spec/frozen/core/argf/close_spec.rb
MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_byte.rb
MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_char.rb
MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_line.rb
MacRuby/branches/experimental/spec/frozen/core/argf/skip_spec.rb
MacRuby/branches/experimental/spec/frozen/core/bignum/comparison_spec.rb
MacRuby/branches/experimental/spec/frozen/core/fiber/resume_spec_disabled.rb
MacRuby/branches/experimental/spec/frozen/core/fiber/shared/resume.rb
MacRuby/branches/experimental/spec/frozen/core/file/join_spec.rb
MacRuby/branches/experimental/spec/frozen/core/float/abs_spec.rb
MacRuby/branches/experimental/spec/frozen/core/float/comparison_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/callcc_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/caller_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/require_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/respond_to_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/include_spec.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/abs_spec.rb
MacRuby/branches/experimental/spec/frozen/core/objectspace/define_finalizer_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/Rational_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/abs_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/coerce_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/comparison_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/denominator_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/divide_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/divmod_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/equal_value_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/exponent_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/hash_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/initialize_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/inspect_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/minus_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/modulo_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/multiply_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/new_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/numerator_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/plus_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/reduce_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/to_f_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/to_i_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/to_r_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/to_s_spec.rb
MacRuby/branches/experimental/spec/frozen/ruby.1.8.mspec
MacRuby/branches/experimental/spec/frozen/upstream
Added Paths:
-----------
MacRuby/branches/experimental/spec/frozen/core/complex/
MacRuby/branches/experimental/spec/frozen/core/complex/rect_spec.rb
MacRuby/branches/experimental/spec/frozen/core/complex/rectangular_spec.rb
MacRuby/branches/experimental/spec/frozen/core/complex/shared/
MacRuby/branches/experimental/spec/frozen/core/complex/shared/rect.rb
MacRuby/branches/experimental/spec/frozen/core/float/denominator_spec.rb
MacRuby/branches/experimental/spec/frozen/core/float/fdiv_spec.rb
MacRuby/branches/experimental/spec/frozen/core/float/magnitude_spec.rb
MacRuby/branches/experimental/spec/frozen/core/float/numerator_spec.rb
MacRuby/branches/experimental/spec/frozen/core/float/shared/abs.rb
MacRuby/branches/experimental/spec/frozen/core/integer/denominator_spec.rb
MacRuby/branches/experimental/spec/frozen/core/integer/gcd_spec.rb
MacRuby/branches/experimental/spec/frozen/core/integer/gcdlcm_spec.rb
MacRuby/branches/experimental/spec/frozen/core/integer/lcm_spec.rb
MacRuby/branches/experimental/spec/frozen/core/integer/numerator_spec.rb
MacRuby/branches/experimental/spec/frozen/core/integer/to_r_spec.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/angle_spec.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/arg_spec.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/conj_spec.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/conjugate_spec.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/denominator_spec.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/imag_spec.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/imaginary_spec.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/magnitude_spec.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/numerator_spec.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/phase_spec.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/polar_spec.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/real_spec.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/rect_spec.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/rectangular_spec.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/shared/
MacRuby/branches/experimental/spec/frozen/core/numeric/shared/abs.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/shared/conj.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/shared/imag.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/shared/phase.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/shared/rect.rb
MacRuby/branches/experimental/spec/frozen/core/numeric/to_c_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/
MacRuby/branches/experimental/spec/frozen/core/rational/Rational_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/abs_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/ceil_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/coerce_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/comparison_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/denominator_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/div_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/divide_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/divmod_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/equal_value_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/exponent_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/fdiv_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/floor_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/hash_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/initialize_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/inspect_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/minus_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/modulo_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/multiply_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/numerator_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/plus_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/quo_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/remainder_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/round_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/to_f_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/to_i_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/to_r_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/to_s_spec.rb
MacRuby/branches/experimental/spec/frozen/core/rational/truncate_spec.rb
MacRuby/branches/experimental/spec/frozen/library/enumerator/next_spec.rb
MacRuby/branches/experimental/spec/frozen/library/enumerator/rewind_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/ceil_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/div_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/fdiv_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/floor_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/quo_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/remainder_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/round_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/truncate_spec.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/
MacRuby/branches/experimental/spec/frozen/shared/rational/Rational.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/abs.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/ceil.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/coerce.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/comparison.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/denominator.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/div.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/divide.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/divmod.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/equal_value.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/exponent.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/fdiv.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/floor.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/hash.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/initialize.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/inspect.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/marshal_dump.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/marshal_load.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/minus.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/modulo.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/multiply.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/new.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/numerator.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/plus.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/quo.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/reduce.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/remainder.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/round.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/to_f.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/to_i.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/to_r.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/to_s.rb
MacRuby/branches/experimental/spec/frozen/shared/rational/truncate.rb
MacRuby/branches/experimental/spec/frozen/tags/1.8/
MacRuby/branches/experimental/spec/frozen/tags/1.8/library/
MacRuby/branches/experimental/spec/frozen/tags/1.8/library/rational/
MacRuby/branches/experimental/spec/frozen/tags/1.8/library/rational/div_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/fiber/
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/fiber/resume_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/macruby/core/objectspace/
MacRuby/branches/experimental/spec/frozen/tags/macruby/core/objectspace/define_finalizer_tags.txt
Removed Paths:
-------------
MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/Rational_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/coerce_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/divmod_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/equal_value_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/exponent_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/initialize_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/inspect_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/new_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/reduce_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/to_r_tags.txt
Modified: MacRuby/branches/experimental/spec/frozen/TODO
===================================================================
--- MacRuby/branches/experimental/spec/frozen/TODO 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/TODO 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,59 +1,49 @@
* Decide a way to test methods that are only visible given a specific
-command-line option. For example, Kernel#gsub with -n/-p on 1.9.
+ command-line option. For example, Kernel#gsub with -n/-p on 1.9.
* Decide how to guard bugs that are regressions. IOW, if a bug appears in 1.9
-but not in 1.8, we should be able to guard it from 1.9 while still yielding to
-1.8.
+ but not in 1.8, we should be able to guard it from 1.9 while still yielding
+ to 1.8.
* Look at automating discovery of guarded bugs which have been fixed. Use
-* mocks for all Math functions that coerce with #to_f; currently a fixture
-is used.
-* Rational and Complex moved from library/ to core/ in 1.9. Where do we locate
-* the tests?
-* Confirm that 1.9 tags can be removed when the corresponding tests pass on
-1.9 trunk.
-* File ticket about ARGF#each_char, ARGF#each_byte, ARGF#chars, and ARGF#bytes
-* returning nil on 1.9.
+ mocks for all Math functions that coerce with #to_f; currently a fixture
+ is used.
* Consider filing ticket about 1.8.6's ARGF#readlines returning nil at the end
-of a stream. 1.8.7+ returns an empty Array, as the rdoc since 1.8.6 implies.
+ of a stream. 1.8.7+ returns an empty Array, as the rdoc since 1.8.6 implies.
* File ticket: $ ruby86 -e 'p ARGF.skip'
--e:1:in `skip': undefined method `close' for false:FalseClass (NoMethodError)
- from -e:1
-* File ticket: "ruby -e 'p ARGF.read; ARGF.skip'" raises "closed stream
-(IOError)" when two files are given. ARGF#skip should be a no-op when there
-are no more files.
-* Determine correct behaviour of ARGF#skip, file ticket if necessary, then
-update failing tests in core/argf/skip_spec.rb.
+ -e:1:in `skip': undefined method `close' for false:FalseClass (NoMethodError)
+ from -e:1 (Reported as bug #1653; update spec based on outcome).
* The failing ARGF#lineno tests are due to a race-ish condition whereby if the
-test is executed in the same run as other ARGF tests the #lineno value isn't
-reset. This can be fixed by explicitly reseting #lineno in the test, but
-that could mask another bug... Figure out who's to blame here.
-* Refactor Kernel.require specification; it's messy and ungainly.
+ test is executed in the same run as other ARGF tests the #lineno value isn't
+ reset. This can be fixed by explicitly reseting #lineno in the test, but
+ that could mask another bug... Figure out who's to blame here.
+* Use the variable matchers which take into consideration the difference of the
+ returned type of variable name. Which is String on 1.8 and Symbol on 1.9.
+ Examples include: have_constant, have_instance_variable, etc.
+* Ascertain backport policy for 1.9.2 -> 1.9.1 -> 1.8.7. Are bug fixes merged
+ backwards by default, or is it all case by case? The answer will inform how
+ we handle ruby_bug guards that pass on HEAD, but fail on earlier versions.
+# Windows
+==========
+* Run core/kernel/require_spec.rb on Windows, check all tests pass; fix as
+ necessary.
+* Confirm that core/dir/home_spec.rb passes on Windows under 1.9.
+
+# 1.8
+=========
+* File ticket about Rational(1, 2) != Rational.new!(4, 8) on 1.8...
+
# 1.9
=========
* Methods expecting filenames or paths should call #to_path on non-String
-arguments. Tests need adding, and tickets may need filing for non-conforming
-methods.
+ arguments. Tests need adding, and tickets may need filing for non-conforming
+ methods.
* Methods that could modify a frozen receiver should raise RuntimeError, even
-if the method's arguments are such that no modification would occur.
+ if the method's arguments are such that no modification would occur.
* The inclusion of 'rational' by default has resulted in ZeroDivisionErrors
-being raised where they previously weren't. What is the rule of thumb in
-determining whether this outcome is intentional?
-
-## Rational
-===========
-
- (All questions below were posed in:
-<http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/23843>)
-
-* Determine whether Rational::Unify was intentionally removed.
-* Determine whether Rational#new! was intentionally removed. If not, will
-there be a method to construct a Rational object without simplifying its
-arguments?
-* Determine whether Rational#coerce is supposed to call #to_f on non-numeric
-argument. 1.8 does.
-* Determine whether Rational.allocate has intentionally been removed. Presumably
-so because on 1.8 it creates Rational(nil, nil), which is illegal on 1.9.
-* Determine whether Rational.reduce has intentionally been removed. Presumably
-so because Rational() serves the same function.
-* Determine whether Rational#inspect and #to_s are intentionally different on
-1.9
+ being raised where they previously weren't. What is the rule of thumb in
+ determining whether this outcome is intentional?
+* Discover why core/kernel/caller_spec.rb has failures on 1.9. What's the
+ cause of this behaviour?
+* Unify treatment of bugs after conversation with brixen. Bugs that occur only
+ in 1.9 shouldn't be guarded; we just tag them with the bug number, e.g. " mspec
+ tag --add 'fails(#555)' -e 'the failing stuff' path/to/spec".
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/close_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/close_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/close_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -23,4 +23,28 @@
ARGF.close.should equal(ARGF)
end
end
+
+ # This passes on 1.9, but fails on 1.8. matz claims to have fixed it in the
+ # attached ticket. The actual exception raised may differ; this will need
+ # checking.
+ ruby_bug "#1633", "1.8" do
+ it "raises an IOError if called on a closed stream" do
+ argv [@file1_name] do
+ lambda { ARGF.close }.should_not raise_error
+ lambda { ARGF.close }.should raise_error(IOError)
+ end
+ end
+ end
+
+ # This passes on 1.8.6 and 1.8.7 but fails on 1.9. matz confirmed that it
+ # should pass in the referenced bug report
+ ruby_bug "#1633", "1.9.2" do
+ it "can close STDIN" do
+ argv [] do
+ ARGV.size.should == 0
+ ARGF.close.should == ARGF
+ ARGF.closed?.should be_true
+ end
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_byte.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_byte.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_byte.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -20,9 +20,11 @@
end
end
- it "returns self when passed a block" do
- argv [@file1_name, @file2_name] do
- ARGF.send(@method) {}.should equal(ARGF)
+ ruby_bug "#1633", "1.9.2" do
+ it "returns self when passed a block" do
+ argv [@file1_name, @file2_name] do
+ ARGF.send(@method) {}.should equal(ARGF)
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_char.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_char.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_char.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -20,9 +20,11 @@
end
end
- it "returns self when passed a block" do
- argv [@file1_name, @file2_name] do
- ARGF.send(@method) {}.should equal(ARGF)
+ ruby_bug "#1633", "1.9.2" do
+ it "returns self when passed a block" do
+ argv [@file1_name, @file2_name] do
+ ARGF.send(@method) {}.should equal(ARGF)
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_line.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_line.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_line.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -18,4 +18,12 @@
lines.should == @lines
end
end
+
+ ruby_bug "#1633", "1.9.2" do
+ it "returns self when passed a block" do
+ argv [@file1_name, @file2_name] do
+ ARGF.send(@method) {}.should equal(ARGF)
+ end
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/skip_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/skip_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/skip_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -36,4 +36,12 @@
ARGF.gets.should == nil
end
end
+
+ # This is similar to the test above, but it uncovered one of the regressions
+ # documented in bug #1633. This has been fixed on 1.9 HEAD
+ it "has no effect when the current file is the last" do
+ argv [@file1_name] do
+ lambda { ARGF.skip }.should_not raise_error
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/bignum/comparison_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/bignum/comparison_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/bignum/comparison_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -3,6 +3,7 @@
describe "Bignum#<=>" do
before(:each) do
@bignum = bignum_value(96)
+ @inf = 1/0.0
end
it "returns -1 when self is less than the given argument" do
@@ -26,4 +27,45 @@
(@bignum <=> mock('str')).should == nil
(@bignum <=> 'test').should == nil
end
+
+ # TODO: Remove duplicate bug guards when ruby_bug is updated.
+ ruby_bug "[ruby-dev:38672] [Bug #1645]", "1.8.7.174" do
+ # The 4 tests below are taken from matz's revision 23730 for Ruby trunk
+ #
+ it "returns 1 when self is Infinity and other is a Bignum" do
+ (@inf <=> Float::MAX.to_i*2).should == 1
+ end
+
+ it "returns 1 when self is negative and other is Infinty" do
+ (-Float::MAX.to_i*2 <=> @inf).should == 1
+ end
+
+ it "returns -1 when self is -Infinity and other is negative" do
+ (- at inf <=> -Float::MAX.to_i*2).should == -1
+ end
+
+ it "returns -1 when self is negative and other is -Infinity" do
+ (- at inf <=> -Float::MAX.to_i*2).should == -1
+ end
+ end
+
+ ruby_bug "[ruby-dev:38672] [Bug #1645]", "1.8.6.369" do
+ # The 4 tests below are taken from matz's revision 23730 for Ruby trunk
+ #
+ it "returns 1 when self is Infinity and other is a Bignum" do
+ (@inf <=> Float::MAX.to_i*2).should == 1
+ end
+
+ it "returns 1 when self is negative and other is Infinty" do
+ (-Float::MAX.to_i*2 <=> @inf).should == 1
+ end
+
+ it "returns -1 when self is -Infinity and other is negative" do
+ (- at inf <=> -Float::MAX.to_i*2).should == -1
+ end
+
+ it "returns -1 when self is negative and other is -Infinity" do
+ (- at inf <=> -Float::MAX.to_i*2).should == -1
+ end
+ end
end
Added: MacRuby/branches/experimental/spec/frozen/core/complex/rect_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/complex/rect_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/complex/rect_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/rect'
+
+ruby_version_is "1.9" do
+ describe "Complex#rect" do
+ it_behaves_like(:complex_rect, :rect)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/complex/rectangular_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/complex/rectangular_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/complex/rectangular_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/rect'
+
+ruby_version_is "1.9" do
+ describe "Complex#rectangular" do
+ it_behaves_like(:complex_rect, :rectangular)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/complex/shared/rect.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/complex/shared/rect.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/complex/shared/rect.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,45 @@
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+describe :complex_rect, :shared => true do
+ before(:each) do
+ @numbers = [
+ Complex(1),
+ Complex(0, 20),
+ Complex(0, 0),
+ Complex(0.0),
+ Complex(9999999**99),
+ Complex(-20),
+ Complex.polar(76, 10)
+ ]
+ end
+
+ it "returns an Array" do
+ @numbers.each do |number|
+ number.send(@method).should be_an_instance_of(Array)
+ end
+ end
+
+ it "returns a two-element Array" do
+ @numbers.each do |number|
+ number.send(@method).size.should == 2
+ end
+ end
+
+ it "returns the real part of self as the first element" do
+ @numbers.each do |number|
+ number.send(@method).first.should == number.real
+ end
+ end
+
+ it "returns the imaginary part of self as the last element" do
+ @numbers.each do |number|
+ number.send(@method).last.should == number.imaginary
+ end
+ end
+
+ it "raises an ArgumentError if given any arguments" do
+ @numbers.each do |number|
+ lambda { number.send(@method, number) }.should raise_error(ArgumentError)
+ end
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/fiber/resume_spec_disabled.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/fiber/resume_spec_disabled.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/fiber/resume_spec_disabled.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -18,5 +18,17 @@
fiber2.resume
lambda { fiber2.resume }.should raise_error(FiberError)
end
+
+ # http://redmine.ruby-lang.org/issues/show/595
+ it "executes the ensure clause" do
+ fib = Fiber.new{
+ begin
+ Fiber.yield :begin
+ ensure
+ :ensure
+ end
+ }
+ fib.resume.should == :ensure
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/fiber/shared/resume.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/fiber/shared/resume.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/fiber/shared/resume.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,4 +1,5 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
+require 'fiber'
ruby_version_is "1.9" do
describe :resume, :shared => :true do
@@ -67,5 +68,5 @@
lambda { fiber.send(@method) }.should raise_error(LocalJumpError)
end
- end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/file/join_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/file/join_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/file/join_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -93,4 +93,14 @@
File.join("usr", bin).should == "usr/bin"
end
+ ruby_version_is "1.9" do
+ it "calls #to_path" do
+ lambda { File.join(mock('x')) }.should raise_error(TypeError)
+
+ bin = mock("bin")
+ bin.should_receive(:to_path).exactly(:twice).and_return("bin")
+ File.join(bin).should == "bin"
+ File.join("usr", bin).should == "usr/bin"
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/float/abs_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/float/abs_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/float/abs_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,9 +1,5 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/abs'
describe "Float#abs" do
- it "returns the absolute value" do
- -99.1.abs.should be_close(99.1, TOLERANCE)
- 4.5.abs.should be_close(4.5, TOLERANCE)
- 0.0.abs.should be_close(0.0, TOLERANCE)
- end
+ it_behaves_like(:float_abs, :abs)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/float/comparison_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/float/comparison_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/float/comparison_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,9 +1,55 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe "Float#<=>" do
+ before(:all) do
+ @inf = 1/0.0
+ @nan = 0/0.0
+ end
+
it "returns -1, 0, 1 when self is less than, equal, or greater than other" do
(1.5 <=> 5).should == -1
(2.45 <=> 2.45).should == 0
((bignum_value*1.1) <=> bignum_value).should == 1
end
+
+ # TODO: Remove duplicate ruby_bug guards when ruby_bug is fixed.
+ ruby_bug "[ruby-dev:38672] [Bug #1645]", "1.8.6.369" do
+ # The 4 tests below are taken from matz's revision 23730 for Ruby trunk
+ #
+ it "returns 1 when self is Infinity and other is a Bignum" do
+ (@inf <=> Float::MAX.to_i*2).should == 1
+ end
+
+ it "returns 1 when self is negative and other is Infinty" do
+ (-Float::MAX.to_i*2 <=> @inf).should == 1
+ end
+
+ it "returns -1 when self is -Infinity and other is negative" do
+ (- at inf <=> -Float::MAX.to_i*2).should == -1
+ end
+
+ it "returns -1 when self is negative and other is -Infinity" do
+ (- at inf <=> -Float::MAX.to_i*2).should == -1
+ end
+ end
+
+ ruby_bug "[ruby-dev:38672] [Bug #1645]", "1.8.7.174" do
+ # The 4 tests below are taken from matz's revision 23730 for Ruby trunk
+ #
+ it "returns 1 when self is Infinity and other is a Bignum" do
+ (@inf <=> Float::MAX.to_i*2).should == 1
+ end
+
+ it "returns 1 when self is negative and other is Infinty" do
+ (-Float::MAX.to_i*2 <=> @inf).should == 1
+ end
+
+ it "returns -1 when self is -Infinity and other is negative" do
+ (- at inf <=> -Float::MAX.to_i*2).should == -1
+ end
+
+ it "returns -1 when self is negative and other is -Infinity" do
+ (- at inf <=> -Float::MAX.to_i*2).should == -1
+ end
+ end
end
Added: MacRuby/branches/experimental/spec/frozen/core/float/denominator_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/float/denominator_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/float/denominator_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,31 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.9" do
+ describe "Float#denominator" do
+ before(:each) do
+ @numbers = [
+ 0.0,
+ 29871.22736282,
+ 7772222663.0,
+ 1.4592,
+ ].map {|n| [0-n, n]}.flatten
+ end
+
+ it "returns an Integer" do
+ @numbers.each do |number|
+ number.denominator.should be_kind_of(Integer)
+ end
+ end
+
+ it "converts self to a Rational and returns the denominator" do
+ @numbers.each do |number|
+ number.denominator.should == Rational(number).denominator
+ end
+ end
+
+ it "returns 1 for NaN and Infinity" do
+ (0/0.0).denominator.should == 1
+ (1/0.0).denominator.should == 1
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/float/fdiv_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/float/fdiv_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/float/fdiv_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,68 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.9" do
+ describe "Float#fdiv" do
+ before(:all) do
+ @inf = 1/0.00
+ @nan = 0/0.0
+ end
+
+ it "performs floating-point division between self and a Fixnum" do
+ 8.9.fdiv(7).should == 1.2714285714285716
+ end
+
+ it "performs floating-point division between self and a Bignum" do
+ 8.9.fdiv(9999999999999**9).should == 8.900000000008011e-117
+ end
+
+ it "performs floating-point division between self and a Float" do
+ 2827.22.fdiv(872.111111).should == 3.2418116961704433
+ end
+
+ it "returns NaN when the argument is NaN" do
+ -1819.999999.fdiv(@nan).nan?.should be_true
+ 11109.1981271.fdiv(@nan).nan?.should be_true
+ end
+
+ it "returns Infinity when the argument is 0.0" do
+ 2827.22.fdiv(0.0).infinite?.should == 1
+ end
+
+ it "returns -Infinity when the argument is 0.0 and self is negative" do
+ -48229.282.fdiv(0.0).infinite?.should == -1
+ end
+
+ it "returns Infinity when the argument is 0" do
+ 2827.22.fdiv(0).infinite?.should == 1
+ end
+
+ it "returns -Infinity when the argument is 0 and self is negative" do
+ -48229.282.fdiv(0).infinite?.should == -1
+ end
+
+ it "returns 0.0 when the argument is Infinity" do
+ 47292.2821.fdiv(@inf).should == 0.0
+ end
+
+ it "returns -0.0 when the argument is -Infinity" do
+ 1.9999918.fdiv(- at inf).should == -0.0
+ end
+
+ it "performs floating-point division between self and a Rational" do
+ 74620.09.fdiv(Rational(2,3)).should == 111930.135
+ end
+
+ it "performs floating-point division between self and a Complex" do
+ 74620.09.fdiv(Complex(8,2)).should == Complex(
+ 8778.834117647059, -2194.7085294117646)
+ end
+
+ it "raises a TypeError when argument isn't numeric" do
+ lambda { 27292.2.fdiv(mock('non-numeric')) }.should raise_error(TypeError)
+ end
+
+ it "raises an ArgumentError when passed multiple arguments" do
+ lambda { 272.221.fdiv(6,0.2) }.should raise_error(ArgumentError)
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/float/magnitude_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/float/magnitude_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/float/magnitude_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/shared/abs'
+
+ruby_version_is "1.9" do
+ describe "Float#magnitude" do
+ it_behaves_like(:float_abs, :magnitude)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/float/numerator_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/float/numerator_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/float/numerator_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,47 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.9" do
+ describe "Numeric#numerator" do
+ before(:all) do
+ @numbers = [
+ 29871.2722891,
+ 999.1**99.928888,
+ -72628191273.22,
+ 29282.2827,
+ -2927.00091,
+ 12.0,
+ Float::MAX,
+ ]
+ end
+
+ it "converts self to a Rational object then returns its numerator" do
+ @numbers.each do |number|
+ number.infinite?.should be_nil
+ number.numerator.should == Rational(number).numerator
+ end
+ end
+
+ it "returns 0 for 0.0" do
+ 0.0.numerator.should == 0
+ end
+
+ it "returns NaN for NaN" do
+ nan = 0/0.0
+ nan.nan?.should be_true
+ nan.numerator.nan?.should be_true
+ end
+
+ it "returns Infinity for Infinity" do
+ inf = 1/0.0
+ inf.infinite?.should == 1
+ inf.numerator.infinite?.should == 1
+ end
+
+ it "returns -Infinity for Infinity" do
+ inf = -(1/0.0)
+ inf.infinite?.should == -1
+ inf.numerator.infinite?.should == -1
+ end
+
+ end
+end
Copied: MacRuby/branches/experimental/spec/frozen/core/float/shared/abs.rb (from rev 1878, MacRuby/branches/experimental/spec/frozen/core/float/abs_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/float/shared/abs.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/float/shared/abs.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,9 @@
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+describe :float_abs, :shared => true do
+ it "returns the absolute value" do
+ -99.1.abs.should be_close(99.1, TOLERANCE)
+ 4.5.abs.should be_close(4.5, TOLERANCE)
+ 0.0.abs.should be_close(0.0, TOLERANCE)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/integer/denominator_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/integer/denominator_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/integer/denominator_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,22 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.9" do
+ describe "Integer#denominator" do
+ # The Numeric child classes override this method, so their behaviour is
+ # specified in the appropriate place
+ before(:each) do
+ @numbers = [
+ 20, # Integer
+ -2709, # Negative Integer
+ 99999999**99, # Bignum
+ -99999**621, # Negative BigNum
+ 0,
+ 1
+ ]
+ end
+
+ it "returns 1" do
+ @numbers.each {|number| number.denominator.should == 1}
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/integer/gcd_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/integer/gcd_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/integer/gcd_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,60 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe "Integer#gcd" do
+ ruby_version_is "1.9" do
+ it "returns self if equal to the argument" do
+ 1.gcd(1).should == 1
+ 398.gcd(398).should == 398
+ end
+
+ it "returns an Integer" do
+ 36.gcd(6).should be_kind_of(Integer)
+ 4.gcd(20981).should be_kind_of(Integer)
+ end
+
+ it "returns the greatest common divisor of self and argument" do
+ 10.gcd(5).should == 5
+ 200.gcd(20).should == 20
+ end
+
+ it "returns a positive integer even if self is negative" do
+ -12.gcd(6).should == 6
+ -100.gcd(100).should == 100
+ end
+
+ it "returns a positive integer even if the argument is negative" do
+ 12.gcd(-6).should == 6
+ 100.gcd(-100).should == 100
+ end
+
+ it "returns a positive integer even if both self and argument are negative" do
+ -12.gcd(-6).should == 6
+ -100.gcd(-100).should == 100
+ end
+
+ it "accepts a Bignum argument" do
+ bignum = 9999**99
+ bignum.should be_kind_of(Bignum)
+ 99.gcd(bignum).should == 99
+ end
+
+ it "works if self is a Bignum" do
+ bignum = 9999**99
+ bignum.should be_kind_of(Bignum)
+ bignum.gcd(99).should == 99
+ end
+
+ it "raises an ArgumentError if not given an argument" do
+ lambda { 12.gcd }.should raise_error(ArgumentError)
+ end
+
+ it "raises an ArgumentError if given more than one argument" do
+ lambda { 12.gcd(30, 20) }.should raise_error(ArgumentError)
+ end
+
+ it "raises an ArgumentError unless the argument is an Integer" do
+ lambda { 39.gcd(3.8) }.should raise_error(ArgumentError)
+ lambda { 45872.gcd([]) }.should raise_error(ArgumentError)
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/integer/gcdlcm_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/integer/gcdlcm_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/integer/gcdlcm_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,55 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe "Integer#gcdlcm" do
+ ruby_version_is "1.9" do
+ it "returns [self, self] if self is equal to the argument" do
+ 1.gcdlcm(1).should == [1, 1]
+ 398.gcdlcm(398).should == [398, 398]
+ end
+
+ it "returns an Array" do
+ 36.gcdlcm(6).should be_kind_of(Array)
+ 4.gcdlcm(20981).should be_kind_of(Array)
+ end
+
+ it "returns a two-element Array" do
+ 36.gcdlcm(876).size.should == 2
+ 29.gcdlcm(17).size.should == 2
+ end
+
+ it "returns the greatest common divisor of self and argument as the first element" do
+ 10.gcdlcm(5)[0].should == 10.gcd(5)
+ 200.gcdlcm(20)[0].should == 200.gcd(20)
+ end
+
+ it "returns the least common multiple of self and argument as the last element" do
+ 10.gcdlcm(5)[1].should == 10.lcm(5)
+ 200.gcdlcm(20)[1].should == 200.lcm(20)
+ end
+
+ it "accepts a Bignum argument" do
+ bignum = 91999**99
+ bignum.should be_kind_of(Bignum)
+ 99.gcdlcm(bignum).should == [99.gcd(bignum), 99.lcm(bignum)]
+ end
+
+ it "works if self is a Bignum" do
+ bignum = 9999**89
+ bignum.should be_kind_of(Bignum)
+ bignum.gcdlcm(99).should == [bignum.gcd(99), bignum.lcm(99)]
+ end
+
+ it "raises an ArgumentError if not given an argument" do
+ lambda { 12.gcdlcm }.should raise_error(ArgumentError)
+ end
+
+ it "raises an ArgumentError if given more than one argument" do
+ lambda { 12.gcdlcm(30, 20) }.should raise_error(ArgumentError)
+ end
+
+ it "raises an ArgumentError unless the argument is an Integer" do
+ lambda { 39.gcdlcm(3.8) }.should raise_error(ArgumentError)
+ lambda { 45872.gcdlcm([]) }.should raise_error(ArgumentError)
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/integer/lcm_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/integer/lcm_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/integer/lcm_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,60 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe "Integer#lcm" do
+ ruby_version_is "1.9" do
+ it "returns self if equal to the argument" do
+ 1.lcm(1).should == 1
+ 398.lcm(398).should == 398
+ end
+
+ it "returns an Integer" do
+ 36.lcm(6).should be_kind_of(Integer)
+ 4.lcm(20981).should be_kind_of(Integer)
+ end
+
+ it "returns the least common multiple of self and argument" do
+ 200.lcm(2001).should == 400200
+ 99.lcm(90).should == 990
+ end
+
+ it "returns a positive integer even if self is negative" do
+ -12.lcm(6).should == 12
+ -100.lcm(100).should == 100
+ end
+
+ it "returns a positive integer even if the argument is negative" do
+ 12.lcm(-6).should == 12
+ 100.lcm(-100).should == 100
+ end
+
+ it "returns a positive integer even if both self and argument are negative" do
+ -12.lcm(-6).should == 12
+ -100.lcm(-100).should == 100
+ end
+
+ it "accepts a Bignum argument" do
+ bignum = 9999**99
+ bignum.should be_kind_of(Bignum)
+ 99.lcm(bignum).should == bignum
+ end
+
+ it "works if self is a Bignum" do
+ bignum = 9999**99
+ bignum.should be_kind_of(Bignum)
+ bignum.lcm(99).should == bignum
+ end
+
+ it "raises an ArgumentError if not given an argument" do
+ lambda { 12.lcm }.should raise_error(ArgumentError)
+ end
+
+ it "raises an ArgumentError if given more than one argument" do
+ lambda { 12.lcm(30, 20) }.should raise_error(ArgumentError)
+ end
+
+ it "raises an ArgumentError unless the argument is an Integer" do
+ lambda { 39.lcm(3.8) }.should raise_error(ArgumentError)
+ lambda { 45872.lcm([]) }.should raise_error(ArgumentError)
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/integer/numerator_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/integer/numerator_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/integer/numerator_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,20 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.9" do
+ describe "Integer#numerator" do
+ before(:all) do
+ @numbers = [
+ 0,
+ 29871,
+ 99999999999999**99,
+ 72628191273,
+ ].map{|n| [-n, n]}.flatten
+ end
+
+ it "returns self" do
+ @numbers.each do |number|
+ number.numerator.should == number
+ end
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/integer/to_r_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/integer/to_r_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/integer/to_r_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,28 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe "Integer#to_r" do
+ ruby_version_is "1.9" do
+ it "returns a Rational object" do
+ 309.to_r.should be_an_instance_of(Rational)
+ end
+
+ it "constructs a rational number with self as the numerator" do
+ 34.to_r.numerator.should == 34
+ end
+
+ it "constructs a rational number with 1 as the denominator" do
+ 298.to_r.denominator.should == 1
+ end
+
+ it "works even if self is a Bignum" do
+ bignum = 99999**999
+ bignum.should be_an_instance_of(Bignum)
+ bignum.to_r.should == Rational(bignum, 1)
+ end
+
+ it "raises an ArgumentError if given any arguments" do
+ lambda { 287.to_r(2) }.should raise_error(ArgumentError)
+ lambda { 9102826.to_r(309, [], 71) }.should raise_error(ArgumentError)
+ end
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/callcc_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/callcc_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/callcc_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -24,9 +24,10 @@
it "is possible to call a continuation multiple times" do
i = 0
cont = nil
- Kernel.callcc {|cont|}
+ @cont = nil
+ Kernel.callcc {|cont| @cont = cont}
i += 1
- cont.call() if i < 5
+ @cont.call() if i < 5
i.should == 5
end
@@ -38,8 +39,9 @@
it "returns the results of continuation once called" do
cont = nil
- a = callcc {|cont| 0}
- cont.call(1) if a == 0
+ @cont = nil
+ a = callcc {|cont| @cont = cont; 0}
+ @cont.call(1) if a == 0
a.should == 1
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/caller_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/caller_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/caller_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -57,7 +57,7 @@
it "returns the correct caller line from a called Proc" do
stack = CallerFixture.entry_point.call
- stack[0].should =~ /caller_fixture1\.rb:31:in `third'/
+ stack[0].should =~ /caller_fixture1\.rb:31:in `(block in )?third'/
stack[1].should =~ /caller_spec\.rb:59/
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/require_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/require_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/require_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -5,19 +5,6 @@
$LOAD_PATH << $require_fixture_dir
$LOAD_PATH << $require_tmp_dir
-$require_spec = nil
-$require_spec_1 = nil
-$require_spec_2 = nil
-$require_spec_3 = nil
-$require_spec_4 = nil
-$require_spec_5 = nil
-$require_spec_6 = nil
-$require_spec_7 = nil
-$require_spec_8 = nil
-$require_spec_9 = nil
-$require_spec_10 = nil
-$require_spec_rooby = nil
-$require_spec_recursive = nil
require 'rbconfig'
@@ -31,18 +18,31 @@
end
# Avoid storing .rbc in repo
- before :all do
+ before :each do
+ # We explicitly delete and recreate our temporary directories every time
+ # to avoid establishing dependencies between tests.
+ FileUtils.rm_rf($require_tmp_dir)
Dir.mkdir($require_tmp_dir)
Dir.chdir($require_tmp_dir) {
FileUtils.touch("require_spec_dummy.#{Config::CONFIG['DLEXT']}")
FileUtils.touch("require_spec_dummy.rb")
}
+ $LOADED_FEATURES.delete_if {|path| path =~ /require_spec/}
+ $require_spec = nil
+ $require_spec_1 = nil
+ $require_spec_2 = nil
+ $require_spec_3 = nil
+ $require_spec_4 = nil
+ $require_spec_5 = nil
+ $require_spec_6 = nil
+ $require_spec_7 = nil
+ $require_spec_8 = nil
+ $require_spec_9 = nil
+ $require_spec_10 = nil
+ $require_spec_rooby = nil
+ $require_spec_recursive = nil
end
- after :all do
- FileUtils.rm_rf($require_tmp_dir)
- end
-
# The files used below just contain code that assigns
# Time.now to the respective global variable so that
# reloads can easily be verified.
@@ -51,151 +51,190 @@
# load the same file. Be careful if you change the order
# or add items.
- it "requires arbitrarily complex files (files with large numbers of AST nodes)" do
- lambda {require File.expand_path(File.dirname(__FILE__)) + '/fixtures/test'}.should_not raise_error
+#######################################
+# PATH RESOLUTION
+#######################################
+
+ it "resolves paths relative to the current working directory" do
+ Dir.chdir($require_fixture_dir) do |dir|
+ require('../../fixtures/require/require_spec_1.rb').should be_true
+ $require_spec_1.should_not be_nil
+ $LOADED_FEATURES.grep(/require_spec_1\.rb/).size.should == 1
+ end
end
- it "loads a .rb from an absolute path and returns true" do
- path = File.expand_path(File.dirname(__FILE__) + '/../../fixtures/require/require_spec_1.rb')
- require(path).should == true
- $require_spec_1.nil?.should == false
+ it "does not expand/resolve qualified files against $LOAD_PATH" do
+ num_features = $LOADED_FEATURES.size
+ Dir.chdir($require_fixture_dir + '/../') do |dir|
+ # This would be a valid path if expanded against the fixture dir
+ lambda { require '../require/require_spec_2.rb' }.should raise_error LoadError
+ end
+ $LOADED_FEATURES.size.should == num_features
end
- ruby_version_is ""..."1.9" do
- it "loads a .rb from a relative path and returns true" do
- Dir.chdir($require_fixture_dir) do |dir|
- $require_spec_1 = nil
- require('../../fixtures/require/require_spec_1.rb').should == true
- $require_spec_1.nil?.should == false
+ it "loads a .rb from an absolute path" do
+ path = File.join($require_fixture_dir, 'require_spec_1.rb')
+ require(path).should be_true
+ $require_spec_1.should_not be_nil
+ end
- $require_spec_1 = nil
- require('./../require/require_spec_1.rb').should == true
- $require_spec_1.nil?.should == false
- end
- end
+ it "collapses consecutive path separators" do
+ abs_path = File.join($require_fixture_dir, '/require_spec_1.rb')
+ path_parts = File.split(abs_path)
+ # Mangle the absolute path so it contains multiple consecutive separator
+ # characters, then require it.
+ require([
+ path_parts[0], File::Separator, path_parts[1]
+ ].join(File::Separator)).should be_true
+ $require_spec_1.should_not be_nil
end
+ # Has been fixed on 1.9.2 HEAD; not backported yet
+ ruby_bug "#1627", "1.9.2" do
ruby_version_is "1.9" do
- it "can load .rb files from relative paths" do
- Dir.chdir($require_fixture_dir) do |dir|
- abs_path = File.expand_path('./../require/require_spec_1.rb')
- $LOADED_FEATURES.delete abs_path
- $require_spec_1 = nil
- require('../../fixtures/require/require_spec_1.rb').should be_true
- $require_spec_1.should_not be_nil
- $LOADED_FEATURES.grep(/require_spec_1\.rb/).should == [abs_path]
+ platform_is_not :windows do
+ it "collapses '../' inside an absolute path" do
+ abs_path = File.expand_path(
+ File.join($require_fixture_dir, 'require_spec_1.rb'))
+ require(abs_path).should be_true
+ # Create an absolute path (beginning at a child of the filesystem
+ # root), containing '../' (to move to the root), then the real
+ # absolute path.
+ require("/tmp/../#{abs_path}")
+ $LOADED_FEATURES.grep(/require_spec_1\.rb/).should == [abs_path]
+ end
end
+
+ # This is untested because I don't have access to a Windows box.
+ platform_is :windows do
+ it "collapses '../' inside an absolute path" do
+ abs_path = File.expand_path(
+ File.join($require_fixture_dir, 'require_spec_1.rb'))
+ require(abs_path).should be_true
+ # Create an absolute path (beginning at a child of the filesystem
+ # root), containing '../' (to move to the root), then the real
+ # absolute path.
+ require("C:\Windows\..\#{abs_path}")
+ $require_spec_1.should_not be_nil
+ end
+ end
end
+ end
- it "collapses consecutive path separators" do
- Dir.chdir($require_fixture_dir) do |dir|
- abs_path = File.expand_path('./../require/require_spec_1.rb')
- $LOADED_FEATURES.delete_if {|p| p =~ /require_spec_1\.rb$/ }
- # Put the absolute path into $LOADED_FEATURES
- require(abs_path).should be_true
- path_parts = File.split(abs_path)
- # Mangle the absolute path so it contains multiple consecutive separator
- # characters, then require it. We've already require'd the canonical
- # form of this path, so this should return false
- require([
- path_parts[0], File::Separator, path_parts[1]
- ].join(File::Separator)).should be_false
+ it "loads an unqualified .rb by looking in $LOAD_PATH and returning true" do
+ require('require_spec_2.rb').should be_true
+ $require_spec_2.should_not be_nil
+ end
- # $LOADED_FEATURES should only contain the absolute path
- $LOADED_FEATURES.grep(/require_spec_1\.rb/).should == [abs_path]
- end
- end
+ it "allows unqualified files to contain path information (just not in the beginning)" do
+ name = (File.dirname(__FILE__) + '/../../fixtures')
+ $LOAD_PATH << name
+ require('require/../require/require_spec_2.rb').should be_true
+ $require_spec_2.should_not be_nil
+ end
- it "collapses '../' inside an absolute path" do
- Dir.chdir($require_fixture_dir) do |dir|
- abs_path = File.expand_path('./../require/require_spec_1.rb')
- $LOADED_FEATURES.delete_if {|p| p =~ /require_spec_1\.rb$/ }
- # Put the absolute path into $LOADED_FEATURES
- require(abs_path).should be_true
- # Create an absolute path (beginning at the filesystem root), containing
- # '../', then the real absolute path.
- #FIXME: Fix to work on Windows. :-(
- require("/tmp/../#{abs_path}").should be_false
+ it "loads a file with ./filename even if . is not in path" do
+ Dir.chdir($require_fixture_dir) do |dir|
+ path_backup = $LOAD_PATH.clone
+ $LOAD_PATH.clear
+ $LOAD_PATH << "Someirrelevantpath"
+ begin
+ require('./require_spec.rb').should be_true
+ ensure
+ $LOAD_PATH.clear
+ $LOAD_PATH.concat(path_backup)
+ end
+ end
+ end
- # $LOADED_FEATURES should only contain the absolute path
- $LOADED_FEATURES.grep(/require_spec_1\.rb/).should == [abs_path]
+#######################################
+# PATH CANONICALIZATION
+#######################################
+
+ # This bug has been fixed on 1.9.2 HEAD.
+ ruby_bug "#1627", "1.9.2" do
+ ruby_version_is "1.9" do
+ it "stores relative paths as absolute paths in $LOADED_FEATURES" do
+ Dir.chdir($require_fixture_dir) do |dir|
+ abs_path = File.expand_path('../require/require_spec_1.rb')
+ require(abs_path).should be_true
+ require("../require/require_spec_1.rb").should be_false
+ $LOADED_FEATURES.grep(/require_spec_1\.rb/).should == [abs_path]
+ end
end
- end
+
+ it "stores ./file paths as absolute paths in $LOADED_FEATURES" do
+ Dir.chdir($require_fixture_dir) do |dir|
+ abs_path = File.expand_path('./require_spec_1.rb')
+ require(abs_path).should be_true
+ require("./require_spec_1.rb").should be_false
+ $LOADED_FEATURES.grep(/require_spec_1\.rb/).should == [abs_path]
+ end
+ end
- it "canonicalizes relative paths" do
- Dir.chdir($require_fixture_dir) do |dir|
- abs_path = File.expand_path('../require/require_spec_1.rb')
- $LOADED_FEATURES.delete_if {|p| p =~ /require_spec_1\.rb$/ }
- # Put the absolute path into $LOADED_FEATURES
- require(abs_path).should be_true
- require("../require/require_spec_1.rb").should be_false
-
- # $LOADED_FEATURES should only contain the absolute path
- $LOADED_FEATURES.grep(/require_spec_1\.rb/).should == [abs_path]
+ it "performs tilde expansion before storing paths in $LOADED_FEATURES" do
+ begin
+ original_home = ENV['HOME'].dup
+ ENV['HOME'] = $require_fixture_dir
+ abs_path = File.expand_path(
+ File.join($require_fixture_dir, 'require_spec_1.rb'))
+ tilde_path = File.join('~', 'require_spec_1.rb')
+ require(tilde_path).should be_true
+ $LOADED_FEATURES.grep(/require_spec_1\.rb/).should == [abs_path]
+ ensure
+ ENV['HOME'] = original_home
+ end
end
- end
- end
- it "loads an unqualified .rb by looking in $LOAD_PATH and returns true" do
- require('require_spec_2.rb').should == true
- $require_spec_2.nil?.should == false
- end
+ it "collapses multiple consecutive path separators before storing in $LOADED_FEATURES" do
+ Dir.chdir($require_fixture_dir) do |dir|
+ abs_path = File.expand_path('../require/require_spec_1.rb')
+ path_parts = File.split(abs_path)
+ require([
+ path_parts[0], File::Separator, path_parts[1]
+ ].join(File::Separator)).should be_true
- # TODO: add an implementation-agnostic method for creating
- # an extension file
- it "loads extension files"
+ $LOADED_FEATURES.grep(/require_spec_1\.rb/).should == [abs_path]
+ end
+ end
- it "does not expand/resolve qualified files against $LOAD_PATH" do
- num_features = $LOADED_FEATURES.size
- Dir.chdir($require_fixture_dir + '/../') do |dir|
- # This would be a valid path if expanded against the fixture dir
- lambda { require '../require/require_spec_2.rb' }.should raise_error LoadError
- end
- $LOADED_FEATURES.size.should == num_features
- end
-
- ruby_version_is ""..."1.9" do
- it "allows unqualified files to contain path information (just not in the beginning)" do
- name = (File.dirname(__FILE__) + '/../../fixtures')
- $LOAD_PATH << name
-
- $require_spec2 = nil
- require('require/../require/require_spec_2.rb').should == true
- $require_spec_2.nil?.should == false
+ platform_is_not :windows do
+ it "collapses '../' inside an absolute path before storing in $LOADED_FEATURES" do
+ abs_path = File.expand_path(
+ File.join($require_fixture_dir, '/require_spec_1.rb'))
+ require(abs_path).should be_true
+ # Create an absolute path (beginning at a child of the filesystem
+ # root), containing '../' (to move to the root), then the real
+ # absolute path.
+ require("/tmp/../#{abs_path}")
+ $LOADED_FEATURES.grep(/require_spec_1\.rb/).should == [abs_path]
+ end
+ end
- $LOAD_PATH.delete name
- end
+ # This is untested because I don't have access to a Windows box.
+ platform_is :windows do
+ it "collapses '../' inside an absolute path before storing in $LOADED_FEATURES" do
+ abs_path = File.expand_path(
+ File.join($require_fixture_dir, '/require_spec_1.rb'))
+ require(abs_path).should be_true
+ # Create an absolute path (beginning at a child of the filesystem
+ # root), containing '../' (to move to the root), then the real
+ # absolute path.
+ require("C:\Windows\..\#{abs_path}")
+ $LOADED_FEATURES.grep(/require_spec_1\.rb/).should == [abs_path]
+ end
+ end
+ end
end
- ruby_version_is "1.9" do
- it "allows unqualified files to contain path information (just not in the beginning)" do
- # Forget that we've already loaded this file
- $LOADED_FEATURES.delete File.expand_path(
- File.join($require_fixture_dir, 'require_spec_2.rb'))
- name = (File.dirname(__FILE__) + '/../../fixtures')
- # Append fixtures directory to $LOAD_PATH
- $LOAD_PATH << name
- $require_spec2 = nil
- # Require fixtures file using path relative to $LOAD_PATH
- require('require/../require/require_spec_2.rb').should be_true
- $require_spec_2.should_not be_nil
- $LOAD_PATH.delete File.expand_path(name)
- end
+ it "stores a non-extensioned file with its located suffix" do
+ require('require_spec_6').should be_true
+ $LOADED_FEATURES.grep(/require_spec_6\.rb/).should_not == []
end
-
- it "loads a file with ./filename even if . is not in path" do
- Dir.chdir($require_fixture_dir) do |dir|
- path_backup = $LOAD_PATH.clone
- $LOAD_PATH.clear
- $LOAD_PATH << "Someirrelevantpath"
- begin
- require('./require_spec.rb').should == true
- ensure
- $LOAD_PATH.clear
- $LOAD_PATH.concat(path_backup)
- end
- end
- end
+
+#######################################
+# FILE EXTENSIONS
+#######################################
it "appends a file with no extension with .rb/.<ext> in that order to locate file" do
load('require_spec')
@@ -213,63 +252,23 @@
$require_spec.should == :rb
end
- ruby_version_is ""..."1.9" do
- it "prefers to use .rb over .<ext> if given non-extensioned file and both exist" do
- require('require_spec_dummy').should == true
- $LOADED_FEATURES.include?('require_spec_dummy.rb').should == true
- $LOADED_FEATURES.include?("require_spec_dummy.#{Config::CONFIG['DLEXT']}").should == false
- end
+ it "prefers to use .rb over .<ext> if given non-extensioned file and both exist" do
+ require('require_spec_dummy').should be_true
+ $LOADED_FEATURES.grep(/require_spec_dummy\.rb/).should_not == []
+ $LOADED_FEATURES.grep(/require_spec_dummy\.#{Config::CONFIG['DLEXT']}/).should == []
end
- ruby_version_is "1.9" do
- it "prefers to use .rb over .<ext> if given non-extensioned file and both exist" do
- rb_abs_path = File.expand_path(
- File.join($require_tmp_dir, 'require_spec_dummy.rb'))
- ext_abs_path = rb_abs_path.sub(/\.rb$/, '.' + Config::CONFIG['DLEXT'])
- require('require_spec_dummy').should be_true
- $LOADED_FEATURES.include?(rb_abs_path).should be_true
- $LOADED_FEATURES.include?(ext_abs_path).should be_false
- end
+ it "will load file.rb when given 'file' if it exists even if file.<ext> is loaded" do
+ $LOADED_FEATURES << "require_spec_3.#{Config::CONFIG['DLEXT']}"
+ require('require_spec_3.rb').should be_true
+ $LOADED_FEATURES.grep(/require_spec_3\.rb/).should_not == []
end
- runner_is_not :rspec do
- it "will not add a bad load to LOADED_FEATURES" do
- lambda { require('require_spec_raises') }.should raise_error(RuntimeError)
-
- $LOADED_FEATURES.include?('require_spec_raises.rb').should == false
- end
- end
-
- ruby_version_is ""..."1.9" do
- it "will load file.rb when given 'file' if it exists even if file.<ext> is loaded" do
- $LOADED_FEATURES << "require_spec_3.#{Config::CONFIG['DLEXT']}"
- require('require_spec_3.rb').should == true
- $LOADED_FEATURES.include?('require_spec_3.rb').should == true
- end
- end
-
- ruby_version_is "1.9" do
- it "will load file.rb when given 'file' if it exists even if file.<ext> is loaded" do
- $LOADED_FEATURES << File.expand_path(
- File.join($require_fixture_dir, "require_spec_3.#{Config::CONFIG['DLEXT']}"))
- require('require_spec_3.rb').should be_true
- $LOADED_FEATURES.include?(File.expand_path(
- File.join($require_fixture_dir, 'require_spec_3.rb'))).should be_true
- end
- end
-
it "will not load file.<ext> when given 'file' if file.rb already loaded" do
- unless $LOADED_FEATURES.include?('require_spec_dummy.rb')
- require('require_spec_dummy.rb')
- end
-
- require('require_spec_dummy').should == false
+ require('require_spec_dummy.rb').should be_true
+ require('require_spec_dummy').should be_false
end
- # TODO: add an implementation-agnostic method for creating
- # an extension file
- it "will load explicit file.<ext> even if file.rb already loaded and vice versa"
-
it "appends any non-ruby extensioned file with .rb/.<ext> in that order to locate file" do
load('require_spec.rooby')
$require_spec_rooby.should == :rooby
@@ -282,181 +281,84 @@
$require_spec_rooby.should == :rb
end
- ruby_version_is ""..."1.9" do
- it "produces __FILE__ as the given filename and __LINE__ as the source line number" do
- Dir.chdir($require_fixture_dir) do |dir|
- require('require_spec_4').should == true
- $require_spec_4.should == [['./require_spec_4.rb', 1], ['./require_spec_4.rb', 10]]
+ # TODO: add an implementation-agnostic method for creating
+ # an extension file
+ it "loads extension files"
- extended_on :rubinius do
- `rm require_spec_4.rbc`
- end
- end
+ # TODO: add an implementation-agnostic method for creating
+ # an extension file
+ it "will load explicit file.<ext> even if file.rb already loaded and vice versa"
- $require_spec_4 = nil
- require("#{$require_fixture_dir}/require_spec_4").should == true
- $require_spec_4[0][0].should =~ %r[^.*/fixtures/require/require_spec_4.rb]
- $require_spec_4[0][1].should == 1
- $require_spec_4[1][0].should =~ %r[^.*/fixtures/require/require_spec_4.rb]
- $require_spec_4[1][1].should == 10
- end
- end
+#######################################
+# $LOADED_FEATURES
+#######################################
- ruby_version_is "1.9" do
- it "produces __FILE__ as the given filename and __LINE__ as the source line number" do
- abs_path = File.expand_path(
- File.join($require_fixture_dir, 'require_spec_4.rb'))
- Dir.chdir($require_fixture_dir) do |dir|
- require('require_spec_4').should be_true
- $require_spec_4.should == [[abs_path, 1], [abs_path, 10]]
-
- extended_on :rubinius do
- `rm require_spec_4.rbc`
- end
- end
-
- $require_spec_4 = nil
- $LOADED_FEATURES.delete abs_path
- require('require_spec_4').should be_true
- $require_spec_4[0][0].should =~ %r[^.*/fixtures/require/require_spec_4.rb]
- $require_spec_4[0][1].should == 1
- $require_spec_4[1][0].should =~ %r[^.*/fixtures/require/require_spec_4.rb]
- $require_spec_4[1][1].should == 10
- end
+ it "stores the loaded file in $LOADED_FEATURES" do
+ require('require_spec_6.rb').should be_true
+ $LOADED_FEATURES.grep(/require_spec_6\.rb/).should_not == []
end
- ruby_version_is ""..."1.9" do
- it "stores the loaded file in $LOADED_FEATURES" do
- $LOADED_FEATURES.include?('require_spec_6.rb').should == false
- require('require_spec_6.rb').should == true
- $LOADED_FEATURES.include?('require_spec_6.rb').should == true
+ runner_is_not :rspec do
+ it "will not add a bad load to LOADED_FEATURES" do
+ lambda { require('require_spec_raises') }.should raise_error(RuntimeError)
+
+ $LOADED_FEATURES.grep(/require_spec_raises\.rb/).should == []
end
end
- ruby_version_is "1.9" do
- it "stores the loaded file in $LOADED_FEATURES" do
- abs_path = File.expand_path(
- File.join($require_fixture_dir, 'require_spec_6.rb'))
- $LOADED_FEATURES.include?(abs_path).should be_false
- require('require_spec_6.rb').should be_true
- $LOADED_FEATURES.include?(abs_path).should be_true
- end
- end
- ruby_version_is ""..."1.9" do
- it "stores a non-extensioned file with its located suffix" do
- $LOADED_FEATURES.delete 'require_spec_6.rb'
+ it "uses $LOADED_FEATURES to see whether file is already loaded" do
+ require('require_spec_7.rb').should be_true
- require('require_spec_6').should == true
+ $LOADED_FEATURES.delete_if {|path| path =~ /require_spec_7\.rb$/}
+ require('require_spec_7.rb').should be_true
+ require('require_spec_7.rb').should be_false
- $LOADED_FEATURES.include?('require_spec_6.rb').should == true
- end
+ $LOADED_FEATURES.grep(/require_spec_7\.rb/).should_not == []
end
- ruby_version_is "1.9" do
- it "stores a non-extensioned file with its located suffix" do
- abs_path = File.expand_path(
- File.join($require_fixture_dir, 'require_spec_6.rb'))
- $LOADED_FEATURES.delete abs_path
+ it "will not load a file whose path appears in $LOADED_FEATURES; it will return false" do
+ # This wording is necessarily precise because 1.8 and 1.9 perform
+ # different forms of normalisation before storing the path in
+ # $LOADED_FEATURES. We deliberately don't concern ourselves with the form
+ # of the saved path; just that an approximation of it has been recorded.
+ require('require_spec_7.rb').should be_true
+ a = $require_spec_7
+ a.should_not be_nil
+
+ $LOADED_FEATURES.grep(/require_spec_7.rb/).should_not == []
- require('require_spec_6').should be_true
+ require('require_spec_7.rb').should be_false
+ b = $require_spec_7
+ b.should_not be_nil
- $LOADED_FEATURES.include?(abs_path).should be_true
- end
- end
+ # Timestamps should not differ
+ a.should eql(b)
- # The 1.9 version of this test is described in it "normalises .rb paths
- # before storing them in $LOADED_FEATURES"
- ruby_version_is ""..."1.9" do
- it "bases the filename in $LOADED_FEATURES on the path given, not just basename" do
- $LOADED_FEATURES.include?('require_spec_6.rb').should == true
-
- Dir.chdir($require_fixture_dir) do |dir|
- require('../../fixtures/require/require_spec_6.rb').should == true
- end
-
- $LOADED_FEATURES.include?('require_spec_6.rb').should == true
- $LOADED_FEATURES.include?('../../fixtures/require/require_spec_6.rb').should == true
- end
+ $LOADED_FEATURES.grep(/require_spec_7\.rb/).should_not == []
end
- ruby_version_is ""..."1.9" do
- it "will not load the same file twice, returns false instead" do
- $LOADED_FEATURES.include?('require_spec_7.rb').should == false
+#######################################
+# ERROR BEHAVIOUR
+#######################################
- require('require_spec_7.rb').should == true
- a = $require_spec_7
- a.nil?.should == false
-
- $LOADED_FEATURES.include?('require_spec_7.rb').should == true
-
- require('require_spec_7.rb').should == false
- b = $require_spec_7
- b.nil?.should == false
-
- # Timestamps should not differ
- a.should eql(b)
-
- $LOADED_FEATURES.include?('require_spec_7.rb').should == true
- end
+ it "requires arbitrarily complex files (files with large numbers of AST nodes)" do
+ lambda {require File.expand_path(File.dirname(__FILE__)) + '/fixtures/test'}.should_not raise_error
end
- ruby_version_is "1.9" do
- it "will not load the same file twice, returns false instead" do
- abs_path = File.expand_path(
- File.join($require_fixture_dir, 'require_spec_7.rb'))
- $LOADED_FEATURES.include?(abs_path).should be_false
-
- require('require_spec_7.rb').should be_true
- a = $require_spec_7
- a.should_not be_nil
-
- $LOADED_FEATURES.include?(abs_path).should be_true
-
- require('require_spec_7.rb').should be_false
- b = $require_spec_7
- b.should_not be_nil
-
- # Timestamps should not differ
- a.should eql(b)
-
- $LOADED_FEATURES.include?(abs_path).should be_true
- end
- end
-
- ruby_version_is ""..."1.9" do
- it "checks $LOADED_FEATURES to see whether file is already loaded" do
- $LOADED_FEATURES.include?('require_spec_7.rb').should == true
- require('require_spec_7.rb').should == false
-
- $LOADED_FEATURES.delete 'require_spec_7.rb'
- require('require_spec_7.rb').should == true
- require('require_spec_7.rb').should == false
-
- $LOADED_FEATURES.include?('require_spec_7.rb').should == true
- end
- end
-
- ruby_version_is "1.9" do
- it "checks $LOADED_FEATURES to see whether file is already loaded" do
- abs_path = File.expand_path(
- File.join($require_fixture_dir, 'require_spec_7.rb'))
- $LOADED_FEATURES.include?(abs_path).should be_true
- require('require_spec_7.rb').should be_false
-
- $LOADED_FEATURES.delete abs_path
- require('require_spec_7.rb').should be_true
- require('require_spec_7.rb').should be_false
-
- $LOADED_FEATURES.include?(abs_path).should be_true
- end
- end
-
it "raises a LoadError if the file can't be found" do
lambda { require "nonesuch#{$$}#{Time.now.to_f}" }.should raise_error LoadError
end
+ it "raises a LoadError if the file exists but can't be read" do
+ abs_path = File.expand_path(
+ File.join($require_tmp_dir, 'require_spec_dummy.rb'))
+ File.exists?(abs_path).should be_true
+ File.new(abs_path).chmod(0000)
+ lambda {require(abs_path)}.should raise_error(LoadError)
+ end
+
ruby_version_is ""..."1.9" do
it "only accepts strings" do
lambda { require(nil) }.should raise_error(TypeError)
@@ -471,42 +373,70 @@
lambda { require(42) }.should raise_error(TypeError)
lambda { require([]) }.should raise_error(TypeError)
end
+
+ it "calls #to_path on non-String arguments" do
+ abs_path = File.expand_path(
+ File.join($require_fixture_dir, 'require_spec.rb'))
+ path = mock('path')
+ path.should_receive(:to_path).and_return('require_spec')
+ require(path).should be_true
+ $LOADED_FEATURES.include?(abs_path).should be_true
+ end
end
+ it "does not infinite loop on an rb file that requires itself" do
+ $LOADED_FEATURES.grep(/require_spec_recursive\.rb/).should == []
+ require('require_spec_recursive').should be_true
+ $LOADED_FEATURES.grep(/require_spec_recursive.rb/).should_not == []
+ $require_spec_recursive.should_not be_false
+ end
+
+#######################################
+# __FILE__ / __LINE__
+#######################################
+
ruby_version_is ""..."1.9" do
- it "does not infinite loop on an rb file that requires itself" do
- $require_spec_recursive = nil
- $LOADED_FEATURES.delete 'require_spec_recursive.rb'
+ it "produces __FILE__ as the given filename and __LINE__ as the source line number" do
+ Dir.chdir($require_fixture_dir) do |dir|
+ require('require_spec_4').should be_true
+ $require_spec_4.should == [['./require_spec_4.rb', 1], ['./require_spec_4.rb', 10]]
- $LOADED_FEATURES.include?('require_spec_recursive.rb').should == false
- require('require_spec_recursive').should == true
- $LOADED_FEATURES.include?('require_spec_recursive.rb').should == true
- $require_spec_recursive.nil?.should == false
+ extended_on :rubinius do
+ `rm require_spec_4.rbc`
+ end
+ end
+
+ $require_spec_4 = nil
+
+ require("#{$require_fixture_dir}/require_spec_4").should be_true
+ $require_spec_4[0][0].should =~ %r[^.*/fixtures/require/require_spec_4.rb]
+ $require_spec_4[0][1].should == 1
+ $require_spec_4[1][0].should =~ %r[^.*/fixtures/require/require_spec_4.rb]
+ $require_spec_4[1][1].should == 10
end
end
ruby_version_is "1.9" do
- it "does not infinite loop on an rb file that requires itself" do
+ it "produces __FILE__ as the given filename and __LINE__ as the source line number" do
abs_path = File.expand_path(
- File.join($require_fixture_dir, 'require_spec_recursive.rb'))
- $require_spec_recursive = nil
- $LOADED_FEATURES.delete abs_path
+ File.join($require_fixture_dir, 'require_spec_4.rb'))
+ Dir.chdir($require_fixture_dir) do |dir|
+ require('require_spec_4').should be_true
+ $require_spec_4.should == [[abs_path, 1], [abs_path, 10]]
- $LOADED_FEATURES.include?(abs_path).should be_false
- require('require_spec_recursive').should be_true
- $LOADED_FEATURES.include?(abs_path).should be_true
- $require_spec_recursive.should_not be_nil
- end
-
- it "calls #to_path on non-String arguments" do
- abs_path = File.expand_path(
- File.join($require_fixture_dir, 'require_spec.rb'))
- path = mock('path')
- path.should_receive(:to_path).and_return('require_spec.rb')
+ extended_on :rubinius do
+ `rm require_spec_4.rbc`
+ end
+ end
+
+ $require_spec_4 = nil
$LOADED_FEATURES.delete abs_path
- require(path).should be_true
- $LOADED_FEATURES.include?(abs_path).should be_true
- end
+ require('require_spec_4').should be_true
+ $require_spec_4[0][0].should =~ %r[^.*/fixtures/require/require_spec_4.rb]
+ $require_spec_4[0][1].should == 1
+ $require_spec_4[1][0].should =~ %r[^.*/fixtures/require/require_spec_4.rb]
+ $require_spec_4[1][1].should == 10
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/respond_to_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/respond_to_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/respond_to_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -60,4 +60,22 @@
KernelSpecs::Foo.new.respond_to?(:bar).should == true
KernelSpecs::Foo.new.respond_to?(:invalid_and_silly_method_name).should == false
end
+
+ ruby_version_is "1.9" do
+ platform_is :os => :windows do
+ it "returns false for a method which exists but is unimplemented" do
+ Process.methods.include?(:fork).should be_true
+ Process.respond_to?(:fork).should be_false
+ lambda { Process.fork }.should raise_error(NotImplementedError)
+ end
+ end
+
+ platform_is :os => [:linux, :openbsd] do
+ it "returns false for a method which exists but is unimplemented" do
+ File.methods.include?(:lchmod).should be_true
+ File.respond_to?(:lchmod).should be_false
+ lambda { File.lchmod }.should raise_error(NotImplementedError)
+ end
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/module/include_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/include_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/module/include_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -166,6 +166,14 @@
end
}.should raise_error(ArgumentError)
end
+
+ it "accepts no-arguments" do
+ lambda {
+ Module.new do
+ include
+ end
+ }.should_not raise_error
+ end
end
describe "Module#include?" do
Modified: MacRuby/branches/experimental/spec/frozen/core/numeric/abs_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/abs_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/abs_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,19 +1,5 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/abs'
describe "Numeric#abs" do
- before(:each) do
- @obj = NumericSub.new
- end
-
- it "returns self when self is greater than 0" do
- @obj.should_receive(:<).with(0).and_return(false)
- @obj.abs.should == @obj
- end
-
- it "returns self\#@- when self is less than 0" do
- @obj.should_receive(:<).with(0).and_return(true)
- @obj.should_receive(:-@).and_return(:absolute_value)
- @obj.abs.should == :absolute_value
- end
-end
\ No newline at end of file
+ it_behaves_like(:numeric_abs, :abs)
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/angle_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/angle_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/angle_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/phase'
+
+ruby_version_is "1.9" do
+ describe "Numeric#angle" do
+ it_behaves_like(:numeric_phase, :angle)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/arg_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/arg_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/arg_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/phase'
+
+ruby_version_is "1.9" do
+ describe "Numeric#arg" do
+ it_behaves_like(:numeric_phase, :arg)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/conj_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/conj_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/conj_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/conj'
+
+ruby_version_is "1.9" do
+ describe "Numeric#conj" do
+ it_behaves_like(:numeric_conj, :conj)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/conjugate_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/conjugate_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/conjugate_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/conj'
+
+ruby_version_is "1.9" do
+ describe "Numeric#conjugate" do
+ it_behaves_like(:numeric_conj, :conjugate)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/denominator_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/denominator_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/denominator_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,18 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.9" do
+ describe "Numeric#denominator" do
+ # The Numeric child classes override this method, so their behaviour is
+ # specified in the appropriate place
+ before(:each) do
+ @numbers = [
+ 20, # Integer
+ 99999999**99, # Bignum
+ ]
+ end
+
+ it "returns 1" do
+ @numbers.each {|number| number.denominator.should == 1}
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/imag_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/imag_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/imag_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/imag'
+
+ruby_version_is "1.9" do
+ describe "Numeric#imag" do
+ it_behaves_like(:numeric_imag, :imag)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/imaginary_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/imaginary_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/imaginary_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/imag'
+
+ruby_version_is "1.9" do
+ describe "Numeric#imaginary" do
+ it_behaves_like(:numeric_imag, :imaginary)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/magnitude_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/magnitude_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/magnitude_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/shared/abs'
+
+ruby_version_is "1.9" do
+ describe "Numeric#magnitude" do
+ it_behaves_like(:numeric_abs, :magnitude)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/numerator_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/numerator_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/numerator_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,27 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.9" do
+ describe "Numeric#numerator" do
+ before(:all) do
+ @numbers = [
+ 0,
+ 29871,
+ 99999999999999**99,
+ -72628191273,
+ 29282.2827,
+ -2927.00091,
+ 0.0,
+ 12.0,
+ Float::MAX,
+ ]
+ end
+
+ # This isn't entirely true, as NaN.numerator works, whereas
+ # Rational(NaN) raises an exception, but we test this in Float#numerator
+ it "converts self to a Rational object then returns its numerator" do
+ @numbers.each do |number|
+ number.numerator.should == Rational(number).numerator
+ end
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/phase_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/phase_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/phase_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/phase'
+
+ruby_version_is "1.9" do
+ describe "Numeric#phase" do
+ it_behaves_like(:numeric_phase, :phase)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/polar_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/polar_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/polar_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,54 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.9" do
+ describe "Numeric#polar" do
+ before(:each) do
+ @pos_numbers = [
+ 1,
+ 3898172610**9,
+ 987.18273,
+ Float::MAX,
+ Rational(13,7),
+ 1/0.0,
+ ]
+ @neg_numbers = @pos_numbers.map {|n| -n}
+ @numbers = @pos_numbers + @neg_numbers
+ @numbers.push(0, 0.0)
+ end
+
+ it "returns a two-element Array" do
+ @numbers.each do |number|
+ number.polar.should be_an_instance_of(Array)
+ number.polar.size.should == 2
+ end
+ end
+
+ it "sets the first value to the absolute value of self" do
+ @numbers.each do |number|
+ number.polar.first.should == number.abs
+ end
+ end
+
+ it "sets the last value to 0 if self is positive" do
+ (@numbers - @neg_numbers).each do |number|
+ number.should >= 0
+ number.polar.last.should == 0
+ end
+ end
+
+ it "sets the last value to Pi if self is negative" do
+ @neg_numbers.each do |number|
+ number.should < 0
+ number.polar.last.should == Math::PI
+ end
+ end
+
+ it "treats NaN like a positive number" do
+ nan = 0/0.0
+ nan.nan?.should be_true
+ nan.polar.size.should == 2
+ nan.polar.first.nan?.should be_true
+ nan.polar.last.should == 0
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/real_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/real_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/real_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,28 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.9" do
+ describe "Numeric#real" do
+ before(:each) do
+ @numbers = [
+ 20, # Integer
+ 398.72, # Float
+ Rational(3, 4), # Rational
+ 99999999**99, # Bignum
+ Float::MAX * 2, # Infinity
+ 0/0.0 # NaN
+ ]
+ end
+
+ it "returns self" do
+ @numbers.each do |number|
+ number.send(@method).should == number
+ end
+ end
+
+ it "raises an ArgumentError if given any arguments" do
+ @numbers.each do |number|
+ lambda { number.send(@method, number) }.should raise_error(ArgumentError)
+ end
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/rect_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/rect_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/rect_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/rect'
+
+ruby_version_is "1.9" do
+ describe "Numeric#rect" do
+ it_behaves_like(:numeric_rect, :rect)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/rectangular_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/rectangular_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/rectangular_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/rect'
+
+ruby_version_is "1.9" do
+ describe "Numeric#rectangular" do
+ it_behaves_like(:numeric_rect, :rectangular)
+ end
+end
Copied: MacRuby/branches/experimental/spec/frozen/core/numeric/shared/abs.rb (from rev 1878, MacRuby/branches/experimental/spec/frozen/core/numeric/abs_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/shared/abs.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/shared/abs.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,19 @@
+require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.dirname(__FILE__) + '/../fixtures/classes'
+
+describe :numeric_abs, :shared => true do
+ before(:each) do
+ @obj = NumericSub.new
+ end
+
+ it "returns self when self is greater than 0" do
+ @obj.should_receive(:<).with(0).and_return(false)
+ @obj.send(@method).should == @obj
+ end
+
+ it "returns self\#@- when self is less than 0" do
+ @obj.should_receive(:<).with(0).and_return(true)
+ @obj.should_receive(:-@).and_return(:absolute_value)
+ @obj.send(@method).should == :absolute_value
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/shared/conj.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/shared/conj.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/shared/conj.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,26 @@
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+describe :numeric_conj, :shared => true do
+ before(:each) do
+ @numbers = [
+ 20, # Integer
+ 398.72, # Float
+ Rational(3, 4), # Rational
+ 99999999**99, # Bignum
+ Float::MAX * 2, # Infinity
+ 0/0.0 # NaN
+ ]
+ end
+
+ it "returns self" do
+ @numbers.each do |number|
+ number.send(@method).to_s.should == number.to_s
+ end
+ end
+
+ it "raises an ArgumentError if given any arguments" do
+ @numbers.each do |number|
+ lambda { number.send(@method, number) }.should raise_error(ArgumentError)
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/shared/imag.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/shared/imag.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/shared/imag.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,26 @@
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+describe :numeric_imag, :shared => true do
+ before(:each) do
+ @numbers = [
+ 20, # Integer
+ 398.72, # Float
+ Rational(3, 4), # Rational
+ 99999999**99, # Bignum
+ Float::MAX * 2, # Infinity
+ 0/0.0 # NaN
+ ]
+ end
+
+ it "returns 0" do
+ @numbers.each do |number|
+ number.send(@method).should == 0
+ end
+ end
+
+ it "raises an ArgumentError if given any arguments" do
+ @numbers.each do |number|
+ lambda { number.send(@method, number) }.should raise_error(ArgumentError)
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/shared/phase.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/shared/phase.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/shared/phase.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,34 @@
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+describe :numeric_phase, :shared => true do
+ before(:each) do
+ @numbers = [
+ 20, # Integer
+ 398.72, # Float
+ Rational(3, 4), # Rational
+ 99999999**99, # Bignum
+ Float::MAX * 2, # Infinity
+ 0/0.0 # NaN
+ ]
+ end
+
+ it "returns 0 if positive" do
+ @numbers.each do |number|
+ number.send(@method).should == 0
+ end
+ end
+
+ it "returns Pi if negative" do
+ @numbers.each do |number|
+ # NaN can't be negated
+ next if number.to_f.nan?
+ (0-number).send(@method).should == Math::PI
+ end
+ end
+
+ it "raises an ArgumentError if given any arguments" do
+ @numbers.each do |number|
+ lambda { number.send(@method, number) }.should raise_error(ArgumentError)
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/shared/rect.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/shared/rect.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/shared/rect.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,44 @@
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+describe :numeric_rect, :shared => true do
+ before(:each) do
+ @numbers = [
+ 20, # Integer
+ 398.72, # Float
+ Rational(3, 4), # Rational
+ 99999999**99, # Bignum
+ Float::MAX * 2, # Infinity
+ 0/0.0 # NaN
+ ]
+ end
+
+ it "returns an Array" do
+ @numbers.each do |number|
+ number.send(@method).should be_an_instance_of(Array)
+ end
+ end
+
+ it "returns a two-element Array" do
+ @numbers.each do |number|
+ number.send(@method).size.should == 2
+ end
+ end
+
+ it "returns self as the first element" do
+ @numbers.each do |number|
+ number.send(@method).first.should == number
+ end
+ end
+
+ it "returns 0 as the last element" do
+ @numbers.each do |number|
+ number.send(@method).last.should == 0
+ end
+ end
+
+ it "raises an ArgumentError if given any arguments" do
+ @numbers.each do |number|
+ lambda { number.send(@method, number) }.should raise_error(ArgumentError)
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/numeric/to_c_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/to_c_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/to_c_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,47 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.9" do
+ describe "Numeric#to_c" do
+ before(:all) do
+ @numbers = [
+ 0,
+ 29871,
+ 99999999999999**99,
+ -72628191273,
+ Rational(2,3),
+ Rational(1.898),
+ Rational(-238),
+ 29282.2827,
+ -2927.00091,
+ 0.0,
+ 12.0,
+ Float::MAX,
+ 1/0.0,
+ 0/0.0
+ ]
+ end
+
+ it "returns a Complex object" do
+ @numbers.each do |number|
+ number.to_c.should be_an_instance_of(Complex)
+ end
+ end
+
+ it "uses self as the real component" do
+ @numbers.each do |number|
+ real = number.to_c.real
+ if number.to_f.nan?
+ real.nan?.should be_true
+ else
+ real.should == number
+ end
+ end
+ end
+
+ it "uses 0 as the imaginary component" do
+ @numbers.each do |number|
+ number.to_c.imag.should == 0
+ end
+ end
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/objectspace/define_finalizer_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/objectspace/define_finalizer_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/core/objectspace/define_finalizer_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -22,4 +22,19 @@
def handler.call(obj) end
ObjectSpace.define_finalizer("garbage", handler).should == [0, handler]
end
+
+ it "calls finalizer on process termination" do
+ rd, wr = IO.pipe
+ if Kernel::fork then
+ wr.close
+ rd.read.should == "finalized"
+ rd.close
+ else
+ rd.close
+ obj = "Test"
+ handler = Proc.new { wr.write "finalized"; wr.close }
+ ObjectSpace.define_finalizer(obj, handler)
+ exit 0
+ end
+ end
end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/Rational_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/Rational_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/Rational_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,11 @@
+require File.dirname(__FILE__) + '/../../shared/rational/Rational'
+
+ruby_version_is "1.9" do
+ describe "Rational() passed two arguments" do
+ it_behaves_like(:rational_rational_two, :Rational)
+ end
+
+ describe "Rational() passed Integer" do
+ it_behaves_like(:rational_rational_int, :Rational)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/abs_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/abs_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/abs_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/abs'
+
+ruby_version_is "1.9" do
+ describe "Rational#abs" do
+ it_behaves_like(:rational_abs, :abs)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/ceil_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/ceil_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/ceil_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/ceil'
+
+ruby_version_is "1.9" do
+ describe "Rational#ceil" do
+ it_behaves_like(:rational_ceil, :ceil)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/coerce_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/coerce_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/coerce_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/coerce'
+
+ruby_version_is "1.9" do
+ describe "Rational#coerce" do
+ it_behaves_like(:rational_coerce, :coerce)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/comparison_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/comparison_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/comparison_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,23 @@
+require File.dirname(__FILE__) + '/../../shared/rational/comparison'
+
+ruby_version_is "1.9" do
+ describe "Rational#<=> when passed a Rational object" do
+ it_behaves_like(:rational_cmp_rat, :<=>)
+ end
+
+ describe "Rational#<=> when passed a Integer object" do
+ it_behaves_like(:rational_cmp_int, :<=>)
+ end
+
+ describe "Rational#<=> when passed a Float object" do
+ it_behaves_like(:rational_cmp_float, :<=>)
+ end
+
+ describe "Rational#<=> when passed an Object that responds to #coerce" do
+ it_behaves_like(:rational_cmp_coerce, :<=>)
+ end
+
+ describe "Rational#<=> when passed a non-Numeric Object that doesn't respond to #coerce" do
+ it_behaves_like(:rational_cmp_other, :<=>)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/denominator_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/denominator_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/denominator_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/denominator'
+
+ruby_version_is "1.9" do
+ describe "Rational#denominator" do
+ it_behaves_like(:rational_denominator, :denominator)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/div_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/div_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/div_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,19 @@
+require File.dirname(__FILE__) + '/../../shared/rational/div'
+
+ruby_version_is "1.9" do
+ describe "Rational#div" do
+ it_behaves_like(:rational_div, :div)
+ end
+
+ describe "Rational#div passed a Rational" do
+ it_behaves_like(:rational_div_rat, :div)
+ end
+
+ describe "Rational#div passed an Integer" do
+ it_behaves_like(:rational_div_int, :div)
+ end
+
+ describe "Rational#div passed a Float" do
+ it_behaves_like(:rational_div_float, :div)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/divide_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/divide_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/divide_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,19 @@
+require File.dirname(__FILE__) + '/../../shared/rational/divide'
+
+ruby_version_is "1.9" do
+ describe "Rational#/" do
+ it_behaves_like(:rational_divide, :/)
+ end
+
+ describe "Rational#/ when passed an Integer" do
+ it_behaves_like(:rational_divide_int, :/)
+ end
+
+ describe "Rational#/ when passed a Rational" do
+ it_behaves_like(:rational_divide_rat, :/)
+ end
+
+ describe "Rational#/ when passed a Float" do
+ it_behaves_like(:rational_divide_float, :/)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/divmod_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/divmod_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/divmod_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,15 @@
+require File.dirname(__FILE__) + '/../../shared/rational/divmod'
+
+ruby_version_is "1.9" do
+ describe "Rational#divmod when passed a Rational" do
+ it_behaves_like(:rational_divmod_rat, :divmod)
+ end
+
+ describe "Rational#divmod when passed an Integer" do
+ it_behaves_like(:rational_divmod_int, :divmod)
+ end
+
+ describe "Rational#divmod when passed a Float" do
+ it_behaves_like(:rational_divmod_float, :divmod)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/equal_value_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/equal_value_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/equal_value_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,19 @@
+require File.dirname(__FILE__) + '/../../shared/rational/equal_value'
+
+ruby_version_is "1.9" do
+ describe "Rational#==" do
+ it_behaves_like(:rational_equal_value, :==)
+ end
+
+ describe "Rational#== when passed a Rational" do
+ it_behaves_like(:rational_equal_value_rat, :==)
+ end
+
+ describe "Rational#== when passed a Float" do
+ it_behaves_like(:rational_equal_value_float, :==)
+ end
+
+ describe "Rational#== when passed an Integer" do
+ it_behaves_like(:rational_equal_value_int, :==)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/exponent_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/exponent_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/exponent_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,19 @@
+require File.dirname(__FILE__) + '/../../shared/rational/exponent'
+
+ruby_version_is "1.9" do
+ describe "Rational#**" do
+ it_behaves_like(:rational_exponent, :**)
+ end
+
+ describe "Rational#** when passed Rational" do
+ it_behaves_like(:rational_exponent_rat, :**)
+ end
+
+ describe "Rational#** when passed Float" do
+ it_behaves_like(:rational_exponent_float, :**)
+ end
+
+ describe "Rational#** when pass Integer" do
+ it_behaves_like(:rational_exponent_int, :**)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/fdiv_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/fdiv_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/fdiv_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/fdiv'
+
+ruby_version_is "1.9" do
+ describe "Rational#fdiv" do
+ it_behaves_like(:rational_fdiv, :fdiv)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/floor_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/floor_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/floor_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/floor'
+
+ruby_version_is "1.9" do
+ describe "Rational#floor" do
+ it_behaves_like(:rational_floor, :floor)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/hash_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/hash_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/hash_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/hash'
+
+ruby_version_is "1.9" do
+ describe "Rational#hash" do
+ it_behaves_like(:rational_hash, :hash)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/initialize_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/initialize_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/initialize_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,9 @@
+require File.dirname(__FILE__) + '/../../shared/rational/initialize'
+
+ruby_version_is "1.9" do
+ describe "Rational#initialize" do
+ it_behaves_like(:rational_initialize, :initialize)
+ end
+end
+
+
Added: MacRuby/branches/experimental/spec/frozen/core/rational/inspect_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/inspect_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/inspect_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/inspect'
+
+ruby_version_is "1.9" do
+ describe "Rational#inspect" do
+ it_behaves_like(:rational_inspect, :inspect)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/minus_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/minus_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/minus_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/minus'
+
+ruby_version_is "1.9" do
+ describe "Rational#-" do
+ it_behaves_like(:rational_minus, :-)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/modulo_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/modulo_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/modulo_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/modulo'
+
+ruby_version_is "1.9" do
+ describe "Rational#%" do
+ it_behaves_like(:rational_modulo, :%)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/multiply_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/multiply_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/multiply_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,19 @@
+require File.dirname(__FILE__) + '/../../shared/rational/multiply'
+
+ruby_version_is "1.9" do
+ describe "Rational#*" do
+ it_behaves_like(:rational_multiply, :*)
+ end
+
+ describe "Rational#* passed a Rational" do
+ it_behaves_like(:rational_multiply_rat, :*)
+ end
+
+ describe "Rational#* passed a Float" do
+ it_behaves_like(:rational_multiply_float, :*)
+ end
+
+ describe "Rational#* passed an Integer" do
+ it_behaves_like(:rational_multiply_int, :*)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/numerator_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/numerator_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/numerator_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/numerator'
+
+ruby_version_is "1.9" do
+ describe "Rational#numerator" do
+ it_behaves_like(:rational_numerator, :numerator)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/plus_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/plus_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/plus_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,18 @@
+require File.dirname(__FILE__) + '/../../shared/rational/plus'
+
+ruby_version_is "1.9" do
+ describe "Rational#+" do
+ it_behaves_like(:rational_plus, :+)
+ end
+
+ describe "Rational#+ with a Rational" do
+ it_behaves_like(:rational_plus_rat, :+)
+ end
+ describe "Rational#+ with a Float" do
+ it_behaves_like(:rational_plus_float, :+)
+ end
+
+ describe "Rational#+ with an Integer" do
+ it_behaves_like(:rational_plus_int, :+)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/quo_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/quo_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/quo_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/divide'
+
+ruby_version_is "1.9" do
+ describe "Rational#quo" do
+ it_behaves_like(:rational_divide, :quo)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/remainder_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/remainder_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/remainder_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/remainder'
+
+ruby_version_is "1.9" do
+ describe "Rational#remainder" do
+ it_behaves_like(:rational_remainder, :remainder)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/round_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/round_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/round_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/round'
+
+ruby_version_is "1.9" do
+ describe "Rational#round" do
+ it_behaves_like(:rational_round, :round)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/to_f_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/to_f_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/to_f_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/to_f'
+
+ruby_version_is "1.9" do
+ describe "Rational#to_f" do
+ it_behaves_like(:rational_to_f, :to_f)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/to_i_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/to_i_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/to_i_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/to_i'
+
+ruby_version_is "1.9" do
+ describe "Rational#to_i" do
+ it_behaves_like(:rational_to_i, :to_i)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/to_r_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/to_r_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/to_r_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/to_r'
+
+ruby_version_is "1.9" do
+ describe "Rational#to_r" do
+ it_behaves_like(:rational_to_r, :to_r)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/to_s_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/to_s_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/to_s_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/to_s'
+
+ruby_version_is "1.9" do
+ describe "Rational#to_s" do
+ it_behaves_like(:rational_to_s, :to_s)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/rational/truncate_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/rational/truncate_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/rational/truncate_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/truncate'
+
+ruby_version_is "1.9" do
+ describe "Rational#truncate" do
+ it_behaves_like(:rational_truncate, :truncate)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/library/enumerator/next_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/enumerator/next_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/enumerator/next_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,28 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'enumerator'
+
+describe "Enumerator#next" do
+
+ ruby_version_is "1.8.7" do
+ before(:each) do
+ @enum = enumerator_class.new(1, :upto, 3)
+ end
+
+ it "returns the next element of the enumeration" do
+ @enum.next.should == 1
+ @enum.next.should == 2
+ @enum.next.should == 3
+ end
+
+ it "raises a StopIteration exception at the end of the stream" do
+ 3.times { @enum.next }
+ lambda { @enum.next }.should raise_error(StopIteration)
+ end
+
+ it "rewinds the enumerator after raising StopIteration" do
+ 3.times { @enum.next }
+ lambda { @enum.next }.should raise_error(StopIteration)
+ @enum.next.should == 1
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/library/enumerator/rewind_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/enumerator/rewind_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/enumerator/rewind_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,49 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'enumerator'
+
+describe "Enumerator#rewind" do
+
+ ruby_version_is "1.8.7" do
+ before(:each) do
+ @enum = enumerator_class.new(1, :upto, 3)
+ end
+
+ it "resets the enumerator to its initial state" do
+ @enum.next.should == 1
+ @enum.next.should == 2
+ @enum.rewind
+ @enum.next.should == 1
+ end
+
+ it "returns self" do
+ @enum.rewind.should == @enum
+ end
+
+ it "has no effect on a new enumerator" do
+ @enum.rewind
+ @enum.next.should == 1
+ end
+
+ it "has no effect if called multiple, consecutive times" do
+ @enum.next.should == 1
+ @enum.rewind
+ @enum.rewind
+ @enum.next.should == 1
+ end
+
+ ruby_version_is "1.9" do
+ it "calls the enclosed object's rewind method if one exists" do
+ obj = mock('rewinder')
+ enum = enumerator_class.new(obj, :enum)
+ obj.should_receive(:rewind)
+ enum.rewind
+ end
+
+ it "does nothing if the object doesn't have a #rewind method" do
+ obj = mock('rewinder')
+ enum = enumerator_class.new(obj)
+ lambda { enum.rewind.should == enum }.should_not raise_error
+ end
+ end
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/Rational_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/Rational_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/Rational_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,69 +1,15 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/Rational'
-describe "Rational when passed Integer, Integer" do
- it "returns a new Rational number" do
- rat = Rational(1, 2)
- rat.numerator.should == 1
- rat.denominator.should == 2
- rat.should be_an_instance_of(Rational)
-
- rat = Rational(-3, -5)
- rat.numerator.should == 3
- rat.denominator.should == 5
- rat.should be_an_instance_of(Rational)
-
- rat = Rational(bignum_value, 3)
- rat.numerator.should == bignum_value
- rat.denominator.should == 3
- rat.should be_an_instance_of(Rational)
+ruby_version_is ""..."1.9" do
+ describe "Rational() passed Integer, Integer" do
+ it_behaves_like(:rational_rational_int_int, :Rational)
end
- it "automatically reduces the Rational" do
- rat = Rational(2, 4)
- rat.numerator.should == 1
- rat.denominator.should == 2
-
- rat = Rational(3, 9)
- rat.numerator.should == 1
- rat.denominator.should == 3
+ describe "Rational() passed Integer" do
+ it_behaves_like(:rational_rational_int, :Rational)
end
-end
-
-# Guard against the Mathn library
-conflicts_with :Prime do
- ruby_version_is ""..."1.9" do
- describe "Rational when passed Integer" do
- it "returns a new Rational number with 1 as the denominator" do
- Rational(1).should eql(Rational.new!(1, 1))
- Rational(-3).should eql(Rational.new!(-3, 1))
- Rational(bignum_value).should eql(Rational.new!(bignum_value, 1))
- end
- end
- end
-
- ruby_version_is "1.9" do
- describe "Rational when passed Integer" do
- it "returns a new Rational number with 1 as the denominator" do
- Rational(1).should eql(Rational(1, 1))
- Rational(-3).should eql(Rational(-3, 1))
- Rational(bignum_value).should eql(Rational(bignum_value, 1))
- end
- end
- end
-
- describe "Rational when passed Integer and Rational::Unify is defined" do
- after :each do
- Rational.send :remove_const, :Unify
- end
-
- it "returns the passed Integer when Rational::Unify is defined" do
- Rational::Unify = true
-
- Rational(1).should eql(1)
- Rational(-3).should eql(-3)
- Rational(bignum_value).should eql(bignum_value)
- end
- end
+ describe "Rational() passed Integer when Unify is defined" do
+ it_behaves_like(:rational_rational_int_rat_unify, :Rational)
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/abs_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/abs_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/abs_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,12 +1,7 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/abs'
-describe "Rational#abs" do
- it "returns self's absolute value" do
- Rational(3, 4).abs.should == Rational(3, 4)
- Rational(-3, 4).abs.should == Rational(3, 4)
- Rational(3, -4).abs.should == Rational(3, 4)
-
- Rational(bignum_value, -bignum_value).abs.should == Rational(bignum_value, bignum_value)
+ruby_version_is ""..."1.9" do
+ describe "Rational#abs" do
+ it_behaves_like(:rational_abs, :abs)
end
end
Added: MacRuby/branches/experimental/spec/frozen/library/rational/ceil_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/ceil_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/ceil_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/ceil'
+
+ruby_version_is ""..."1.9" do
+ describe "Rational#ceil" do
+ it_behaves_like(:rational_ceil, :ceil)
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/coerce_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/coerce_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/coerce_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,38 +1,7 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/coerce'
-describe "Rational#coerce when passed [Rational]" do
- it "returns the passed argument, self as Floats" do
- result = Rational(3, 4).coerce(1.0)
- result.should == [1.0, 0.75]
- result.first.is_a?(Float).should be_true
- result.last.is_a?(Float).should be_true
+ruby_version_is ""..."1.9" do
+ describe "Rational#coerce" do
+ it_behaves_like(:rational_coerce, :coerce)
end
end
-
-describe "Rational#coerce when passed [Rational]" do
- it "returns the passed argument, self as Rationals" do
- result = Rational(3, 4).coerce(10)
- result.should == [Rational(10, 1), Rational(3, 4)]
- result.first.is_a?(Rational).should be_true
- result.last.is_a?(Rational).should be_true
- end
-end
-
-describe "Rational#coerce" do
- it "does try to convert the passed argument into a Float (using #to_f)" do
- obj = mock("something")
- obj.should_receive(:to_f).and_return(1.1)
- Rational(3, 4).coerce(obj)
- end
-
- it "returns the passed argument, self converted to Floats" do
- obj = mock("something")
- obj.should_receive(:to_f).and_return(1.1)
-
- result = Rational(3, 4).coerce(obj)
- result.should == [1.1, 0.75]
- result.first.is_a?(Float).should be_true
- result.last.is_a?(Float).should be_true
- end
-end
\ No newline at end of file
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/comparison_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/comparison_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/comparison_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,86 +1,23 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/comparison'
-describe "Rational#<=> when passed [Rational]" do
- it "returns 1 when self is greater than the passed argument" do
- (Rational(4, 4) <=> Rational(3, 4)).should equal(1)
- (Rational(-3, 4) <=> Rational(-4, 4)).should equal(1)
+ruby_version_is ""..."1.9" do
+ describe "Rational#<=> when passed a Rational object" do
+ it_behaves_like(:rational_cmp_rat, :<=>)
end
-
- it "returns 0 when self is equal to the passed argument" do
- (Rational(4, 4) <=> Rational(4, 4)).should equal(0)
- (Rational(-3, 4) <=> Rational(-3, 4)).should equal(0)
- end
-
- it "returns -1 when self is less than the passed argument" do
- (Rational(3, 4) <=> Rational(4, 4)).should equal(-1)
- (Rational(-4, 4) <=> Rational(-3, 4)).should equal(-1)
- end
-end
-describe "Rational#<=> when passed [Integer]" do
- it "returns 1 when self is greater than the passed argument" do
- (Rational(4, 4) <=> 0).should equal(1)
- (Rational(4, 4) <=> -10).should equal(1)
- (Rational(-3, 4) <=> -1).should equal(1)
+ describe "Rational#<=> when passed a Integer object" do
+ it_behaves_like(:rational_cmp_int, :<=>)
end
-
- it "returns 0 when self is equal to the passed argument" do
- (Rational(4, 4) <=> 1).should equal(0)
- (Rational(-8, 4) <=> -2).should equal(0)
- end
-
- it "returns -1 when self is less than the passed argument" do
- (Rational(3, 4) <=> 1).should equal(-1)
- (Rational(-4, 4) <=> 0).should equal(-1)
- end
-end
-describe "Rational#<=> when passed [Float]" do
- it "returns 1 when self is greater than the passed argument" do
- (Rational(4, 4) <=> 0.5).should equal(1)
- (Rational(4, 4) <=> -1.5).should equal(1)
- (Rational(-3, 4) <=> -0.8).should equal(1)
+ describe "Rational#<=> when passed a Float object" do
+ it_behaves_like(:rational_cmp_float, :<=>)
end
-
- it "returns 0 when self is equal to the passed argument" do
- (Rational(4, 4) <=> 1.0).should equal(0)
- (Rational(-6, 4) <=> -1.5).should equal(0)
- end
-
- it "returns -1 when self is less than the passed argument" do
- (Rational(3, 4) <=> 1.2).should equal(-1)
- (Rational(-4, 4) <=> 0.5).should equal(-1)
- end
-end
-describe "Rational#<=> when passed an Object that responds to #coerce" do
- it "calls #coerce on the passed argument with self" do
- rational = Rational(3, 4)
-
- obj = mock("Object")
- obj.should_receive(:coerce).with(rational).and_return([1, 2])
-
- rational <=> obj
+ describe "Rational#<=> when passed an Object that responds to #coerce" do
+ it_behaves_like(:rational_cmp_coerce, :<=>)
end
-
- it "calls #<=> on the coerced Rational with the coerced Object" do
- rational = Rational(3, 4)
- coerced_rational = mock("Coerced Rational")
- coerced_rational.should_receive(:<=>).and_return(:result)
-
- coerced_obj = mock("Coerced Object")
-
- obj = mock("Object")
- obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
-
- (rational <=> obj).should == :result
+ describe "Rational#<=> when passed a non-Numeric Object that doesn't respond to #coerce" do
+ it_behaves_like(:rational_cmp_other, :<=>)
end
end
-
-describe "Rational#<=>" do
- it "returns nil" do
- (Rational <=> mock("Object")).should be_nil
- end
-end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/denominator_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/denominator_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/denominator_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,11 +1,7 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/denominator'
-describe "Rational#denominator" do
- it "returns the denominator" do
- Rational(3, 4).denominator.should equal(4)
- Rational(3, -4).denominator.should equal(4)
-
- Rational(1, bignum_value).denominator.should == bignum_value
+ruby_version_is ""..."1.9" do
+ describe "Rational#denominator" do
+ it_behaves_like(:rational_denominator, :denominator)
end
end
Added: MacRuby/branches/experimental/spec/frozen/library/rational/div_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/div_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/div_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,19 @@
+require File.dirname(__FILE__) + '/../../shared/rational/div'
+
+ruby_version_is ""..."1.9" do
+ describe "Rational#div" do
+ it_behaves_like(:rational_div, :div)
+ end
+
+ describe "Rational#div passed a Rational" do
+ it_behaves_like(:rational_div_rat, :div)
+ end
+
+ describe "Rational#div passed an Integer" do
+ it_behaves_like(:rational_div_int, :div)
+ end
+
+ describe "Rational#div passed a Float" do
+ it_behaves_like(:rational_div_float, :div)
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/divide_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/divide_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/divide_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,72 +1,19 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/divide'
-describe "Rational#/ when passed [Rational]" do
- it "returns self divided by other as a Rational" do
- (Rational(3, 4) / Rational(3, 4)).should eql(Rational(1, 1))
- (Rational(2, 4) / Rational(1, 4)).should eql(Rational(2, 1))
-
- (Rational(2, 4) / 2).should == Rational(1, 4)
- (Rational(6, 7) / -2).should == Rational(-3, 7)
+ruby_version_is ""..."1.9" do
+ describe "Rational#/" do
+ it_behaves_like(:rational_divide, :/)
end
-
- it "raises a ZeroDivisionError when passed a Rational with a numerator of 0" do
- lambda { Rational(3, 4) / Rational(0, 1) }.should raise_error(ZeroDivisionError)
- end
-end
-describe "Rational#/ when passed [Integer]" do
- it "returns self divided by other as a Rational" do
- (Rational(3, 4) / 2).should eql(Rational(3, 8))
- (Rational(2, 4) / 2).should eql(Rational(1, 4))
- (Rational(6, 7) / -2).should eql(Rational(-3, 7))
+ describe "Rational#/ when passed an Integer" do
+ it_behaves_like(:rational_divide_int, :/)
end
-
- it "raises a ZeroDivisionError when passed 0" do
- lambda { Rational(3, 4) / 0 }.should raise_error(ZeroDivisionError)
- end
-end
-describe "Raional#/ when passed [Float]" do
- it "returns self divided by other as a Float" do
- (Rational(3, 4) / 0.75).should eql(1.0)
- (Rational(3, 4) / 0.25).should eql(3.0)
- (Rational(3, 4) / 0.3).should eql(2.5)
-
- (Rational(-3, 4) / 0.3).should eql(-2.5)
- (Rational(3, -4) / 0.3).should eql(-2.5)
- (Rational(3, 4) / -0.3).should eql(-2.5)
+ describe "Rational#/ when passed a Rational" do
+ it_behaves_like(:rational_divide_rat, :/)
end
-
- it "returns infinity when passed 0" do
- (Rational(3, 4) / 0.0).infinite?.should eql(1)
- (Rational(-3, -4) / 0.0).infinite?.should eql(1)
-
- (Rational(-3, 4) / 0.0).infinite?.should eql(-1)
- (Rational(3, -4) / 0.0).infinite?.should eql(-1)
- end
-end
-describe "Rational#/" do
- it "calls #coerce on the passed argument with self" do
- rational = Rational(3, 4)
- obj = mock("Object")
- obj.should_receive(:coerce).with(rational).and_return([1, 2])
-
- rational / obj
+ describe "Rational#/ when passed a Float" do
+ it_behaves_like(:rational_divide_float, :/)
end
-
- it "calls #/ on the coerced Rational with the coerced Object" do
- rational = Rational(3, 4)
-
- coerced_rational = mock("Coerced Rational")
- coerced_rational.should_receive(:/).and_return(:result)
-
- coerced_obj = mock("Coerced Object")
-
- obj = mock("Object")
- obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
-
- (rational / obj).should == :result
- end
-end
\ No newline at end of file
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/divmod_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/divmod_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/divmod_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,45 +1,15 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/divmod'
-describe "Rational#divmod when passed [Rational]" do
- it "returns the quotient as Integer and the remainder as Rational" do
- Rational(7, 4).divmod(Rational(1, 2)).should eql([3, Rational(1, 4)])
- Rational(7, 4).divmod(Rational(-1, 2)).should eql([-4, Rational(-1, 4)])
- Rational(0, 4).divmod(Rational(4, 3)).should eql([0, Rational(0, 1)])
-
- Rational(bignum_value, 4).divmod(Rational(4, 3)).should eql([1729382256910270464, Rational(0, 1)])
+ruby_version_is ""..."1.9" do
+ describe "Rational#divmod when passed a Rational" do
+ it_behaves_like(:rational_divmod_rat, :divmod)
end
- it "raises a ZeroDivisonError when passed a Rational with a numerator of 0" do
- lambda { Rational(7, 4).divmod(Rational(0, 3)) }.should raise_error(ZeroDivisionError)
+ describe "Rational#divmod when passed an Integer" do
+ it_behaves_like(:rational_divmod_int, :divmod)
end
-end
-describe "Rational#divmod when passed [Integer]" do
- it "returns the quotient as Integer and the remainder as Rational" do
- Rational(7, 4).divmod(2).should eql([0, Rational(7, 4)])
- Rational(7, 4).divmod(-2).should eql([-1, Rational(-1, 4)])
-
- Rational(bignum_value, 4).divmod(3).should == [768614336404564650, Rational(2, 1)]
+ describe "Rational#divmod when passed a Float" do
+ it_behaves_like(:rational_divmod_float, :divmod)
end
-
- it "raises a ZeroDivisionError when passed 0" do
- lambda { Rational(7, 4).divmod(0) }.should raise_error(ZeroDivisionError)
- end
end
-
-describe "Rational#divmod when passed [Float]" do
- it "returns the quotient as Integer and the remainder as Float" do
- Rational(7, 4).divmod(0.5).should eql([3, 0.25])
- end
-
- ruby_bug "#", "1.8.6" do # Fixed at MRI 1.8.7
- it "returns the quotient as Integer and the remainder as Float" do
- Rational(7, 4).divmod(-0.5).should eql([-4, -0.25])
- end
- end
-
- it "raises a FloatDomainError when passed 0" do
- lambda { Rational(7, 4).divmod(0.0) }.should raise_error(FloatDomainError)
- end
-end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/equal_value_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/equal_value_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/equal_value_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,62 +1,19 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/equal_value'
-describe "Rational#== when passed [Rational]" do
- it "returns true if self has the same numerator and denominator as the passed argument" do
- (Rational(3, 4) == Rational(3, 4)).should be_true
- (Rational(-3, -4) == Rational(3, 4)).should be_true
- (Rational(-4, 5) == Rational(4, -5)).should be_true
-
- (Rational(bignum_value, 3) == Rational(bignum_value, 3)).should be_true
- (Rational(-bignum_value, 3) == Rational(bignum_value, -3)).should be_true
+ruby_version_is ""..."1.9" do
+ describe "Rational#==" do
+ it_behaves_like(:rational_equal_value, :==)
end
-
- ruby_version_is ""..."1.9" do
- it "returns false if self has different numerator/denominator but the same numerical value as the passed argument" do
- (Rational(3, 4) == Rational.new!(6, 8)).should be_false
- (Rational(-3, 4) == Rational.new!(-6, 8)).should be_false
- end
- end
-end
-describe "Rational#== when passed [Integer]" do
- it "returns true if self has the passed argument as numerator and a denominator of 1" do
- # Rational(x, y) reduces x and y automatically
- (Rational(4, 2) == 2).should be_true
- (Rational(-4, 2) == -2).should be_true
- (Rational(4, -2) == -2).should be_true
+ describe "Rational#== when passed a Rational" do
+ it_behaves_like(:rational_equal_value_rat, :==)
end
- ruby_version_is ""..."1.9" do
- it "returns true if self is constructed with #new! and has the passed argument as numerator and a denominator of 1" do
- (Rational.new!(4, 2) == 2).should be_false
- (Rational.new!(9, 3) == 3).should be_false
- end
+ describe "Rational#== when passed a Float" do
+ it_behaves_like(:rational_equal_value_float, :==)
end
-end
-describe "Rational#== when passed [Float]" do
- it "converts self to a Float and compares it with the passed argument" do
- (Rational(3, 4) == 0.75).should be_true
- (Rational(4, 2) == 2.0).should be_true
- (Rational(-4, 2) == -2.0).should be_true
- (Rational(4, -2) == -2.0).should be_true
+ describe "Rational#== when passed an Integer" do
+ it_behaves_like(:rational_equal_value_int, :==)
end
-
- ruby_version_is ""..."1.9" do
- it "converts self to Float and compares it with the passed argument when the #new! constructor is used" do
- # This is inconsistent to behaviour when passed Integers or Rationals
- (Rational.new!(4, 2) == 2.0).should be_true
- (Rational.new!(9, 3) == 3.0).should be_true
- end
- end
-end
-
-describe "Rational#==" do
- it "returns the result of calling #== with self on the passed argument" do
- obj = mock("Object")
- obj.should_receive(:==).and_return(:result)
-
- (Rational(3, 4) == obj).should == :result
- end
-end
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/exponent_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/exponent_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/exponent_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,95 +1,19 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/exponent'
-describe "Rational#** when passed [Rational]" do
- conflicts_with :Prime do
- it "converts self to a Float and returns it raised to the passed argument" do
- (Rational(3, 4) ** Rational(4, 3)).should be_close(0.681420222312052, TOLERANCE)
- (Rational(3, 4) ** Rational(-4, 3)).should be_close(1.46752322173095, TOLERANCE)
- (Rational(3, 4) ** Rational(4, -3)).should be_close(1.46752322173095, TOLERANCE)
-
- (Rational(3, 4) ** Rational(0, 3)).should eql(1.0)
- (Rational(-3, 4) ** Rational(0, 3)).should eql(1.0)
- (Rational(3, -4) ** Rational(0, 3)).should eql(1.0)
- (Rational(3, 4) ** Rational(0, -3)).should eql(1.0)
-
- (Rational(bignum_value, 4) ** Rational(0, 3)).should eql(1.0)
- (Rational(3, -bignum_value) ** Rational(0, 3)).should eql(1.0)
- (Rational(3, 4) ** Rational(0, bignum_value)).should eql(1.0)
- (Rational(3, 4) ** Rational(0, -bignum_value)).should eql(1.0)
- end
-
- it "returns NaN when self is negative and the passed argument is not 0" do
- (Rational(-3, 4) ** Rational(-4, 3)).nan?.should be_true
- end
+ruby_version_is ""..."1.9" do
+ describe "Rational#**" do
+ it_behaves_like(:rational_exponent, :**)
end
-end
-describe "Rational#** when passed [Integer]" do
- it "returns the Rational value of self raised to the passed argument" do
- (Rational(3, 4) ** 4).should == Rational(81, 256)
- (Rational(3, 4) ** -4).should == Rational(256, 81)
- (Rational(-3, 4) ** -4).should == Rational(256, 81)
- (Rational(3, -4) ** -4).should == Rational(256, 81)
-
- (Rational(bignum_value, 4) ** 4).should == Rational(28269553036454149273332760011886696253239742350009903329945699220681916416, 1)
- (Rational(3, bignum_value) ** -4).should == Rational(7237005577332262213973186563042994240829374041602535252466099000494570602496, 81)
- (Rational(-bignum_value, 4) ** -4).should == Rational(1, 28269553036454149273332760011886696253239742350009903329945699220681916416)
- (Rational(3, -bignum_value) ** -4).should == Rational(7237005577332262213973186563042994240829374041602535252466099000494570602496, 81)
+ describe "Rational#** when passed Rational" do
+ it_behaves_like(:rational_exponent_rat, :**)
end
-
- conflicts_with :Prime do
- it "returns Rational(1, 1) when the passed argument is 0" do
- (Rational(3, 4) ** 0).should eql(Rational(1, 1))
- (Rational(-3, 4) ** 0).should eql(Rational(1, 1))
- (Rational(3, -4) ** 0).should eql(Rational(1, 1))
- (Rational(bignum_value, 4) ** 0).should eql(Rational(1, 1))
- (Rational(3, -bignum_value) ** 0).should eql(Rational(1, 1))
- end
+ describe "Rational#** when passed Float" do
+ it_behaves_like(:rational_exponent_float, :**)
end
-end
-describe "Rational#** when passed [Float]" do
- it "returns self converted to Float and raised to the passed argument" do
- (Rational(3, 1) ** 3.0).should eql(27.0)
- (Rational(3, 1) ** 1.5).should be_close(5.19615242270663, TOLERANCE)
- (Rational(3, 1) ** -1.5).should be_close(0.192450089729875, TOLERANCE)
+ describe "Rational#** when pass Integer" do
+ it_behaves_like(:rational_exponent_int, :**)
end
-
- it "returns 1.0 when the passed argument is 0" do
- (Rational(3, 4) ** 0.0).should eql(1.0)
- (Rational(-3, 4) ** 0.0).should eql(1.0)
- (Rational(-3, 4) ** 0.0).should eql(1.0)
- end
-
- it "returns NaN if self is negative and the passed argument is not 0" do
- (Rational(-3, 2) ** 1.5).nan?.should be_true
- (Rational(3, -2) ** 1.5).nan?.should be_true
- (Rational(3, -2) ** -1.5).nan?.should be_true
- end
end
-
-describe "Rational#**" do
- it "calls #coerce on the passed argument with self" do
- rational = Rational(3, 4)
- obj = mock("Object")
- obj.should_receive(:coerce).with(rational).and_return([1, 2])
-
- rational ** obj
- end
-
- it "calls #** on the coerced Rational with the coerced Object" do
- rational = Rational(3, 4)
-
- coerced_rational = mock("Coerced Rational")
- coerced_rational.should_receive(:**).and_return(:result)
-
- coerced_obj = mock("Coerced Object")
-
- obj = mock("Object")
- obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
-
- (rational ** obj).should == :result
- end
-end
Added: MacRuby/branches/experimental/spec/frozen/library/rational/fdiv_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/fdiv_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/fdiv_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/fdiv'
+
+ruby_version_is ""..."1.9" do
+ describe "Rational#fdiv" do
+ it_behaves_like(:rational_fdiv, :fdiv)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/library/rational/floor_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/floor_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/floor_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/floor'
+
+ruby_version_is ""..."1.9" do
+ describe "Rational#floor" do
+ it_behaves_like(:rational_floor, :floor)
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/hash_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/hash_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/hash_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,10 +1,7 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/hash'
-describe "Rational#hash" do
- # BUG: Rational(2, 3).hash == Rational(3, 2).hash
- it "is static" do
- Rational(2, 3).hash.should == Rational(2, 3).hash
- Rational(2, 4).hash.should_not == Rational(2, 3).hash
+ruby_version_is ""..."1.9" do
+ describe "Rational#hash" do
+ it_behaves_like(:rational_hash, :hash)
end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/initialize_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/initialize_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/initialize_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,21 +1,9 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/initialize'
-describe "Rational#initialize" do
- before(:each) do
- @rational = Rational.allocate
+ruby_version_is ""..."1.9" do
+ describe "Rational#initialize" do
+ it_behaves_like(:rational_initialize, :initialize)
end
-
- it "turns around the numerators and denominators signs around when the denominator is negative" do
- @rational.send(:initialize, 1, -2)
- @rational.numerator.should == -1
- @rational.denominator.should == 2
- end
+end
- # I think this should work (at least Rational#initialize seems to be intended for this)
- # it "tries to convert the passed numerator and denominator to Integers using #to_i" do
- # @rational.send(:initialize, "1", "2")
- # @rational.numerator.should == "1"
- # @rational.denominator.should == "2"
- # end
-end
+
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/inspect_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/inspect_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/inspect_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,13 +1,7 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/inspect'
-describe "Rational#inspect" do
- conflicts_with :Prime do
- it "returns a reconstructable string representation of self" do
- Rational(3, 4).inspect.should == "Rational(3, 4)"
- Rational(-5, 8).inspect.should == "Rational(-5, 8)"
- Rational(-1, -2).inspect.should == "Rational(1, 2)"
- Rational(bignum_value, 1).inspect.should == "Rational(#{bignum_value}, 1)"
- end
+ruby_version_is ""..."1.9" do
+ describe "Rational#inspect" do
+ it_behaves_like(:rational_inspect, :inspect)
end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/minus_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/minus_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/minus_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,49 +1,7 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/minus'
-describe "Rational#- when passed [Rational]" do
- it "returns the result of substracting other from self as a Rational" do
- (Rational(3, 4) - Rational(0, 1)).should eql(Rational(3, 4))
- (Rational(3, 4) - Rational(1, 4)).should eql(Rational(1, 2))
-
- (Rational(3, 4) - Rational(2, 1)).should eql(Rational(-5, 4))
+ruby_version_is ""..."1.9" do
+ describe "Rational#-" do
+ it_behaves_like(:rational_minus, :-)
end
end
-
-describe "Rational#- when passed [Integer]" do
- it "returns the result of substracting other from self as a Rational" do
- (Rational(3, 4) - 1).should eql(Rational(-1, 4))
- (Rational(3, 4) - 2).should eql(Rational(-5, 4))
- end
-end
-
-describe "Rational#- when passed [Float]" do
- it "returns the result of substracting other from self as a Float" do
- (Rational(3, 4) - 0.2).should eql(0.55)
- (Rational(3, 4) - 2.5).should eql(-1.75)
- end
-end
-
-describe "Rational#-" do
- it "calls #coerce on the passed argument with self" do
- rational = Rational(3, 4)
- obj = mock("Object")
- obj.should_receive(:coerce).with(rational).and_return([1, 2])
-
- rational - obj
- end
-
- it "calls #- on the coerced Rational with the coerced Object" do
- rational = Rational(3, 4)
-
- coerced_rational = mock("Coerced Rational")
- coerced_rational.should_receive(:-).and_return(:result)
-
- coerced_obj = mock("Coerced Object")
-
- obj = mock("Object")
- obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
-
- (rational - obj).should == :result
- end
-end
\ No newline at end of file
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/modulo_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/modulo_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/modulo_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,34 +1,7 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/modulo'
-describe "Rational#%" do
- it "returns the remainder when this value is divided by other" do
- (Rational(2, 3) % Rational(2, 3)).should == Rational(0, 1)
- (Rational(4, 3) % Rational(2, 3)).should == Rational(0, 1)
- (Rational(2, -3) % Rational(-2, 3)).should == Rational(0, 1)
- (Rational(0, -1) % -1).should == Rational(0, 1)
-
- (Rational(7, 4) % Rational(1, 2)).should == Rational(1, 4)
- (Rational(7, 4) % 1).should == Rational(3, 4)
- (Rational(7, 4) % Rational(1, 7)).should == Rational(1, 28)
-
- (Rational(3, 4) % -1).should == Rational(-1, 4)
- (Rational(1, -5) % -1).should == Rational(-1, 5)
+ruby_version_is ""..."1.9" do
+ describe "Rational#%" do
+ it_behaves_like(:rational_modulo, :%)
end
-
- it "returns a Float value when the argument is Float" do
- (Rational(7, 4) % 1.0).should be_kind_of(Float)
- (Rational(7, 4) % 1.0).should == 0.75
- (Rational(7, 4) % 0.26).should be_close(0.19, 0.0001)
- end
-
- it "raises ZeroDivisionError on zero denominator" do
- lambda { Rational(3, 5) % Rational(0, 1) }.should raise_error(ZeroDivisionError)
- lambda { Rational(0, 1) % Rational(0, 1) }.should raise_error(ZeroDivisionError)
- lambda { Rational(3, 5) % 0 }.should raise_error(ZeroDivisionError)
- end
-
- it "raises FloatDomainError when the argument is 0.0" do
- lambda { Rational(3, 5) % 0.0 }.should raise_error(FloatDomainError)
- end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/multiply_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/multiply_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/multiply_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,63 +1,19 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/multiply'
-describe "Rational#* when passed [Rational]" do
- it "returns self divided by other as a Rational" do
- (Rational(3, 4) * Rational(3, 4)).should eql(Rational(9, 16))
- (Rational(2, 4) * Rational(1, 4)).should eql(Rational(1, 8))
-
- (Rational(3, 4) * Rational(0, 1)).should eql(Rational(0, 4))
+ruby_version_is ""..."1.9" do
+ describe "Rational#*" do
+ it_behaves_like(:rational_multiply, :*)
end
-end
-describe "Rational#* when passed [Integer]" do
- it "returns self divided by other as a Rational" do
- (Rational(3, 4) * 2).should eql(Rational(3, 2))
- (Rational(2, 4) * 2).should eql(Rational(1, 1))
- (Rational(6, 7) * -2).should eql(Rational(-12, 7))
-
- (Rational(3, 4) * 0).should eql(Rational(0, 4))
+ describe "Rational#* passed a Rational" do
+ it_behaves_like(:rational_multiply_rat, :*)
end
-end
-describe "Raional#/ when passed [Float]" do
- it "returns self divided by other as a Float" do
- (Rational(3, 4) * 0.75).should eql(0.5625)
- (Rational(3, 4) * 0.25).should eql(0.1875)
- (Rational(3, 4) * 0.3).should be_close(0.225, TOLERANCE)
-
- (Rational(-3, 4) * 0.3).should be_close(-0.225, TOLERANCE)
- (Rational(3, -4) * 0.3).should be_close(-0.225, TOLERANCE)
- (Rational(3, 4) * -0.3).should be_close(-0.225, TOLERANCE)
-
- (Rational(3, 4) * 0.0).should eql(0.0)
- (Rational(-3, -4) * 0.0).should eql(0.0)
-
- (Rational(-3, 4) * 0.0).should eql(0.0)
- (Rational(3, -4) * 0.0).should eql(0.0)
+ describe "Rational#* passed a Float" do
+ it_behaves_like(:rational_multiply_float, :*)
end
-end
-describe "Rational#*" do
- it "calls #coerce on the passed argument with self" do
- rational = Rational(3, 4)
- obj = mock("Object")
- obj.should_receive(:coerce).with(rational).and_return([1, 2])
-
- rational * obj
+ describe "Rational#* passed an Integer" do
+ it_behaves_like(:rational_multiply_int, :*)
end
-
- it "calls #* on the coerced Rational with the coerced Object" do
- rational = Rational(3, 4)
-
- coerced_rational = mock("Coerced Rational")
- coerced_rational.should_receive(:*).and_return(:result)
-
- coerced_obj = mock("Coerced Object")
-
- obj = mock("Object")
- obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
-
- (rational * obj).should == :result
- end
-end
\ No newline at end of file
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/new_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/new_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/new_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,23 +1,11 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/new'
ruby_version_is ""..."1.9" do
describe "Rational.new" do
- it "is private" do
- Rational.private_methods.should include("new")
- end
+ it_behaves_like(:rational_new, :new)
end
describe "Rational.new!" do
- it "returns a Rational with the passed numerator and denominator not reduced to their lowest terms" do
- Rational.new!(2, 4).should_not eql(Rational(1, 4))
- Rational.new!(6, 8).should_not eql(Rational(3, 4))
- Rational.new!(-5, 10).should_not eql(Rational(-1, 2))
- end
-
- it "does not check for divisions by 0" do
- lambda { Rational.new!(4, 0) }.should_not raise_error(ZeroDivisionError)
- lambda { Rational.new!(0, 0) }.should_not raise_error(ZeroDivisionError)
- end
+ it_behaves_like(:rational_new, :new!)
end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/numerator_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/numerator_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/numerator_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,11 +1,7 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/numerator'
-describe "Rational#numerator" do
- it "returns the numerator" do
- Rational(3, 4).numerator.should equal(3)
- Rational(3, -4).numerator.should equal(-3)
-
- Rational(bignum_value, 1).numerator.should == bignum_value
+ruby_version_is ""..."1.9" do
+ describe "Rational#numerator" do
+ it_behaves_like(:rational_numerator, :numerator)
end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/plus_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/plus_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/plus_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,49 +1,18 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/plus'
-describe "Rational#+ when passed [Rational]" do
- it "returns the result of substracting other from self as a Rational" do
- (Rational(3, 4) + Rational(0, 1)).should eql(Rational(3, 4))
- (Rational(3, 4) + Rational(1, 4)).should eql(Rational(1, 1))
-
- (Rational(3, 4) + Rational(2, 1)).should eql(Rational(11, 4))
+ruby_version_is ""..."1.9" do
+ describe "Rational#+" do
+ it_behaves_like(:rational_plus, :+)
end
-end
-describe "Rational#+ when passed [Integer]" do
- it "returns the result of substracting other from self as a Rational" do
- (Rational(3, 4) + 1).should eql(Rational(7, 4))
- (Rational(3, 4) + 2).should eql(Rational(11, 4))
+ describe "Rational#+ with a Rational" do
+ it_behaves_like(:rational_plus_rat, :+)
end
-end
-
-describe "Rational#+ when passed [Float]" do
- it "returns the result of substracting other from self as a Float" do
- (Rational(3, 4) + 0.2).should eql(0.95)
- (Rational(3, 4) + 2.5).should eql(3.25)
+ describe "Rational#+ with a Float" do
+ it_behaves_like(:rational_plus_float, :+)
end
-end
-describe "Rational#+" do
- it "calls #coerce on the passed argument with self" do
- rational = Rational(3, 4)
- obj = mock("Object")
- obj.should_receive(:coerce).with(rational).and_return([1, 2])
-
- rational + obj
+ describe "Rational#+ with an Integer" do
+ it_behaves_like(:rational_plus_int, :+)
end
-
- it "calls #+ on the coerced Rational with the coerced Object" do
- rational = Rational(3, 4)
-
- coerced_rational = mock("Coerced Rational")
- coerced_rational.should_receive(:+).and_return(:result)
-
- coerced_obj = mock("Coerced Object")
-
- obj = mock("Object")
- obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
-
- (rational + obj).should == :result
- end
-end
\ No newline at end of file
+end
Added: MacRuby/branches/experimental/spec/frozen/library/rational/quo_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/quo_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/quo_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/divide'
+
+ruby_version_is ""..."1.9" do
+ describe "Rational#quo" do
+ it_behaves_like(:rational_divide, :quo)
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/reduce_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/reduce_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/reduce_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,34 +1,11 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/reduce'
-
ruby_version_is ""..."1.9" do
- describe "Rational.reduce when Unify is defined" do
- # This is not consistent with the Complex library, Complex checks
- # Complex::Unify and not the top-level Unify.
- it "returns an Integer when the reduced denominator is 1" do
- begin
- Unify = true
-
- Rational.reduce(3, 1).should eql(3)
- Rational.reduce(5, 1).should eql(5)
- Rational.reduce(4, 2).should eql(2)
- Rational.reduce(-9, 3).should eql(-3)
- ensure
- Object.send :remove_const, :Unify
- end
- end
+ describe "Rational.reduce" do
+ it_behaves_like(:rational_reduce, :reduce)
end
- describe "Rational.reduce" do
- it "returns a new Rational with the passed numerator and denominator reduced to their lowest terms" do
- Rational(6, 8).should eql(Rational(3, 4))
- Rational(-5, 10).should eql(Rational(-1, 2))
- end
-
- it "raises a ZeroDivisionError when the passed denominator is 0" do
- lambda { Rational.reduce(4, 0) }.should raise_error(ZeroDivisionError)
- lambda { Rational.reduce(-1, 0) }.should raise_error(ZeroDivisionError)
- end
+ describe "Rational.reduce when Unify is defined" do
+ it_behaves_like(:rational_reduce_unfiy, :reduce)
end
end
Added: MacRuby/branches/experimental/spec/frozen/library/rational/remainder_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/remainder_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/remainder_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/remainder'
+
+ruby_version_is ""..."1.9" do
+ describe "Rational#remainder" do
+ it_behaves_like(:rational_remainder, :remainder)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/library/rational/round_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/round_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/round_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/round'
+
+ruby_version_is ""..."1.9" do
+ describe "Rational#round" do
+ it_behaves_like(:rational_round, :round)
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/to_f_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/to_f_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/to_f_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,11 +1,7 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/to_f'
-describe "Rational#to_f" do
- it "returns self converted to a Float" do
- Rational(3, 4).to_f.should eql(0.75)
- Rational(3, -4).to_f.should eql(-0.75)
- Rational(-1, 4).to_f.should eql(-0.25)
- Rational(-1, -4).to_f.should eql(0.25)
+ruby_version_is ""..."1.9" do
+ describe "Rational#to_f" do
+ it_behaves_like(:rational_to_f, :to_f)
end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/to_i_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/to_i_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/to_i_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,16 +1,7 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/to_i'
-describe "Rational#to_i" do
- it "converts self to an Integer by truncation" do
- Rational(7, 4).to_i.should eql(1)
- Rational(11, 4).to_i.should eql(2)
+ruby_version_is ""..."1.9" do
+ describe "Rational#to_i" do
+ it_behaves_like(:rational_to_i, :to_i)
end
-
- ruby_bug "#", "1.8.6" do
- it "converts self to an Integer by truncation" do
- Rational(-7, 4).to_i.should eql(-1)
- end
- end
-
end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/to_r_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/to_r_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/to_r_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,14 +1,7 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/to_r'
-describe "Rational#to_r" do
- conflicts_with :Prime do
- it "returns self" do
- a = Rational(3, 4)
- a.to_r.should equal(a)
-
- a = Rational(bignum_value, 4)
- a.to_r.should equal(a)
- end
+ruby_version_is ""..."1.9" do
+ describe "Rational#to_r" do
+ it_behaves_like(:rational_to_r, :to_r)
end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/to_s_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/to_s_spec.rb 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/to_s_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,12 +1,7 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'rational'
+require File.dirname(__FILE__) + '/../../shared/rational/to_s'
-describe "Rational#to_s" do
- it "returns a string representation of self" do
- Rational(1, 1).to_s.should == "1"
- Rational(2, 1).to_s.should == "2"
- Rational(1, 2).to_s.should == "1/2"
- Rational(-1, 3).to_s.should == "-1/3"
- Rational(1, -3).to_s.should == "-1/3"
+ruby_version_is ""..."1.9" do
+ describe "Rational#to_s" do
+ it_behaves_like(:rational_to_s, :to_s)
end
end
Added: MacRuby/branches/experimental/spec/frozen/library/rational/truncate_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/truncate_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/truncate_spec.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/rational/truncate'
+
+ruby_version_is ""..."1.9" do
+ describe "Rational#truncate" do
+ it_behaves_like(:rational_truncate, :truncate)
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/ruby.1.8.mspec
===================================================================
--- MacRuby/branches/experimental/spec/frozen/ruby.1.8.mspec 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/ruby.1.8.mspec 2009-06-18 20:38:24 UTC (rev 1879)
@@ -44,4 +44,12 @@
# The default implementation to run the specs
set :target, 'ruby'
+
+ set :tags_patterns, [
+ [%r(language/), 'tags/1.8/language/'],
+ [%r(core/), 'tags/1.8/core/'],
+ [%r(command_line/), 'tags/1.8/command_line/'],
+ [%r(library/), 'tags/1.8/library/'],
+ [/_spec.rb$/, '_tags.txt']
+ ]
end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/Rational.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/Rational.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/Rational.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,114 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_rational_two, :shared => true do
+ before(:each) do
+ @args = {
+ [1, 2] => [1, 2],
+ [2, 1] => [2, 1],
+ ["6", 5] => [6, 5],
+ [-8, -6] => [4, 3],
+ [99999**99, 209] => [999010484943188636608805980402802915400434536979655386654009490813859457598616206837179821412302692420911878238392114694353872205705469979997758000847544074497398071603034467574810862492956315403164145181317850364010376300213453752437982265518464568325790559557401725276413045564927258325699353130042548208064924009216093547546101231747525975999315735437260590254281341103015581933843191009768771215462495272328209801935290153265929807401919949633636861142033871459231063562556848951490009899999, 209],
+ [30.21, 0.22] => [362809985980967168, 2642111781390691],
+ [-28, 2.3] => [-31525197391593472, 2589569785738035]
+ }
+ end
+
+ it "returns a Rational instance" do
+ @args.each_pair do |arguments, expected|
+ rat = Rational(arguments.first, arguments.last)
+ rat.should be_an_instance_of(Rational)
+ end
+ end
+
+ it "sets the numerator to the first argument" do
+ @args.each_pair do |arguments, expected|
+ rat = Rational(arguments.first, arguments.last)
+ rat.numerator.should == expected.first
+ end
+ end
+
+ it "sets the denominator to the second argument" do
+ @args.each_pair do |arguments, expected|
+ rat = Rational(arguments.first, arguments.last)
+ rat.denominator.should == expected.last
+ end
+ end
+
+ it "automatically reduces the Rational" do
+ rat = Rational(2, 4)
+ rat.numerator.should == 1
+ rat.denominator.should == 2
+
+ rat = Rational(3, 9)
+ rat.numerator.should == 1
+ rat.denominator.should == 3
+ end
+end
+
+describe :rational_rational_int_int, :shared => true do
+ it "returns a new Rational number" do
+ rat = Rational(1, 2)
+ rat.numerator.should == 1
+ rat.denominator.should == 2
+ rat.should be_an_instance_of(Rational)
+
+ rat = Rational(-3, -5)
+ rat.numerator.should == 3
+ rat.denominator.should == 5
+ rat.should be_an_instance_of(Rational)
+
+ rat = Rational(bignum_value, 3)
+ rat.numerator.should == bignum_value
+ rat.denominator.should == 3
+ rat.should be_an_instance_of(Rational)
+ end
+
+ it "automatically reduces the Rational" do
+ rat = Rational(2, 4)
+ rat.numerator.should == 1
+ rat.denominator.should == 2
+
+ rat = Rational(3, 9)
+ rat.numerator.should == 1
+ rat.denominator.should == 3
+ end
+end
+
+
+describe :rational_rational_int, :shared => true do
+ # Guard against the Mathn library
+ conflicts_with :Prime do
+ ruby_version_is ""..."1.9" do
+ it "returns a new Rational number with 1 as the denominator" do
+ Rational(1).should eql(Rational.new!(1, 1))
+ Rational(-3).should eql(Rational.new!(-3, 1))
+ Rational(bignum_value).should eql(Rational.new!(bignum_value, 1))
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "returns a new Rational number with 1 as the denominator" do
+ Rational(1).should eql(Rational(1, 1))
+ Rational(-3).should eql(Rational(-3, 1))
+ Rational(bignum_value).should eql(Rational(bignum_value, 1))
+ end
+ end
+ end
+end
+
+ruby_version_is ""..."1.9" do
+ describe :rational_rational_int_rat_unify, :shared => true do
+ after :each do
+ Rational.send :remove_const, :Unify
+ end
+
+ it "returns the passed Integer when Rational::Unify is defined" do
+ Rational::Unify = true
+
+ Rational(1).should eql(1)
+ Rational(-3).should eql(-3)
+ Rational(bignum_value).should eql(bignum_value)
+ end
+ end
+end
Copied: MacRuby/branches/experimental/spec/frozen/shared/rational/abs.rb (from rev 1878, MacRuby/branches/experimental/spec/frozen/library/rational/abs_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/abs.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/abs.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,12 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_abs, :shared => true do
+ it "returns self's absolute value" do
+ Rational(3, 4).abs.should == Rational(3, 4)
+ Rational(-3, 4).abs.should == Rational(3, 4)
+ Rational(3, -4).abs.should == Rational(3, 4)
+
+ Rational(bignum_value, -bignum_value).abs.should == Rational(bignum_value, bignum_value)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/ceil.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/ceil.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/ceil.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,41 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.9" do
+ describe :rational_ceil, :shared => true do
+ it "returns an Integer" do
+ Rational(19.18).ceil.should be_kind_of(Integer)
+ end
+
+ it "returns the smallest integer >= self as an integer" do
+ Rational(200, 87).ceil.should == 3
+ Rational(6.1, 9).ceil.should == 1
+ Rational(686543**99).ceil.should == 686543**99
+ end
+ end
+end
+
+ruby_version_is ""..."1.9" do
+
+ require 'rational'
+
+ describe :rational_ceil, :shared => true do
+ it "returns an Integer" do
+ Rational(19).ceil.should be_kind_of(Integer)
+ end
+
+ ruby_version_is ""..."1.8.6" do
+ it "returns the smallest integer >= self as an integer" do
+ Rational(200, 87).ceil.should == 3
+ Rational(6, 9).ceil.should == 1
+ end
+ end
+
+ ruby_version_is "1.8.6"..."" do
+ it "returns the smallest integer >= self as an integer" do
+ Rational(200, 87).ceil.should == 3
+ Rational(6, 9).ceil.should == 1
+ Rational(686543**99).ceil.should == 686543**99
+ end
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/coerce.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/coerce.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/coerce.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,41 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_coerce, :shared => true do
+ it "returns the passed argument, self as Float, when given a Float" do
+ result = Rational(3, 4).coerce(1.0)
+ result.should == [1.0, 0.75]
+ result.first.is_a?(Float).should be_true
+ result.last.is_a?(Float).should be_true
+ end
+
+ it "returns the passed argument, self as Rational, when given an Integer" do
+ result = Rational(3, 4).coerce(10)
+ result.should == [Rational(10, 1), Rational(3, 4)]
+ result.first.is_a?(Rational).should be_true
+ result.last.is_a?(Rational).should be_true
+ end
+
+ # This failed on 1.9 as reported in bug #1636. It was fixed in revision 23718
+ it "returns [argument, self] when given a Rational" do
+ Rational(3, 7).coerce(Rational(9, 2)).should == [Rational(9, 2), Rational(3, 7)]
+ end
+
+ ruby_version_is ""..."1.9" do
+ it "tries to convert the passed argument into a Float (using #to_f)" do
+ obj = mock("something")
+ obj.should_receive(:to_f).and_return(1.1)
+ Rational(3, 4).coerce(obj)
+ end
+
+ it "returns the passed argument, self converted to Float, when given object with #to_f" do
+ obj = mock("something")
+ obj.should_receive(:to_f).and_return(1.1)
+
+ result = Rational(3, 4).coerce(obj)
+ result.should == [1.1, 0.75]
+ result.first.is_a?(Float).should be_true
+ result.last.is_a?(Float).should be_true
+ end
+ end
+end
Copied: MacRuby/branches/experimental/spec/frozen/shared/rational/comparison.rb (from rev 1878, MacRuby/branches/experimental/spec/frozen/library/rational/comparison_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/comparison.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/comparison.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,86 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_cmp_rat, :shared => true do
+ it "returns 1 when self is greater than the passed argument" do
+ (Rational(4, 4) <=> Rational(3, 4)).should equal(1)
+ (Rational(-3, 4) <=> Rational(-4, 4)).should equal(1)
+ end
+
+ it "returns 0 when self is equal to the passed argument" do
+ (Rational(4, 4) <=> Rational(4, 4)).should equal(0)
+ (Rational(-3, 4) <=> Rational(-3, 4)).should equal(0)
+ end
+
+ it "returns -1 when self is less than the passed argument" do
+ (Rational(3, 4) <=> Rational(4, 4)).should equal(-1)
+ (Rational(-4, 4) <=> Rational(-3, 4)).should equal(-1)
+ end
+end
+
+describe :rational_cmp_int, :shared => true do
+ it "returns 1 when self is greater than the passed argument" do
+ (Rational(4, 4) <=> 0).should equal(1)
+ (Rational(4, 4) <=> -10).should equal(1)
+ (Rational(-3, 4) <=> -1).should equal(1)
+ end
+
+ it "returns 0 when self is equal to the passed argument" do
+ (Rational(4, 4) <=> 1).should equal(0)
+ (Rational(-8, 4) <=> -2).should equal(0)
+ end
+
+ it "returns -1 when self is less than the passed argument" do
+ (Rational(3, 4) <=> 1).should equal(-1)
+ (Rational(-4, 4) <=> 0).should equal(-1)
+ end
+end
+
+describe :rational_cmp_float, :shared => true do
+ it "returns 1 when self is greater than the passed argument" do
+ (Rational(4, 4) <=> 0.5).should equal(1)
+ (Rational(4, 4) <=> -1.5).should equal(1)
+ (Rational(-3, 4) <=> -0.8).should equal(1)
+ end
+
+ it "returns 0 when self is equal to the passed argument" do
+ (Rational(4, 4) <=> 1.0).should equal(0)
+ (Rational(-6, 4) <=> -1.5).should equal(0)
+ end
+
+ it "returns -1 when self is less than the passed argument" do
+ (Rational(3, 4) <=> 1.2).should equal(-1)
+ (Rational(-4, 4) <=> 0.5).should equal(-1)
+ end
+end
+
+describe :rational_cmp_coerce, :shared => true do
+ it "calls #coerce on the passed argument with self" do
+ rational = Rational(3, 4)
+
+ obj = mock("Object")
+ obj.should_receive(:coerce).with(rational).and_return([1, 2])
+
+ rational <=> obj
+ end
+
+ it "calls #<=> on the coerced Rational with the coerced Object" do
+ rational = Rational(3, 4)
+
+ coerced_rational = mock("Coerced Rational")
+ coerced_rational.should_receive(:<=>).and_return(:result)
+
+ coerced_obj = mock("Coerced Object")
+
+ obj = mock("Object")
+ obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
+
+ (rational <=> obj).should == :result
+ end
+end
+
+describe :rational_cmp_other, :shared => true do
+ it "returns nil" do
+ (Rational <=> mock("Object")).should be_nil
+ end
+end
Copied: MacRuby/branches/experimental/spec/frozen/shared/rational/denominator.rb (from rev 1878, MacRuby/branches/experimental/spec/frozen/library/rational/denominator_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/denominator.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/denominator.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,15 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_denominator, :shared => true do
+ it "returns the denominator" do
+ Rational(3, 4).denominator.should equal(4)
+ Rational(3, -4).denominator.should equal(4)
+
+ Rational(1, bignum_value).denominator.should == bignum_value
+ end
+
+ it "returns 1 if no denominator was given" do
+ Rational(80).denominator.should == 1
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/div.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/div.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/div.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,72 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_div_rat, :shared => true do
+ it "performs integer division and returns the result" do
+ Rational(2, 3).div(Rational(2, 3)).should == 1
+ Rational(-2, 9).div(Rational(-9, 2)).should == 0
+ end
+
+ it "raises a ZeroDivisionError when the argument has a numerator of 0" do
+ lambda { Rational(3, 4).div(Rational(0, 3)) }.should raise_error(ZeroDivisionError)
+ end
+
+ # 1.8 doesn't accept Floats for Rational() arguments
+ ruby_version_is "1.9" do
+ it "raises a ZeroDivisionError when the argument has a numerator of 0.0" do
+ lambda { Rational(3, 4).div(Rational(0.0, 3)) }.should raise_error(ZeroDivisionError)
+ end
+ end
+end
+
+describe :rational_div_float, :shared => true do
+
+ # The version guard is necessary because 1.8 can't cope with Floats passed
+ # to Rational(), so we need to simplify the examples accordingly.
+
+ ruby_version_is "1.9" do
+ it "performs integer division and returns the result" do
+ Rational(2, 3).div(30.333).should == 0
+ Rational(2, 9).div(Rational(-8.6)).should == -1
+ Rational(3.12).div(0.5).should == 6
+ end
+ end
+
+ ruby_version_is ""..."1.9" do
+ it "performs integer division and returns the result" do
+ Rational(2, 3).div(30.333).should == 0
+ Rational(7, 12).div(0.5).should == 1
+ end
+ end
+
+ it "raises a FloatDomainError when the argument is 0.0" do
+ lambda { Rational(3, 4).div(0.0) }.should raise_error(FloatDomainError)
+ end
+end
+
+describe :rational_div_int, :shared => true do
+ it "performs integer division and returns the result" do
+ Rational(2, 1).div(1).should == 2
+ Rational(25, 5).div(-50).should == -1
+ end
+
+ it "raises a ZeroDivisionError when the argument is 0" do
+ lambda { Rational(3, 4).div(0) }.should raise_error(ZeroDivisionError)
+ end
+end
+
+describe :rational_div, :shared => true do
+ it "returns an Integer" do
+ Rational(229, 21).div(82).should be_kind_of(Integer)
+ end
+
+ it "raises an ArgumentError if passed more than one argument" do
+ lambda { Rational(3, 4).div(2,3) }.should raise_error(ArgumentError)
+ end
+
+ ruby_bug "#1648", "1.8.7" do
+ it "raises a TypeError if passed a non-numeric argument" do
+ lambda { Rational(3, 4).div([]) }.should raise_error(TypeError)
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/divide.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/divide.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/divide.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,72 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_divide_rat, :shared => true do
+ it "returns self divided by other as a Rational" do
+ Rational(3, 4).send(@method, Rational(3, 4)).should eql(Rational(1, 1))
+ Rational(2, 4).send(@method, Rational(1, 4)).should eql(Rational(2, 1))
+
+ Rational(2, 4).send(@method, 2).should == Rational(1, 4)
+ Rational(6, 7).send(@method, -2).should == Rational(-3, 7)
+ end
+
+ it "raises a ZeroDivisionError when passed a Rational with a numerator of 0" do
+ lambda { Rational(3, 4).send(@method, Rational(0, 1)) }.should raise_error(ZeroDivisionError)
+ end
+end
+
+describe :rational_divide_int, :shared => true do
+ it "returns self divided by other as a Rational" do
+ Rational(3, 4).send(@method, 2).should eql(Rational(3, 8))
+ Rational(2, 4).send(@method, 2).should eql(Rational(1, 4))
+ Rational(6, 7).send(@method, -2).should eql(Rational(-3, 7))
+ end
+
+ it "raises a ZeroDivisionError when passed 0" do
+ lambda { Rational(3, 4).send(@method, 0) }.should raise_error(ZeroDivisionError)
+ end
+end
+
+describe :rational_divide_float, :shared => true do
+ it "returns self divided by other as a Float" do
+ Rational(3, 4).send(@method, 0.75).should eql(1.0)
+ Rational(3, 4).send(@method, 0.25).should eql(3.0)
+ Rational(3, 4).send(@method, 0.3).should eql(2.5)
+
+ Rational(-3, 4).send(@method, 0.3).should eql(-2.5)
+ Rational(3, -4).send(@method, 0.3).should eql(-2.5)
+ Rational(3, 4).send(@method, -0.3).should eql(-2.5)
+ end
+
+ it "returns infinity when passed 0" do
+ Rational(3, 4).send(@method, 0.0).infinite?.should eql(1)
+ Rational(-3, -4).send(@method, 0.0).infinite?.should eql(1)
+
+ Rational(-3, 4).send(@method, 0.0).infinite?.should eql(-1)
+ Rational(3, -4).send(@method, 0.0).infinite?.should eql(-1)
+ end
+end
+
+describe :rational_divide, :shared => true do
+ it "calls #coerce on the passed argument with self" do
+ rational = Rational(3, 4)
+ obj = mock("Object")
+ obj.should_receive(:coerce).with(rational).and_return([1, 2])
+
+ rational.send(@method, obj)
+ end
+
+ it "calls #/ on the coerced Rational with the coerced Object" do
+ rational = Rational(3, 4)
+
+ coerced_rational = mock("Coerced Rational")
+ coerced_rational.should_receive(:/).and_return(:result)
+
+ coerced_obj = mock("Coerced Object")
+
+ obj = mock("Object")
+ obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
+
+ rational.send(@method, obj).should == :result
+ end
+end
Copied: MacRuby/branches/experimental/spec/frozen/shared/rational/divmod.rb (from rev 1878, MacRuby/branches/experimental/spec/frozen/library/rational/divmod_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/divmod.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/divmod.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,45 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_divmod_rat, :shared => true do
+ it "returns the quotient as Integer and the remainder as Rational" do
+ Rational(7, 4).divmod(Rational(1, 2)).should eql([3, Rational(1, 4)])
+ Rational(7, 4).divmod(Rational(-1, 2)).should eql([-4, Rational(-1, 4)])
+ Rational(0, 4).divmod(Rational(4, 3)).should eql([0, Rational(0, 1)])
+
+ Rational(bignum_value, 4).divmod(Rational(4, 3)).should eql([1729382256910270464, Rational(0, 1)])
+ end
+
+ it "raises a ZeroDivisonError when passed a Rational with a numerator of 0" do
+ lambda { Rational(7, 4).divmod(Rational(0, 3)) }.should raise_error(ZeroDivisionError)
+ end
+end
+
+describe :rational_divmod_int, :shared => true do
+ it "returns the quotient as Integer and the remainder as Rational" do
+ Rational(7, 4).divmod(2).should eql([0, Rational(7, 4)])
+ Rational(7, 4).divmod(-2).should eql([-1, Rational(-1, 4)])
+
+ Rational(bignum_value, 4).divmod(3).should == [768614336404564650, Rational(2, 1)]
+ end
+
+ it "raises a ZeroDivisionError when passed 0" do
+ lambda { Rational(7, 4).divmod(0) }.should raise_error(ZeroDivisionError)
+ end
+end
+
+describe :rational_divmod_float, :shared => true do
+ it "returns the quotient as Integer and the remainder as Float" do
+ Rational(7, 4).divmod(0.5).should eql([3, 0.25])
+ end
+
+ ruby_bug "#", "1.8.6" do # Fixed at MRI 1.8.7
+ it "returns the quotient as Integer and the remainder as Float" do
+ Rational(7, 4).divmod(-0.5).should eql([-4, -0.25])
+ end
+ end
+
+ it "raises a FloatDomainError when passed 0" do
+ lambda { Rational(7, 4).divmod(0.0) }.should raise_error(FloatDomainError)
+ end
+end
Copied: MacRuby/branches/experimental/spec/frozen/shared/rational/equal_value.rb (from rev 1878, MacRuby/branches/experimental/spec/frozen/library/rational/equal_value_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/equal_value.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/equal_value.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,62 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_equal_value_rat, :shared => true do
+ it "returns true if self has the same numerator and denominator as the passed argument" do
+ (Rational(3, 4) == Rational(3, 4)).should be_true
+ (Rational(-3, -4) == Rational(3, 4)).should be_true
+ (Rational(-4, 5) == Rational(4, -5)).should be_true
+
+ (Rational(bignum_value, 3) == Rational(bignum_value, 3)).should be_true
+ (Rational(-bignum_value, 3) == Rational(bignum_value, -3)).should be_true
+ end
+
+ ruby_version_is ""..."1.9" do
+ it "returns false if self has different numerator/denominator but the same numerical value as the passed argument" do
+ (Rational(3, 4) == Rational.new!(6, 8)).should be_false
+ (Rational(-3, 4) == Rational.new!(-6, 8)).should be_false
+ end
+ end
+end
+
+describe :rational_equal_value_int, :shared => true do
+ it "returns true if self has the passed argument as numerator and a denominator of 1" do
+ # Rational(x, y) reduces x and y automatically
+ (Rational(4, 2) == 2).should be_true
+ (Rational(-4, 2) == -2).should be_true
+ (Rational(4, -2) == -2).should be_true
+ end
+
+ ruby_version_is ""..."1.9" do
+ it "returns true if self is constructed with #new! and has the passed argument as numerator and a denominator of 1" do
+ (Rational.new!(4, 2) == 2).should be_false
+ (Rational.new!(9, 3) == 3).should be_false
+ end
+ end
+end
+
+describe :rational_equal_value_float, :shared => true do
+ it "converts self to a Float and compares it with the passed argument" do
+ (Rational(3, 4) == 0.75).should be_true
+ (Rational(4, 2) == 2.0).should be_true
+ (Rational(-4, 2) == -2.0).should be_true
+ (Rational(4, -2) == -2.0).should be_true
+ end
+
+ ruby_version_is ""..."1.9" do
+ it "converts self to Float and compares it with the passed argument when the #new! constructor is used" do
+ # This is inconsistent to behaviour when passed Integers or Rationals
+ (Rational.new!(4, 2) == 2.0).should be_true
+ (Rational.new!(9, 3) == 3.0).should be_true
+ end
+ end
+end
+
+describe :rational_equal_value, :shared => true do
+ it "returns the result of calling #== with self on the passed argument" do
+ obj = mock("Object")
+ obj.should_receive(:==).and_return(:result)
+
+ (Rational(3, 4) == obj).should == :result
+ end
+end
Copied: MacRuby/branches/experimental/spec/frozen/shared/rational/exponent.rb (from rev 1878, MacRuby/branches/experimental/spec/frozen/library/rational/exponent_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/exponent.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/exponent.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,118 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_exponent_rat, :shared => true do
+ conflicts_with :Prime do
+ ruby_version_is ""..."1.9" do
+ it "converts self to a Float and returns it raised to the passed argument" do
+ (Rational(3, 4) ** Rational(4, 3)).should be_close(0.681420222312052, TOLERANCE)
+ (Rational(3, 4) ** Rational(-4, 3)).should be_close(1.46752322173095, TOLERANCE)
+ (Rational(3, 4) ** Rational(4, -3)).should be_close(1.46752322173095, TOLERANCE)
+
+ (Rational(3, 4) ** Rational(0, 3)).should eql(1.0)
+ (Rational(-3, 4) ** Rational(0, 3)).should eql(1.0)
+ (Rational(3, -4) ** Rational(0, 3)).should eql(1.0)
+ (Rational(3, 4) ** Rational(0, -3)).should eql(1.0)
+
+ (Rational(bignum_value, 4) ** Rational(0, 3)).should eql(1.0)
+ (Rational(3, -bignum_value) ** Rational(0, 3)).should eql(1.0)
+ (Rational(3, 4) ** Rational(0, bignum_value)).should eql(1.0)
+ (Rational(3, 4) ** Rational(0, -bignum_value)).should eql(1.0)
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "returns self raised to the argument as a Rational if possible" do
+
+ (Rational(3, 4) ** Rational(0, 3)).should == Rational(1, 1)
+ (Rational(-3, 4) ** Rational(0, 3)).should == Rational(1, 1)
+ (Rational(3, -4) ** Rational(0, 3)).should == Rational(1, 1)
+ (Rational(3, 4) ** Rational(0, -3)).should == Rational(1, 1)
+
+ (Rational(bignum_value, 4) ** Rational(0, 3)).should == Rational(1, 1)
+ (Rational(3, -bignum_value) ** Rational(0, 3)).should == Rational(1, 1)
+ (Rational(3, 4) ** Rational(0, bignum_value)).should == Rational(1, 1)
+ (Rational(3, 4) ** Rational(0, -bignum_value)).should == Rational(1, 1)
+ end
+
+ it "returns self raised to the argument as a Float if necessary" do
+ (Rational(3, 4) ** Rational(4, 3)).should be_close(0.681420222312052, TOLERANCE)
+ (Rational(3, 4) ** Rational(-4, 3)).should be_close(1.46752322173095, TOLERANCE)
+ (Rational(3, 4) ** Rational(4, -3)).should be_close(1.46752322173095, TOLERANCE)
+ end
+ end
+
+ it "returns NaN when self is negative and the passed argument is not 0" do
+ (Rational(-3, 4) ** Rational(-4, 3)).nan?.should be_true
+ end
+ end
+end
+
+describe :rational_exponent_int, :shared => true do
+ it "returns the Rational value of self raised to the passed argument" do
+ (Rational(3, 4) ** 4).should == Rational(81, 256)
+ (Rational(3, 4) ** -4).should == Rational(256, 81)
+ (Rational(-3, 4) ** -4).should == Rational(256, 81)
+ (Rational(3, -4) ** -4).should == Rational(256, 81)
+
+ (Rational(bignum_value, 4) ** 4).should == Rational(28269553036454149273332760011886696253239742350009903329945699220681916416, 1)
+ (Rational(3, bignum_value) ** -4).should == Rational(7237005577332262213973186563042994240829374041602535252466099000494570602496, 81)
+ (Rational(-bignum_value, 4) ** -4).should == Rational(1, 28269553036454149273332760011886696253239742350009903329945699220681916416)
+ (Rational(3, -bignum_value) ** -4).should == Rational(7237005577332262213973186563042994240829374041602535252466099000494570602496, 81)
+ end
+
+ conflicts_with :Prime do
+ it "returns Rational(1, 1) when the passed argument is 0" do
+ (Rational(3, 4) ** 0).should eql(Rational(1, 1))
+ (Rational(-3, 4) ** 0).should eql(Rational(1, 1))
+ (Rational(3, -4) ** 0).should eql(Rational(1, 1))
+
+ (Rational(bignum_value, 4) ** 0).should eql(Rational(1, 1))
+ (Rational(3, -bignum_value) ** 0).should eql(Rational(1, 1))
+ end
+ end
+end
+
+describe :rational_exponent_float, :shared => true do
+ it "returns self converted to Float and raised to the passed argument" do
+ (Rational(3, 1) ** 3.0).should eql(27.0)
+ (Rational(3, 1) ** 1.5).should be_close(5.19615242270663, TOLERANCE)
+ (Rational(3, 1) ** -1.5).should be_close(0.192450089729875, TOLERANCE)
+ end
+
+ it "returns 1.0 when the passed argument is 0" do
+ (Rational(3, 4) ** 0.0).should eql(1.0)
+ (Rational(-3, 4) ** 0.0).should eql(1.0)
+ (Rational(-3, 4) ** 0.0).should eql(1.0)
+ end
+
+ it "returns NaN if self is negative and the passed argument is not 0" do
+ (Rational(-3, 2) ** 1.5).nan?.should be_true
+ (Rational(3, -2) ** 1.5).nan?.should be_true
+ (Rational(3, -2) ** -1.5).nan?.should be_true
+ end
+end
+
+describe :rational_exponent, :shared => true do
+ it "calls #coerce on the passed argument with self" do
+ rational = Rational(3, 4)
+ obj = mock("Object")
+ obj.should_receive(:coerce).with(rational).and_return([1, 2])
+
+ rational ** obj
+ end
+
+ it "calls #** on the coerced Rational with the coerced Object" do
+ rational = Rational(3, 4)
+
+ coerced_rational = mock("Coerced Rational")
+ coerced_rational.should_receive(:**).and_return(:result)
+
+ coerced_obj = mock("Coerced Object")
+
+ obj = mock("Object")
+ obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
+
+ (rational ** obj).should == :result
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/fdiv.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/fdiv.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/fdiv.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,5 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe :rational_fdiv, :shared => true do
+ it "needs to be reviewed for spec completeness"
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/floor.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/floor.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/floor.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,5 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe :rational_floor, :shared => true do
+ it "needs to be reviewed for spec completeness"
+end
Copied: MacRuby/branches/experimental/spec/frozen/shared/rational/hash.rb (from rev 1878, MacRuby/branches/experimental/spec/frozen/library/rational/hash_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/hash.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/hash.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_hash, :shared => true do
+ # BUG: Rational(2, 3).hash == Rational(3, 2).hash
+ it "is static" do
+ Rational(2, 3).hash.should == Rational(2, 3).hash
+ Rational(2, 4).hash.should_not == Rational(2, 3).hash
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/initialize.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/initialize.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/initialize.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,25 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_initialize, :shared => true do
+ # Rational#initialize doesn't accept any arguments on 1.9, nor do we
+ # normally specify private methods. Plus, #allocate has been removed in 1.9.
+ ruby_version_is ""..."1.9" do
+ before(:each) do
+ @rational = Rational.allocate
+ end
+
+ it "turns around the numerators and denominators signs around when the denominator is negative" do
+ @rational.send(:initialize, 1, -2)
+ @rational.numerator.should == -1
+ @rational.denominator.should == 2
+ end
+
+ # I think this should work (at least Rational#initialize seems to be intended for this)
+ # it "tries to convert the passed numerator and denominator to Integers using #to_i" do
+ # @rational.send(:initialize, "1", "2")
+ # @rational.numerator.should == "1"
+ # @rational.denominator.should == "2"
+ # end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/inspect.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/inspect.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/inspect.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,24 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_inspect, :shared => true do
+ conflicts_with :Prime do
+ ruby_version_is ""..."1.9" do
+ it "returns a reconstructable string representation of self" do
+ Rational(3, 4).inspect.should == "Rational(3, 4)"
+ Rational(-5, 8).inspect.should == "Rational(-5, 8)"
+ Rational(-1, -2).inspect.should == "Rational(1, 2)"
+ Rational(bignum_value, 1).inspect.should == "Rational(#{bignum_value}, 1)"
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "returns a string representation of self" do
+ Rational(3, 4).inspect.should == "(3/4)"
+ Rational(-5, 8).inspect.should == "(-5/8)"
+ Rational(-1, -2).inspect.should == "(1/2)"
+ Rational(bignum_value, 1).inspect.should == "(#{bignum_value}/1)"
+ end
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/marshal_dump.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/marshal_dump.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/marshal_dump.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,5 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe :rational_marshal_dump, :shared => true do
+ it "needs to be reviewed for spec completeness"
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/marshal_load.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/marshal_load.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/marshal_load.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,5 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe :rational_marshal_load, :shared => true do
+ it "needs to be reviewed for spec completeness"
+end
Copied: MacRuby/branches/experimental/spec/frozen/shared/rational/minus.rb (from rev 1878, MacRuby/branches/experimental/spec/frozen/library/rational/minus_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/minus.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/minus.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,49 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_minus_rat, :shared => true do
+ it "returns the result of substracting other from self as a Rational" do
+ (Rational(3, 4) - Rational(0, 1)).should eql(Rational(3, 4))
+ (Rational(3, 4) - Rational(1, 4)).should eql(Rational(1, 2))
+
+ (Rational(3, 4) - Rational(2, 1)).should eql(Rational(-5, 4))
+ end
+end
+
+describe :rational_minus_int, :shared => true do
+ it "returns the result of substracting other from self as a Rational" do
+ (Rational(3, 4) - 1).should eql(Rational(-1, 4))
+ (Rational(3, 4) - 2).should eql(Rational(-5, 4))
+ end
+end
+
+describe :rational_minus_float, :shared => true do
+ it "returns the result of substracting other from self as a Float" do
+ (Rational(3, 4) - 0.2).should eql(0.55)
+ (Rational(3, 4) - 2.5).should eql(-1.75)
+ end
+end
+
+describe :rational_minus, :shared => true do
+ it "calls #coerce on the passed argument with self" do
+ rational = Rational(3, 4)
+ obj = mock("Object")
+ obj.should_receive(:coerce).with(rational).and_return([1, 2])
+
+ rational - obj
+ end
+
+ it "calls #- on the coerced Rational with the coerced Object" do
+ rational = Rational(3, 4)
+
+ coerced_rational = mock("Coerced Rational")
+ coerced_rational.should_receive(:-).and_return(:result)
+
+ coerced_obj = mock("Coerced Object")
+
+ obj = mock("Object")
+ obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
+
+ (rational - obj).should == :result
+ end
+end
Copied: MacRuby/branches/experimental/spec/frozen/shared/rational/modulo.rb (from rev 1878, MacRuby/branches/experimental/spec/frozen/library/rational/modulo_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/modulo.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/modulo.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,34 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_modulo, :shared => true do
+ it "returns the remainder when this value is divided by other" do
+ (Rational(2, 3) % Rational(2, 3)).should == Rational(0, 1)
+ (Rational(4, 3) % Rational(2, 3)).should == Rational(0, 1)
+ (Rational(2, -3) % Rational(-2, 3)).should == Rational(0, 1)
+ (Rational(0, -1) % -1).should == Rational(0, 1)
+
+ (Rational(7, 4) % Rational(1, 2)).should == Rational(1, 4)
+ (Rational(7, 4) % 1).should == Rational(3, 4)
+ (Rational(7, 4) % Rational(1, 7)).should == Rational(1, 28)
+
+ (Rational(3, 4) % -1).should == Rational(-1, 4)
+ (Rational(1, -5) % -1).should == Rational(-1, 5)
+ end
+
+ it "returns a Float value when the argument is Float" do
+ (Rational(7, 4) % 1.0).should be_kind_of(Float)
+ (Rational(7, 4) % 1.0).should == 0.75
+ (Rational(7, 4) % 0.26).should be_close(0.19, 0.0001)
+ end
+
+ it "raises ZeroDivisionError on zero denominator" do
+ lambda { Rational(3, 5) % Rational(0, 1) }.should raise_error(ZeroDivisionError)
+ lambda { Rational(0, 1) % Rational(0, 1) }.should raise_error(ZeroDivisionError)
+ lambda { Rational(3, 5) % 0 }.should raise_error(ZeroDivisionError)
+ end
+
+ it "raises FloatDomainError when the argument is 0.0" do
+ lambda { Rational(3, 5) % 0.0 }.should raise_error(FloatDomainError)
+ end
+end
Copied: MacRuby/branches/experimental/spec/frozen/shared/rational/multiply.rb (from rev 1878, MacRuby/branches/experimental/spec/frozen/library/rational/multiply_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/multiply.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/multiply.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,63 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_multiply_rat, :shared => true do
+ it "returns self divided by other as a Rational" do
+ (Rational(3, 4) * Rational(3, 4)).should eql(Rational(9, 16))
+ (Rational(2, 4) * Rational(1, 4)).should eql(Rational(1, 8))
+
+ (Rational(3, 4) * Rational(0, 1)).should eql(Rational(0, 4))
+ end
+end
+
+describe :rational_multiply_int, :shared => true do
+ it "returns self divided by other as a Rational" do
+ (Rational(3, 4) * 2).should eql(Rational(3, 2))
+ (Rational(2, 4) * 2).should eql(Rational(1, 1))
+ (Rational(6, 7) * -2).should eql(Rational(-12, 7))
+
+ (Rational(3, 4) * 0).should eql(Rational(0, 4))
+ end
+end
+
+describe :rational_multiply_float, :shared => true do
+ it "returns self divided by other as a Float" do
+ (Rational(3, 4) * 0.75).should eql(0.5625)
+ (Rational(3, 4) * 0.25).should eql(0.1875)
+ (Rational(3, 4) * 0.3).should be_close(0.225, TOLERANCE)
+
+ (Rational(-3, 4) * 0.3).should be_close(-0.225, TOLERANCE)
+ (Rational(3, -4) * 0.3).should be_close(-0.225, TOLERANCE)
+ (Rational(3, 4) * -0.3).should be_close(-0.225, TOLERANCE)
+
+ (Rational(3, 4) * 0.0).should eql(0.0)
+ (Rational(-3, -4) * 0.0).should eql(0.0)
+
+ (Rational(-3, 4) * 0.0).should eql(0.0)
+ (Rational(3, -4) * 0.0).should eql(0.0)
+ end
+end
+
+describe :rational_multiply, :shared => true do
+ it "calls #coerce on the passed argument with self" do
+ rational = Rational(3, 4)
+ obj = mock("Object")
+ obj.should_receive(:coerce).with(rational).and_return([1, 2])
+
+ rational * obj
+ end
+
+ it "calls #* on the coerced Rational with the coerced Object" do
+ rational = Rational(3, 4)
+
+ coerced_rational = mock("Coerced Rational")
+ coerced_rational.should_receive(:*).and_return(:result)
+
+ coerced_obj = mock("Coerced Object")
+
+ obj = mock("Object")
+ obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
+
+ (rational * obj).should == :result
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/new.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/new.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/new.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,21 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_new, :shared => true do
+ it "is private" do
+ Rational.private_methods.should include("new")
+ end
+end
+
+describe :rational_new_bang, :shared => true do
+ it "returns a Rational with the passed numerator and denominator not reduced to their lowest terms" do
+ Rational.new!(2, 4).should_not eql(Rational(1, 4))
+ Rational.new!(6, 8).should_not eql(Rational(3, 4))
+ Rational.new!(-5, 10).should_not eql(Rational(-1, 2))
+ end
+
+ it "does not check for divisions by 0" do
+ lambda { Rational.new!(4, 0) }.should_not raise_error(ZeroDivisionError)
+ lambda { Rational.new!(0, 0) }.should_not raise_error(ZeroDivisionError)
+ end
+end
Copied: MacRuby/branches/experimental/spec/frozen/shared/rational/numerator.rb (from rev 1878, MacRuby/branches/experimental/spec/frozen/library/rational/numerator_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/numerator.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/numerator.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,11 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_numerator, :shared => true do
+ it "returns the numerator" do
+ Rational(3, 4).numerator.should equal(3)
+ Rational(3, -4).numerator.should equal(-3)
+
+ Rational(bignum_value, 1).numerator.should == bignum_value
+ end
+end
Copied: MacRuby/branches/experimental/spec/frozen/shared/rational/plus.rb (from rev 1878, MacRuby/branches/experimental/spec/frozen/library/rational/plus_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/plus.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/plus.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,49 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_plus_rat, :shared => true do
+ it "returns the result of substracting other from self as a Rational" do
+ (Rational(3, 4) + Rational(0, 1)).should eql(Rational(3, 4))
+ (Rational(3, 4) + Rational(1, 4)).should eql(Rational(1, 1))
+
+ (Rational(3, 4) + Rational(2, 1)).should eql(Rational(11, 4))
+ end
+end
+
+describe :rational_plus_int, :shared => true do
+ it "returns the result of substracting other from self as a Rational" do
+ (Rational(3, 4) + 1).should eql(Rational(7, 4))
+ (Rational(3, 4) + 2).should eql(Rational(11, 4))
+ end
+end
+
+describe :rational_plus_float, :shared => true do
+ it "returns the result of substracting other from self as a Float" do
+ (Rational(3, 4) + 0.2).should eql(0.95)
+ (Rational(3, 4) + 2.5).should eql(3.25)
+ end
+end
+
+describe :rational_plus, :shared => true do
+ it "calls #coerce on the passed argument with self" do
+ rational = Rational(3, 4)
+ obj = mock("Object")
+ obj.should_receive(:coerce).with(rational).and_return([1, 2])
+
+ rational + obj
+ end
+
+ it "calls #+ on the coerced Rational with the coerced Object" do
+ rational = Rational(3, 4)
+
+ coerced_rational = mock("Coerced Rational")
+ coerced_rational.should_receive(:+).and_return(:result)
+
+ coerced_obj = mock("Coerced Object")
+
+ obj = mock("Object")
+ obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
+
+ (rational + obj).should == :result
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/quo.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/quo.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/quo.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,5 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe :rational_quo, :shared => true do
+ it "needs to be reviewed for spec completeness"
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/reduce.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/reduce.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/reduce.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,31 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_reduce_unfiy, :shared => true do
+ # This is not consistent with the Complex library, Complex checks
+ # Complex::Unify and not the top-level Unify.
+ it "returns an Integer when the reduced denominator is 1" do
+ begin
+ Unify = true
+
+ Rational.reduce(3, 1).should eql(3)
+ Rational.reduce(5, 1).should eql(5)
+ Rational.reduce(4, 2).should eql(2)
+ Rational.reduce(-9, 3).should eql(-3)
+ ensure
+ Object.send :remove_const, :Unify
+ end
+ end
+end
+
+describe :rational_reduce, :shared => true do
+ it "returns a new Rational with the passed numerator and denominator reduced to their lowest terms" do
+ Rational(6, 8).should eql(Rational(3, 4))
+ Rational(-5, 10).should eql(Rational(-1, 2))
+ end
+
+ it "raises a ZeroDivisionError when the passed denominator is 0" do
+ lambda { Rational.reduce(4, 0) }.should raise_error(ZeroDivisionError)
+ lambda { Rational.reduce(-1, 0) }.should raise_error(ZeroDivisionError)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/remainder.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/remainder.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/remainder.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,5 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe :rational_remainder, :shared => true do
+ it "needs to be reviewed for spec completeness"
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/round.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/round.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/round.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,5 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe :rational_round, :shared => true do
+ it "needs to be reviewed for spec completeness"
+end
Copied: MacRuby/branches/experimental/spec/frozen/shared/rational/to_f.rb (from rev 1878, MacRuby/branches/experimental/spec/frozen/library/rational/to_f_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/to_f.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/to_f.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,11 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_to_f, :shared => true do
+ it "returns self converted to a Float" do
+ Rational(3, 4).to_f.should eql(0.75)
+ Rational(3, -4).to_f.should eql(-0.75)
+ Rational(-1, 4).to_f.should eql(-0.25)
+ Rational(-1, -4).to_f.should eql(0.25)
+ end
+end
Copied: MacRuby/branches/experimental/spec/frozen/shared/rational/to_i.rb (from rev 1878, MacRuby/branches/experimental/spec/frozen/library/rational/to_i_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/to_i.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/to_i.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,15 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_to_i, :shared => true do
+ it "converts self to an Integer by truncation" do
+ Rational(7, 4).to_i.should eql(1)
+ Rational(11, 4).to_i.should eql(2)
+ end
+
+ ruby_bug "#", "1.8.6" do
+ it "converts self to an Integer by truncation" do
+ Rational(-7, 4).to_i.should eql(-1)
+ end
+ end
+end
Copied: MacRuby/branches/experimental/spec/frozen/shared/rational/to_r.rb (from rev 1878, MacRuby/branches/experimental/spec/frozen/library/rational/to_r_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/to_r.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/to_r.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_to_r, :shared => true do
+ conflicts_with :Prime do
+ it "returns self" do
+ a = Rational(3, 4)
+ a.to_r.should equal(a)
+
+ a = Rational(bignum_value, 4)
+ a.to_r.should equal(a)
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/to_s.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/to_s.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/to_s.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,24 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe :rational_to_s, :shared => true do
+ ruby_version_is ""..."1.9" do
+ it "returns a string representation of self" do
+ Rational(1, 1).to_s.should == "1"
+ Rational(2, 1).to_s.should == "2"
+ Rational(1, 2).to_s.should == "1/2"
+ Rational(-1, 3).to_s.should == "-1/3"
+ Rational(1, -3).to_s.should == "-1/3"
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "returns a string representation of self" do
+ Rational(1, 1).to_s.should == "1/1"
+ Rational(2, 1).to_s.should == "2/1"
+ Rational(1, 2).to_s.should == "1/2"
+ Rational(-1, 3).to_s.should == "-1/3"
+ Rational(1, -3).to_s.should == "-1/3"
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/rational/truncate.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/rational/truncate.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/rational/truncate.rb 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1,5 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe :rational_truncate, :shared => true do
+ it "needs to be reviewed for spec completeness"
+end
Added: MacRuby/branches/experimental/spec/frozen/tags/1.8/library/rational/div_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.8/library/rational/div_tags.txt (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.8/library/rational/div_tags.txt 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1 @@
+fails(bug #1648):Rational#div raises a TypeError if passed a non-numeric argument
Added: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/fiber/resume_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/fiber/resume_tags.txt (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/fiber/resume_tags.txt 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1 @@
+fails(#595):Fiber#resume executes the ensure clause
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/Rational_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/Rational_tags.txt 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/Rational_tags.txt 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,3 +0,0 @@
-fails:Rational when passed Integer, Integer returns a new Rational number
-fails:Rational when passed Integer, Integer automatically reduces the Rational
-fails:Rational when passed Integer returns a new Rational number with 1 as the denominator
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/coerce_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/coerce_tags.txt 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/coerce_tags.txt 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,2 +0,0 @@
-fails:Rational#coerce does try to convert the passed argument into a Float (using #to_f)
-fails:Rational#coerce returns the passed argument, self converted to Floats
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/divmod_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/divmod_tags.txt 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/divmod_tags.txt 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1 +0,0 @@
-fails:Rational#divmod when passed [Rational] returns the quotient as Integer and the remainder as Rational
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/equal_value_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/equal_value_tags.txt 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/equal_value_tags.txt 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,3 +0,0 @@
-fails:Rational#== when passed [Rational] returns false if self has different numerator/denominator but the same numerical value as the passed argument
-fails:Rational#== when passed [Integer] returns true if self has the passed argument as numerator and a denominator of 1
-fails:Rational#== when passed [Float] converts self to a Float and compares it with the passed argument
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/exponent_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/exponent_tags.txt 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/exponent_tags.txt 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,5 +0,0 @@
-fails:Rational#** when passed [Rational] converts self to a Float and returns it raised to the passed argument
-fails:Rational#** when passed [Rational] returns NaN when self is negative and the passed argument is not 0
-fails:Rational#** when passed [Integer] returns the Rational value of self raised to the passed argument
-fails:Rational#** when passed [Integer] returns Rational(1, 1) when the passed argument is 0
-fails:Rational#** when passed [Float] returns NaN if self is negative and the passed argument is not 0
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/initialize_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/initialize_tags.txt 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/initialize_tags.txt 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1 +0,0 @@
-fails:Rational#initialize turns around the numerators and denominators signs around when the denominator is negative
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/inspect_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/inspect_tags.txt 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/inspect_tags.txt 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1 +0,0 @@
-fails:Rational#inspect returns a reconstructable string representation of self
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/new_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/new_tags.txt 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/new_tags.txt 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,2 +0,0 @@
-fails:Rational.new is private
-fails:Rational.new! returns a Rational with the passed numerator and denominator not reduced to their lowest terms
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/reduce_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/reduce_tags.txt 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/reduce_tags.txt 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1,2 +0,0 @@
-fails:Rational.reduce when Unify is defined returns an Integer when the reduced denominator is 1
-fails:Rational.reduce raises a ZeroDivisionError when the passed denominator is 0
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/to_r_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/to_r_tags.txt 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/library/rational/to_r_tags.txt 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1 +0,0 @@
-fails:Rational#to_r returns self
Added: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/objectspace/define_finalizer_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/objectspace/define_finalizer_tags.txt (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/objectspace/define_finalizer_tags.txt 2009-06-18 20:38:24 UTC (rev 1879)
@@ -0,0 +1 @@
+critical:ObjectSpace.define_finalizer calls finalizer on process termination
Modified: MacRuby/branches/experimental/spec/frozen/upstream
===================================================================
--- MacRuby/branches/experimental/spec/frozen/upstream 2009-06-18 20:18:30 UTC (rev 1878)
+++ MacRuby/branches/experimental/spec/frozen/upstream 2009-06-18 20:38:24 UTC (rev 1879)
@@ -1 +1 @@
-9c5b3ddd2703ce570abad92592764361e065703f
\ No newline at end of file
+7072d6def04d6fd23244839986e234da76d9a5a0
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090618/5b6ecb2e/attachment-0001.html>
More information about the macruby-changes
mailing list