[macruby-changes] [1646] MacRuby/branches/experimental/spec/frozen

source_changes at macosforge.org source_changes at macosforge.org
Sat May 30 08:29:54 PDT 2009


Revision: 1646
          http://trac.macosforge.org/projects/ruby/changeset/1646
Author:   eloy.de.enige at gmail.com
Date:     2009-05-30 08:29:52 -0700 (Sat, 30 May 2009)
Log Message:
-----------
Updated RubySpec to upstream ba2b6ee4825a4950f50c43e9da424431ceb7db54. Muchos changos

Modified Paths:
--------------
    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/array/delete_if_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/array/each_index_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/array/each_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/array/eql_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/array/equal_value_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/array/fixtures/classes.rb
    MacRuby/branches/experimental/spec/frozen/core/array/flatten_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/array/index_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/array/initialize_copy_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/array/initialize_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/array/intersection_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/array/reject_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/array/reverse_each_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/array/rindex_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/array/sample_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/array/shared/collect.rb
    MacRuby/branches/experimental/spec/frozen/core/array/shift_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/array/sort_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/dir/each_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/dir/fixtures/common.rb
    MacRuby/branches/experimental/spec/frozen/core/dir/foreach_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/dir/shared/delete.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/collect_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/each_with_index_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/fixtures/classes.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/inject_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/partition_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/reject_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/collect.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/entries.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/find.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/find_all.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/sort_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/zip_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/env/delete_if_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/env/each_key_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/env/each_value_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/env/reject_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/env/select_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/env/shared/each.rb
    MacRuby/branches/experimental/spec/frozen/core/exception/fixtures/common.rb
    MacRuby/branches/experimental/spec/frozen/core/exception/to_s_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/exception/to_str_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/file/stat/comparison_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/file/symlink_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/filetest/symlink_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/float/to_s_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/allocate_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/clear_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/clone_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/constructor_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/default_proc_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/default_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/delete_if_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/delete_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/each_key_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/each_pair_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/each_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/each_value_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/element_reference_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/empty_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/equal_value_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/fetch_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/fixtures/classes.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/hash_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/index_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/initialize_copy_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/initialize_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/inspect_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/invert_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/key_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/keys_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/merge_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/new_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/rehash_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/reject_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/select_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/shared/iteration.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/shared/key.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/shared/length.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/shared/replace.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/shared/store.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/shared/update.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/shared/value.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/shift_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/sort_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/to_a_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/to_hash_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/to_s_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/update_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/values_at_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/values_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/io/each_byte_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/io/fixtures/classes.rb
    MacRuby/branches/experimental/spec/frozen/core/io/getc_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/io/gets_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/io/read_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/io/shared/each.rb
    MacRuby/branches/experimental/spec/frozen/core/io/sysread_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/io/ungetc_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/loop_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/methods_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/open_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/protected_methods_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/singleton_methods_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/to_a_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/marshal/dump_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/method/arity_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/method/fixtures/classes.rb
    MacRuby/branches/experimental/spec/frozen/core/method/shared/call.rb
    MacRuby/branches/experimental/spec/frozen/core/method/shared/to_s.rb
    MacRuby/branches/experimental/spec/frozen/core/module/define_method_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/module/extended_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/module/included_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/module/instance_methods_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/module/public_instance_methods_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/numeric/step_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/objectspace/each_object_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/process/egid_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/process/kill_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/range/each_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/range/initialize_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/range/shared/equal_value.rb
    MacRuby/branches/experimental/spec/frozen/core/range/step_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/regexp/union_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/each_byte_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/each_char_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/each_line_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/each_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/fixtures/classes.rb
    MacRuby/branches/experimental/spec/frozen/core/string/gsub_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/initialize_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/split_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/sub_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/upto_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/struct/each_pair_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/struct/each_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/struct/fixtures/classes.rb
    MacRuby/branches/experimental/spec/frozen/core/struct/initialize_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/symbol/all_symbols_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/symbol/to_i_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/symbol/to_int_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/time/initialize_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/time/now_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/time/plus_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/time/times_spec.rb
    MacRuby/branches/experimental/spec/frozen/language/predefined_spec.rb
    MacRuby/branches/experimental/spec/frozen/language/return_spec.rb
    MacRuby/branches/experimental/spec/frozen/language/super_spec.rb
    MacRuby/branches/experimental/spec/frozen/language/symbol_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/bigdecimal/precs_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/enumerator/enum_cons_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/enumerator/enum_slice_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/enumerator/enum_with_index_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/enumerator/new_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/enumerator/shared/enum_for.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/column_size_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/column_vector_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/column_vectors_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/columns_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/compare_by_row_vectors_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/det_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/determinant_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/element_reference_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/eql_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/equal_value_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/exponent_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/hash_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/inspect_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/inv_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/inverse_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/minor_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/rank_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/regular_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/row_vector_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/row_vectors_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/shared/transpose.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/square_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/each_capitalized_name_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/each_value_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/shared/each_capitalized.rb
    MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/shared/each_header.rb
    MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/shared/each_name.rb
    MacRuby/branches/experimental/spec/frozen/library/observer/count_observers_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/queue/num_waiting_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/rexml/attributes/prefixes_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/securerandom/base64_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/set/classify_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/set/delete_if_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/set/flatten_merge_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/set/reject_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/set/sortedset/add_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/set/sortedset/classify_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/set/sortedset/delete_if_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/set/sortedset/flatten_merge_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/set/sortedset/reject_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/stringio/puts_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each.rb
    MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each_byte.rb
    MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each_char.rb
    MacRuby/branches/experimental/spec/frozen/ruby.1.8.mspec
    MacRuby/branches/experimental/spec/frozen/ruby.1.9.mspec
    MacRuby/branches/experimental/spec/frozen/shared/file/symlink.rb
    MacRuby/branches/experimental/spec/frozen/upstream

Added Paths:
-----------
    MacRuby/branches/experimental/spec/frozen/README.markdown
    MacRuby/branches/experimental/spec/frozen/core/array/combination.rb
    MacRuby/branches/experimental/spec/frozen/core/array/cycle.rb
    MacRuby/branches/experimental/spec/frozen/core/array/key_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/array/product.rb
    MacRuby/branches/experimental/spec/frozen/core/array/shared/eql.rb
    MacRuby/branches/experimental/spec/frozen/core/array/shared/index.rb
    MacRuby/branches/experimental/spec/frozen/core/array/shuffle_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/array/try_convert_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/binding/eval_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/count_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/cycle_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/drop_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/drop_while_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/each_cons_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/each_slice_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/each_with_object_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/find_index.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/first_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/group_by_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/max_by_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/min_by_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/minmax_by_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/minmax_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/reduce_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/reverse_each_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/inject.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/take.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/take_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/enumerable/take_while_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/exception/shared/to_s.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/eql_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/shared/eql.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/shared/equal.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/shared/index.rb
    MacRuby/branches/experimental/spec/frozen/core/hash/shared/to_s.rb
    MacRuby/branches/experimental/spec/frozen/core/integer/constructor_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/io/bytes_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/io/chars_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/io/each_char_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/io/getbyte_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/io/lines_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/__callee__spec.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/__method__spec.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/define_singleton_method.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/shared/__method__.rb
    MacRuby/branches/experimental/spec/frozen/core/kernel/tap_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/method/name_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/method/owner_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/method/receiver_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/ascii_only_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/bytesize_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/end_with_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/partition_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/rpartition_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/shared/each_line.rb
    MacRuby/branches/experimental/spec/frozen/core/string/start_with_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/string/try_convert_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/time/shared/now.rb
    MacRuby/branches/experimental/spec/frozen/core/unboundmethod/name_spec.rb
    MacRuby/branches/experimental/spec/frozen/core/unboundmethod/owner_spec.rb
    MacRuby/branches/experimental/spec/frozen/language/fixtures/return.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/shared/determinant.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/shared/equal_value.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/shared/inverse.rb
    MacRuby/branches/experimental/spec/frozen/library/stringio/readpartial_spec.rb

Removed Paths:
-------------
    MacRuby/branches/experimental/spec/frozen/core/string/shared/each.rb
    MacRuby/branches/experimental/spec/frozen/library/enumerator/each_cons_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/enumerator/each_slice_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/Fail_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/Raise_spec.rb
    MacRuby/branches/experimental/spec/frozen/library/matrix/included_spec.rb

Added: MacRuby/branches/experimental/spec/frozen/README.markdown
===================================================================
--- MacRuby/branches/experimental/spec/frozen/README.markdown	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/README.markdown	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,62 @@
+# About RubySpec
+
+RubySpec is a project to write a complete, executable specification for the Ruby programming language. The goal is official recognition and support from all the organizations currently involved in Ruby implementations, such as MatzRuby (including YARV), JRuby, IronRuby, MacRuby, Ruby.NET and MagLev. The specs describe Ruby language syntax, core library classes, and standard library classes.
+
+This project has a free-flowing commit bit policy. If you have had a patch accepted by any current Ruby implementation project, you can get a commit bit by referencing your patch. Anyone who submits an accepted patch to this project will also receive a commit bit. The only requirement is that you have a Github account.
+
+  - [RubySpec website](http://rubyspec.org/)
+  - [RubySpec Wiki with documentation](http://rubyspec.org/wiki/rubyspec)
+  - [Github repository](http://github.com/rubyspec/rubyspec)
+
+## Running RubySpec
+
+The RubySpec specification files are written in Ruby, utilizing the [MSpec](http://github.com/rubyspec/mspec/tree/master) testing framework, so you need to download MSpec in order to run the RubySpec suite. If you don't have MSpec yet, then go to a directory outside the RubySpec directory and check out its source code from Github:
+
+    $ cd /somewhere
+    $ git clone git://github.com/rubyspec/mspec.git
+    # MSpec is now available in /somewhere/mspec.
+
+You should add the MSpec `bin` directory to your PATH for easy access. In this README we'll assume that the `mspec` command is in PATH.
+
+    $ export PATH=/somewhere/mspec/bin:$PATH
+
+If you already have MSpec, then you should run `git pull` from the MSpec source directory from time to time, because RubySpec often utilizes the latest MSpec features.
+
+By invoking the `mspec` command inside the RubySpec directory, it will run the entire RubySpec suite against the Ruby interpreter (named `ruby`) in your PATH:
+
+    $ cd /path-to-rubyspec
+    $ mspec
+
+### Running RubySpec against a specific Ruby interpreter
+
+Use the `-t` option to specify the Ruby interpreter that you want to run RubySpec against. The argument may be a full path to the Ruby binary:
+
+    # Runs RubySpec against /opt/ruby-enterprise/bin/ruby
+    $ mspec -t /opt/ruby-enterprise/bin/ruby
+
+The argument may also be a shortcut. For example, if you specify `j`, then MSpec will look for `jruby` in PATH and run RubySpec against that:
+
+    # Runs RubySpec against JRuby in PATH.
+    $ mspec -t j
+
+See `mspec --help` for a list of possible `-t` shortcut values.
+
+### Running parts of the spec
+
+To run a single spec file, pass the filename to MSpec, for example:
+
+    $ mspec core/kernel/kind_of_spec.rb
+
+You can also pass a directory, in which case all specs in that directories will be run:
+
+    $ mspec core/kernel
+
+Note however that passing a directory to MSpec may not always be a good idea, because some specs aren't supposed to be run against the active Ruby interpreter. For example, if you run `mspec -t /usr/bin/ruby1.8 library`, then MSpec will run the 1.9-specific library specs as well, even though you specified Ruby 1.8 as the Ruby interpreter. Instead, you can specify pseudo-directories, which are defined in ruby.1.8.mspec and ruby.1.9.mspec. These pseudo-directories only include files appropriate for the active Ruby interpreter.
+
+    $ mspec :core
+    $ mspec :library
+    $ mspec :language
+
+## More
+
+For more documentation, e.g. with regard to writing specs, please visit the [Wiki](http://rubyspec.org/wiki/rubyspec).
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_byte.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_byte.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_byte.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -35,10 +35,10 @@
   end
 
   ruby_version_is "1.8.7" do
-    it "returns an Enumerable::Enumerator when passed no block" do
+    it "returns an Enumerator when passed no block" do
       argv [@file1_name, @file2_name] do
         enum = ARGF.send(@method)
-        enum.should be_an_instance_of(Enumerable::Enumerator)
+        enum.should be_an_instance_of(enumerator_class)
 
         bytes = []
         enum.each { |b| bytes << b }

Modified: MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_char.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_char.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_char.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -26,10 +26,10 @@
     end
   end
 
-  it "returns an Enumerable::Enumerator when passed no block" do
+  it "returns an Enumerator when passed no block" do
     argv [@file1_name, @file2_name] do
       enum = ARGF.send(@method)
-      enum.should be_an_instance_of(Enumerable::Enumerator)
+      enum.should be_an_instance_of(enumerator_class)
 
       chars = []
       enum.each { |c| chars << c }

Added: MacRuby/branches/experimental/spec/frozen/core/array/combination.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/combination.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/array/combination.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,30 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe "Array#combination" do
+  ruby_version_is "1.8.7" do
+    it "returns an enumerator when no block is provided" do
+      [1, 2, 3, 4].combination(2).should be_kind_of(enumerator_class)
+    end
+
+    it "returns self when a block is given" do
+      a = [1, 2, 3, 4]
+      a.combination(2){}.should equal(a)
+    end
+
+    it "yields nothing for out of bounds length and return self" do
+      a = [1, 2, 3, 4]
+      a.combination(5).to_a.should == []
+      a.combination(-1).to_a.should == []
+    end
+
+    it "yields the excepted combinations" do
+      a = [1, 2, 3, 4]
+      a.combination(3).to_a.sort.should == [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
+    end
+
+    if "yields [] when length is 0"
+      [1,2,3].combination(0).to_a.should == [[]] # one combination of length 0
+      [].combination(0).to_a.should == [[]] # one combination of length 0
+    end
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/core/array/cycle.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/cycle.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/array/cycle.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,21 @@
+describe "Enumerable#cycle" do
+  ruby_version_is '1.8.7' do
+    it "returns nil and does nothing for non positive n or empty arrays" do
+      [1,2,3].cycle(0){ throw "ball"}.should be_nil
+      [].cycle(0){ throw "ball"}.should be_nil
+    end
+
+    it "cycle as many times as requested" do
+      [1,2,3].cycle(2).to_a.should == [1,2,3,1,2,3]
+    end
+
+    it "loop indefinitely if no n" do
+      bomb = 10
+      [1,2,3].cycle do
+        bomb -= 1
+        break 42 if bomb <= 0
+      end.should == 42
+      bomb.should == 0
+    end
+  end
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/array/delete_if_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/delete_if_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/delete_if_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -22,20 +22,10 @@
     end
   end
 
-  ruby_version_is "1.8.7" ... "1.9" do
-    it "returns an Enumerable::Enumerator if no block given, and the enumerator can modify the original array" do
-      enum = @a.delete_if
-      enum.should be_kind_of(Enumerable::Enumerator)
-      @a.should_not be_empty
-      enum.each { true }
-      @a.should be_empty
-    end
-  end
-
-  ruby_version_is '1.9' do
+  ruby_version_is '1.8.7' do
     it "returns an Enumerator if no block given, and the enumerator can modify the original array" do
       enum = @a.delete_if
-      enum.should be_kind_of(Enumerator)
+      enum.should be_kind_of(enumerator_class)
       @a.should_not be_empty
       enum.each { true }
       @a.should be_empty

Modified: MacRuby/branches/experimental/spec/frozen/core/array/each_index_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/each_index_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/each_index_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -33,14 +33,9 @@
       lambda{ [1,2].each_index }.should raise_error(LocalJumpError)
     end
   end
-  ruby_version_is '1.8.7' ... '1.9' do
-    it 'returns an Enumerable::Enumerator if no block given' do
-      [1,2].each_index.should be_kind_of(Enumerable::Enumerator)
-    end
-  end
-  ruby_version_is '1.9' do
+  ruby_version_is '1.8.7' do
     it 'returns an Enumerator if no block given' do
-      [1,2].each_index.should be_kind_of(Enumerator)
+      [1,2].each_index.should be_kind_of(enumerator_class)
     end
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/array/each_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/each_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/each_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -47,14 +47,9 @@
       lambda{ [1,2].each }.should raise_error(LocalJumpError)
     end
   end
-  ruby_version_is '1.8.7' ... '1.9' do
-    it 'returns an Enumerable::Enumerator if no block given' do
-      [1,2].each.should be_kind_of(Enumerable::Enumerator)
-    end
-  end
-  ruby_version_is '1.9' do
+  ruby_version_is '1.8.7' do
     it 'returns an Enumerator if no block given' do
-      [1,2].each.should be_kind_of(Enumerator)
+      [1,2].each.should be_kind_of(enumerator_class)
     end
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/array/eql_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/eql_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/eql_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,73 +1,15 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/eql'
 
 # Do not use #should_receive(:eql?) mocks in these specs
 # because MSpec uses Hash for mocks and Hash calls #eql?.
 
 describe "Array#eql?" do
-  it "returns true if other is the same array" do
-    a = [1]
-    a.should eql(a)
-  end
+  it_behaves_like :array_eql, :eql?
 
-  it "returns true if corresponding elements are #eql?" do
-    [].should eql([])
-    [1, 2, 3, 4].should eql([1, 2, 3, 4])
-
-    obj = mock("eql? to anything")
-    def obj.eql?(o) true end
-    [obj].should eql([1])
-  end
-
-  it "returns false if other is shorter than self" do
-    [1, 2, 3, 4].should_not eql([1, 2, 3])
-  end
-
-  it "returns false if other is longer than self" do
-    [1, 2, 3, 4].should_not eql([1, 2, 3, 4, 5])
-  end
-
   it "returns false if any corresponding elements are not #eql?" do
-    [1, 2, 3, 4].should_not eql([1, 2, 3, 4.0])
-
-    obj = mock('what is eql to any object')
-    def obj.eql?(o) false end
-
-    [1, 2, obj].should_not eql([1, 2, obj])
+    [1, 2, 3, 4].send(@method, [1, 2, 3, 4.0]).should be_false
   end
 
-  ruby_bug "#", "1.8.6.277" do
-    it "properly handles recursive arrays" do
-      empty = ArraySpecs.empty_recursive_array
-      empty2 = []; empty2 << empty2
-      empty.should eql(empty.dup)
-      empty.should_not eql(empty2)
-
-      array = ArraySpecs.recursive_array
-      array.should eql(array)
-      array.should eql(array.dup)
-
-      array.should_not eql(empty)
-      array.should_not eql([1, 2])
-    end
-  end
-
-  it "does not call #to_ary on its argument" do
-    obj = mock('to_ary')
-    obj.should_not_receive(:to_ary)
-
-    [1, 2, 3].should_not eql(obj)
-  end
-
-  it "does not call #to_ary on Array subclasses" do
-    ary = ArraySpecs::ToAryArray[5, 6, 7]
-    ary.should_not_receive(:to_ary)
-    [5, 6, 7].should eql(ary)
-  end
-
-  it "ignores array class differences" do
-    ArraySpecs::MyArray[1, 2, 3].should eql([1, 2, 3])
-    ArraySpecs::MyArray[1, 2, 3].should eql(ArraySpecs::MyArray[1, 2, 3])
-    [1, 2, 3].should eql(ArraySpecs::MyArray[1, 2, 3])
-  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/array/equal_value_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/equal_value_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/equal_value_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,35 +1,10 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/eql'
 
 describe "Array#==" do
-  it "return true if the other is self" do
-    a = [1, 2, 3]
-    a.should == a
-  end
+  it_behaves_like :array_eql, :==
 
-  it "returns true if corresponding elements are #==" do
-    [].should == []
-    ["a", "c", 7].should == ["a", "c", 7]
-
-    [1, 2, 3].should == [1.0, 2.0, 3.0]
-
-    obj = mock('5')
-    obj.should_receive(:==).and_return(true)
-    [obj].should == [5]
-  end
-
-  it "returns false if the other is shorter than self" do
-    a = [1, 2, 3]
-    b = [1, 2]
-    a.should_not == b
-  end
-
-  it "returns false if the other is longer than self" do
-    a = [1, 2, 3]
-    b = [1, 2, 3, 4]
-    a.should_not == b
-  end
-
   it "returns false if any corresponding elements are not #==" do
     a = ["a", "b", "c"]
     b = ["a", "b", "not equal value"]
@@ -40,52 +15,14 @@
     ["a", "b", c].should_not == a
   end
 
-  it "returns false immediately when sizes of the arrays differ" do
-    obj = mock('1')
-    obj.should_not_receive(:==)
+  it "returns true if corresponding elements are #==" do
+    [].should == []
+    ["a", "c", 7].should == ["a", "c", 7]
 
-    [].should_not == [obj]
-    [obj].should_not == []
-  end
+    [1, 2, 3].should == [1.0, 2.0, 3.0]
 
-  ruby_bug "#", "1.8.6.277" do
-    it "properly handles recursive arrays" do
-      empty = ArraySpecs.empty_recursive_array
-      empty2 = []; empty2 << empty2
-      (empty == empty.dup).should be_true
-      (empty == empty2).should be_false
-
-      array = ArraySpecs.recursive_array
-      (array == array).should be_true
-      (array == array.dup).should be_true
-      (array == empty).should be_false
-      (array == [1, 2]).should be_false
-    end
+    obj = mock('5')
+    obj.should_receive(:==).and_return(true)
+    [obj].should == [5]
   end
-
-  it "does not call #to_ary on its argument" do
-    obj = mock('to_ary')
-    obj.should_not_receive(:to_ary)
-
-    [1, 2, 3].should_not == obj
-  end
-
-  it "does not call #to_ary on Array subclasses" do
-    ary = ArraySpecs::ToAryArray[5, 6, 7]
-    ary.should_not_receive(:to_ary)
-    [5, 6, 7].should == ary
-  end
-
-  it "ignores array class differences" do
-    ArraySpecs::MyArray[1, 2, 3].should == [1, 2, 3]
-    ArraySpecs::MyArray[1, 2, 3].should == ArraySpecs::MyArray[1, 2, 3]
-    [1, 2, 3].should == ArraySpecs::MyArray[1, 2, 3]
-  end
-
-  it "does not call #== on its argument" do
-    bad_array = ArraySpecs::MyArray[1, 2, 3]
-    bad_array.should_not_receive(:==)
-
-    [1, 2, 3].should == bad_array
-  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/array/fixtures/classes.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/fixtures/classes.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/fixtures/classes.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -76,4 +76,28 @@
       ScratchPad.record args
     end
   end
+
+  class ArrayConvertable
+    attr_accessor :called
+    def initialize(*values, &block)
+      @values = values;
+    end
+    
+    def to_a
+      self.called = :to_a
+      @values
+    end
+    
+    def to_ary
+      self.called = :to_ary
+      @values
+    end
+  end
+
+  class ArrayNotReallyConvertable
+    def to_ary
+      raise "Oups"
+    end
+  end
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/array/flatten_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/flatten_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/flatten_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -118,13 +118,14 @@
       [ 1, 2, [3, [4, 5] ] ].flatten!(1).should == [1, 2, 3, [4, 5]]
     end
 
-    # NOTE: This is inconsistent behaviour, it should return nil
-    it "returns self when the level of recursion is 0" do
-      a = [ 1, 2, [3, [4, 5] ] ]
-      a.flatten!(0).should equal(a)
+    ruby_bug "redmine #1440", "1.9.1" do
+      it "returns nil when the level of recursion is 0" do
+        a = [ 1, 2, [3, [4, 5] ] ]
+        a.flatten!(0).should == nil
+      end
     end
 
-    it "ignores negative levels" do
+    it "treats negative levels as no arguments" do
       [ 1, 2, [ 3, 4, [5, 6] ] ].flatten!(-1).should == [1, 2, 3, 4, 5, 6]
       [ 1, 2, [ 3, 4, [5, 6] ] ].flatten!(-10).should == [1, 2, 3, 4, 5, 6]
     end

Modified: MacRuby/branches/experimental/spec/frozen/core/array/index_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/index_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/index_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,24 +1,7 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/index'
 
 describe "Array#index" do
-  it "returns the index of the first element == to object" do
-    x = mock('3')
-    def x.==(obj) 3 == obj; end
-
-    [2, x, 3, 1, 3, 1].index(3).should == 1
-    [2, 3.0, 3, x, 1, 3, 1].index(x).should == 1
-  end
-
-  it "returns 0 if first element == to object" do
-    [2, 1, 3, 2, 5].index(2).should == 0
-  end
-
-  it "returns size-1 if only last element == to object" do
-    [2, 1, 3, 1, 5].index(5).should == 4
-  end
-
-  it "returns nil if no element == to object" do
-    [2, 1, 1, 1, 1].index(3).should == nil
-  end
+  it_behaves_like :array_index, :index
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/array/initialize_copy_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/initialize_copy_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/initialize_copy_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,9 +3,9 @@
 require File.dirname(__FILE__) + '/shared/replace'
 
 describe "Array#initialize_copy" do
- it "is private" do
-   [].private_methods.map { |m| m.to_s }.include?("initialize_copy").should == true
- end
- 
- it_behaves_like(:array_replace, :initialize_copy)
+  it "is private" do
+    Array.should have_private_instance_method("initialize_copy")
+  end
+
+  it_behaves_like(:array_replace, :initialize_copy)
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/array/initialize_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/initialize_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/initialize_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -6,18 +6,10 @@
     ScratchPad.clear
   end
 
-  ruby_version_is "" ... "1.9" do
-    it "is private" do
-      [].private_methods.should include("initialize")
-    end
+  it "is private" do
+    Array.should have_private_instance_method("initialize")
   end
 
-  ruby_version_is "1.9" do
-    it "is private" do
-      [].private_methods.should include(:initialize)
-    end
-  end
-
   it "is called on subclasses" do
     b = ArraySpecs::SubArray.new :size_or_array, :obj
 

Modified: MacRuby/branches/experimental/spec/frozen/core/array/intersection_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/intersection_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/intersection_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -23,7 +23,7 @@
     a.should == [1, 1, 3, 5]
   end
 
-  ruby_bug "#", "1.8.6.277" do
+  ruby_bug "ruby-core #1448", "1.9.1" do
     it "properly handles recursive arrays" do
       empty = ArraySpecs.empty_recursive_array
       (empty & empty).should == empty
@@ -31,7 +31,7 @@
       (ArraySpecs.recursive_array & []).should == []
       ([] & ArraySpecs.recursive_array).should == []
 
-      (ArraySpecs.recursive_array & ArraySpecs.recursive_array).should == [1, 'two', 3.0]
+      (ArraySpecs.recursive_array & ArraySpecs.recursive_array).should == [1, 'two', 3.0, ArraySpecs.recursive_array]
     end
   end
 

Added: MacRuby/branches/experimental/spec/frozen/core/array/key_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/key_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/array/key_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,9 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/index'
+
+describe "Array#key" do
+  ruby_version_is '1.9' do
+    it_behaves_like :array_index, :key
+  end
+end

Added: MacRuby/branches/experimental/spec/frozen/core/array/product.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/product.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/array/product.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,22 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Array#product" do
+  ruby_version_is "1.9" do
+    it "returns convert arguments using :to_ary" do
+      lambda{ [1].product(2..3) }.should raise_error(TypeError)
+      ar = ArraySpecs::ArrayConvertable.new(2,3)
+      [1].product(ar).should == [[1,2],[1,3]]
+      ar.called.should == :to_ary
+    end
+
+    it "returns the expected result" do
+      [1,2].product([3,4,5],[6,8]).should == [[1, 3, 6], [1, 3, 8], [1, 4, 6], [1, 4, 8], [1, 5, 6], [1, 5, 8],
+                                              [2, 3, 6], [2, 3, 8], [2, 4, 6], [2, 4, 8], [2, 5, 6], [2, 5, 8]]
+    end
+
+    it "has no required argument" do
+      [1,2].product.should == [[1],[2]]
+    end
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/array/reject_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/reject_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/reject_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -33,6 +33,18 @@
       ArraySpecs::MyArray[1, 2, 3].reject { |x| x % 2 == 0 }.class.should == Array
     end
   end
+  
+  ruby_version_is '' ... '1.8.7' do
+    it 'raises a LocalJumpError if no block given' do
+      lambda{ [1,2].reject }.should raise_error(LocalJumpError)
+    end
+  end
+  ruby_version_is '1.8.7' do
+    it 'returns an Enumerator if no block given' do
+      [1,2].reject.should be_kind_of(enumerator_class)
+    end
+  end
+  
 end
 
 describe "Array#reject!" do
@@ -92,4 +104,16 @@
       lambda { ArraySpecs.frozen_array.reject! {} }.should raise_error(RuntimeError)
     end
   end
+  
+  ruby_version_is '' ... '1.8.7' do
+    it 'raises a LocalJumpError if no block given' do
+      lambda{ [1,2].reject! }.should raise_error(LocalJumpError)
+    end
+  end
+  ruby_version_is '1.8.7' do
+    it 'returns an Enumerator if no block given' do
+      [1,2].reject!.should be_kind_of(enumerator_class)
+    end
+  end
+  
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/array/reverse_each_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/reverse_each_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/reverse_each_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -35,4 +35,16 @@
 
     count.should == 2
   end
+  
+  ruby_version_is '' ... '1.8.7' do
+    it 'raises a LocalJumpError if no block given' do
+      lambda{ [1,2].reverse_each }.should raise_error(LocalJumpError)
+    end
+  end
+  ruby_version_is '1.8.7' do
+    it 'returns an Enumerator if no block given' do
+      [1,2].reverse_each.should be_kind_of(enumerator_class)
+    end
+  end
+  
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/array/rindex_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/rindex_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/rindex_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -46,4 +46,14 @@
     array.rindex(1).should == 0
     array.rindex(array).should == 7
   end
+  
+  ruby_version_is "1.8.7" do
+    it "accepts a block instead of an argument" do
+      [4, 2, 1, 5, 1, 3].rindex{|x| x < 2}.should == 4
+    end
+
+    it "ignore the block if there is an argument" do
+      [4, 2, 1, 5, 1, 3].rindex(5){|x| x < 2}.should == 3
+    end
+  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/array/sample_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/sample_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/sample_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -10,7 +10,7 @@
 
   ruby_version_is "1.9" do
     it "selects a random value from the array" do
-      a = [1,2,3,4]
+      a = [1, 2, 3, 4]
       10.times {
         a.include?(a.sample).should be_true
       }
@@ -19,5 +19,48 @@
     it "returns nil for empty arrays" do
       [].sample.should be_nil
     end
+
+    describe "passed a number n as an argument" do
+      it "raises ArgumentError for a negative n" do
+        lambda { [1, 2].sample(-1) }.should raise_error(ArgumentError)
+      end
+
+      it "returns different random values from the array" do
+        a = [1, 2, 3, 4]
+        sum = []
+        42.times {
+          pair = a.sample(2)
+          sum.concat(pair)
+          (pair - a).should == []
+          pair[0].should_not == pair[1]
+        }
+        a.should == [1, 2, 3, 4]
+        (a - sum).should == []  # Might fail once every 2^40 times ...
+      end
+
+      it "tries to convert n to an Integer using #to_int" do
+        a = [1, 2, 3, 4]
+        a.sample(2.3).size.should == 2
+
+        obj = mock('to_int')
+        obj.should_receive(:to_int).and_return(2)
+        a.sample(obj).size.should == 2
+      end
+
+      it "returns all values with n big enough" do
+        a = [1, 2, 3, 4]
+        a.sample(4).sort.should == a
+        a.sample(5).sort.should == a
+      end
+
+      it "returns [] for empty arrays or if n <= 0" do
+        [].sample(1).should == []
+        [1, 2, 3].sample(0).should == []
+      end
+
+      it "does not return subclass instances with Array subclass" do
+        ArraySpecs::MyArray[1, 2, 3].sample(2).class.should == Array
+      end
+    end
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/array/shared/collect.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/shared/collect.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/shared/collect.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -40,7 +40,7 @@
   ruby_version_is '1.9' do
     it "returns an Enumerator when no block given" do
       a = [1, 2, 3]
-      a.send(@method).should be_kind_of(Enumerator)
+      a.send(@method).should be_kind_of(enumerator_class)
     end
   end
 
@@ -92,26 +92,16 @@
     end
   end
 
-  ruby_version_is '1.8.7' ... '1.9' do
-    it "returns an Enumerable::Enumerator when no block given, and the enumerator can modify the original array" do
+  ruby_version_is '1.8.7' do
+    it "returns an Enumerator when no block given, and the enumerator can modify the original array" do
       a = [1, 2, 3]
       enum = a.send(@method)
-      enum.should be_kind_of(Enumerable::Enumerator)
+      enum.should be_kind_of(enumerator_class)
       enum.each{|i| "#{i}!" }
       a.should == ["1!", "2!", "3!"]
     end
   end
 
-  ruby_version_is '1.9' do
-    it "returns an Enumerator when no block given, and the enumeratoe can modify the original array" do
-      a = [1, 2, 3]
-      enum = a.send(@method)
-      enum.should be_kind_of(Enumerator)
-      enum.each{|i| "#{i}!" }
-      a.should == ["1!", "2!", "3!"]
-    end
-  end
-
   it "keeps tainted status" do
     a = [1, 2, 3]
     a.taint

Added: MacRuby/branches/experimental/spec/frozen/core/array/shared/eql.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/shared/eql.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/array/shared/eql.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,90 @@
+describe :array_eql, :shared => true do
+  it "returns true if other is the same array" do
+    a = [1]
+    a.send(@method, a).should be_true
+  end
+
+  it "returns true if corresponding elements are #eql?" do
+    [].send(@method, []).should be_true
+    [1, 2, 3, 4].send(@method, [1, 2, 3, 4]).should be_true
+  end
+
+  it "returns false if other is shorter than self" do
+    [1, 2, 3, 4].send(@method, [1, 2, 3]).should be_false
+  end
+
+  it "returns false if other is longer than self" do
+    [1, 2, 3, 4].send(@method, [1, 2, 3, 4, 5]).should be_false
+  end
+
+  it "returns false immediately when sizes of the arrays differ" do
+    obj = mock('1')
+    obj.should_not_receive(@method)
+
+    []        .send(@method,    [obj]  ).should be_false
+    [obj]     .send(@method,    []     ).should be_false
+  end
+
+  ruby_bug "ruby-core #1448", "1.9.1" do
+    it "handles well recursive arrays" do
+      a = ArraySpecs.empty_recursive_array
+      a       .send(@method,    [a]    ).should be_true
+      a       .send(@method,    [[a]]  ).should be_true
+      [a]     .send(@method,    a      ).should be_true
+      [[a]]   .send(@method,    a      ).should be_true
+
+      a2 = ArraySpecs.empty_recursive_array
+      a       .send(@method,    a2     ).should be_true
+      a       .send(@method,    [a2]   ).should be_true
+      a       .send(@method,    [[a2]] ).should be_true
+      [a]     .send(@method,    a2     ).should be_true
+      [[a]]   .send(@method,    a2     ).should be_true
+
+      back = []
+      forth = [back]; back << forth;
+      back   .send(@method,  a  ).should be_true
+
+      x = []; x << x << x
+      x       .send(@method,    a                ).should be_false
+      x       .send(@method,    [a, a]           ).should be_false
+      x       .send(@method,    [x, a]           ).should be_false
+      [x, a]  .send(@method,    [a, x]           ).should be_false
+      x       .send(@method,    [x, x]           ).should be_true
+      x       .send(@method,    [[x, x], [x, x]] ).should be_true
+
+      tree = [];
+      branch = []; branch << tree << tree; tree << branch
+      tree2 = [];
+      branch2 = []; branch2 << tree2 << tree2; tree2 << branch2
+      forest = [tree, branch, :bird, a]; forest << forest
+      forest2 = [tree2, branch2, :bird, a2]; forest2 << forest2
+
+      forest .send(@method,     forest2         ).should be_true
+      forest .send(@method,     [tree2, branch, :bird, a, forest2]).should be_true
+
+      diffforest = [branch2, tree2, :bird, a2]; diffforest << forest2
+      forest .send(@method,     diffforest      ).should be_false
+      forest .send(@method,     [nil]           ).should be_false
+      forest .send(@method,     [forest]        ).should be_false
+    end
+  end
+
+  it "does not call #to_ary on its argument" do
+    obj = mock('to_ary')
+    obj.should_not_receive(:to_ary)
+
+    [1, 2, 3].send(@method, obj).should be_false
+  end
+
+  it "does not call #to_ary on Array subclasses" do
+    ary = ArraySpecs::ToAryArray[5, 6, 7]
+    ary.should_not_receive(:to_ary)
+    [5, 6, 7].send(@method, ary).should be_true
+  end
+
+  it "ignores array class differences" do
+    ArraySpecs::MyArray[1, 2, 3].send(@method, [1, 2, 3]).should be_true
+    ArraySpecs::MyArray[1, 2, 3].send(@method, ArraySpecs::MyArray[1, 2, 3]).should be_true
+    [1, 2, 3].send(@method, ArraySpecs::MyArray[1, 2, 3]).should be_true
+  end
+end

Added: MacRuby/branches/experimental/spec/frozen/core/array/shared/index.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/shared/index.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/array/shared/index.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,32 @@
+describe :array_index, :shared => true do
+  it "returns the index of the first element == to object" do
+    x = mock('3')
+    def x.==(obj) 3 == obj; end
+
+    [2, x, 3, 1, 3, 1].send(@method, 3).should == 1
+    [2, 3.0, 3, x, 1, 3, 1].send(@method, x).should == 1
+  end
+
+  it "returns 0 if first element == to object" do
+    [2, 1, 3, 2, 5].send(@method, 2).should == 0
+  end
+
+  it "returns size-1 if only last element == to object" do
+    [2, 1, 3, 1, 5].send(@method, 5).should == 4
+  end
+
+  it "returns nil if no element == to object" do
+    [2, 1, 1, 1, 1].send(@method, 3).should == nil
+  end
+
+  ruby_version_is "1.8.7" do
+    it "accepts a block instead of an argument" do
+      [4, 2, 1, 5, 1, 3].send(@method){|x| x < 2}.should == 2
+    end
+
+    it "ignore the block if there is an argument" do
+      [4, 2, 1, 5, 1, 3].send(@method, 5){|x| x < 2}.should == 3
+    end
+
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/array/shift_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/shift_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/shift_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -41,4 +41,106 @@
       lambda { ArraySpecs.frozen_array.shift }.should raise_error(RuntimeError)
     end
   end
+  
+  ruby_version_is '' ... '1.8.7' do
+    it "raises an ArgumentError if passed an argument" do
+      lambda{ [1, 2].shift(1) }.should raise_error(ArgumentError)
+    end
+  end
+
+  describe "passed a number n as an argument" do
+    ruby_version_is '1.8.7' do
+      it "removes and returns an array with the first n element of the array" do
+        a = [1, 2, 3, 4, 5, 6]
+
+        a.shift(0).should == []
+        a.should == [1, 2, 3, 4, 5, 6]
+
+        a.shift(1).should == [1]
+        a.should == [2, 3, 4, 5, 6]
+
+        a.shift(2).should == [2, 3]
+        a.should == [4, 5, 6]
+
+        a.shift(3).should == [4, 5, 6]
+        a.should == []
+      end
+
+      it "returns a new empty array if there are no more elements" do
+        a = []
+        popped1 = a.shift(1)
+        popped1.should == []
+        a.should == []
+
+        popped2 = a.shift(2)
+        popped2.should == []
+        a.should == []
+
+        popped1.should_not equal(popped2)
+      end
+
+      it "returns whole elements if n exceeds size of the array" do
+        a = [1, 2, 3, 4, 5]
+        a.shift(6).should == [1, 2, 3, 4, 5]
+        a.should == []
+      end
+
+      it "does not return self even when it returns whole elements" do
+        a = [1, 2, 3, 4, 5]
+        a.shift(5).should_not equal(a)
+
+        a = [1, 2, 3, 4, 5]
+        a.shift(6).should_not equal(a)
+      end
+
+      it "raises an ArgumentError if n is negative" do
+        lambda{ [1, 2, 3].shift(-1) }.should raise_error(ArgumentError)
+      end
+
+      it "tries to convert n to an Integer using #to_int" do
+        a = [1, 2, 3, 4]
+        a.shift(2.3).should == [1, 2]
+
+        obj = mock('to_int')
+        obj.should_receive(:to_int).and_return(2)
+        a.should == [3, 4]
+        a.shift(obj).should == [3, 4]
+        a.should == []
+      end
+
+      it "raises a TypeError when the passed n can be coerced to Integer" do
+        lambda{ [1, 2].shift("cat") }.should raise_error(TypeError)
+        lambda{ [1, 2].shift(nil) }.should raise_error(TypeError)
+      end
+
+      it "raises an ArgumentError if more arguments are passed" do
+        lambda{ [1, 2].shift(1, 2) }.should raise_error(ArgumentError)
+      end
+
+      it "does not return subclass instances with Array subclass" do
+        ArraySpecs::MyArray[1, 2, 3].shift(2).class.should == Array
+      end
+
+      it "returns an untainted array even if the array is tainted" do
+        ary = [1, 2].taint
+        ary.shift(2).tainted?.should be_false
+        ary.shift(0).tainted?.should be_false
+      end
+
+      it "keeps taint status" do
+        a = [1, 2].taint
+        a.shift(2)
+        a.tainted?.should be_true
+        a.shift(2)
+        a.tainted?.should be_true
+      end
+
+      ruby_version_is '' ... '1.9' do
+        it "raises a TypeError on a frozen array" do
+          lambda { ArraySpecs.frozen_array.shift(2) }.should raise_error(TypeError)
+          lambda { ArraySpecs.frozen_array.shift(0) }.should raise_error(TypeError)
+        end
+      end
+    end
+  end
 end

Added: MacRuby/branches/experimental/spec/frozen/core/array/shuffle_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/shuffle_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/array/shuffle_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,59 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Array#shuffle" do
+  ruby_version_is "1.8.7" do
+    it "should return the same values, in a usually different order" do
+      a = [1,2,3,4]
+      different = false
+      10.times do
+        s = a.shuffle
+        s.sort.should == a
+        different ||= (a != s)
+      end
+      different.should be_true # Will fail once in a blue moon (4!^10)
+    end
+
+    it "returns subclass instances with Array subclass" do
+      ArraySpecs::MyArray[1, 2, 3].shuffle.class.should == ArraySpecs::MyArray
+    end
+  
+    it "is not destructive" do
+      a = [1, 2, 3]
+      10.times do
+        a.shuffle
+        a.should == [1, 2, 3]
+      end
+    end
+
+  end
+end
+
+describe "Array#shuffle!" do
+  ruby_version_is "1.8.7" do
+    it "should return the same values, in a usually different order" do
+      a = [1,2,3,4]
+      original = a
+      different = false
+      10.times do
+        a = a.shuffle!
+        a.sort.should == [1,2,3,4]
+        different ||= (a != [1,2,3,4])
+      end
+      different.should be_true # Will fail once in a blue moon (4!^10)
+      a.should equal(original)
+    end
+
+    ruby_version_is ""..."1.9" do
+      it "raises a TypeError on a frozen array" do
+        lambda { ArraySpecs.frozen_array.reverse! }.should raise_error(TypeError)
+      end
+    end
+
+    ruby_version_is "1.9" do
+      it "raises a RuntimeError on a frozen array" do
+        lambda { ArraySpecs.frozen_array.shuffle! }.should raise_error(RuntimeError)
+      end
+    end
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/array/sort_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/sort_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/array/sort_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -29,6 +29,17 @@
     protected
     attr_accessor :order
   end
+  
+  class ComparableWithFixnum
+    include Comparable
+    def initialize(num)
+      @num = num
+    end
+
+    def <=>(fixnum)
+      @num <=> fixnum
+    end
+  end
 end
 
 
@@ -136,6 +147,18 @@
   it "returns the specified value when it would break in the given block" do
     [1, 2, 3].sort{ break :a }.should == :a
   end
+  
+  it "compares values returned by block with 0" do
+    a = [1, 2, 5, 10, 7, -4, 12]
+    a.sort { |n, m| n - m }.should == [-4, 1, 2, 5, 7, 10, 12]
+    a.sort { |n, m|
+      ArraySpecs::ComparableWithFixnum.new(n-m)
+    }.should == [-4, 1, 2, 5, 7, 10, 12]
+    lambda {
+      a.sort { |n, m| (n - m).to_s }
+    }.should raise_error(ArgumentError)
+  end
+  
 end
 
 describe "Array#sort!" do

Added: MacRuby/branches/experimental/spec/frozen/core/array/try_convert_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/try_convert_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/array/try_convert_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,35 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Array.try_convert" do
+  ruby_version_is "1.9" do
+    it "returns self for arrays" do
+      x = [1,2,3]
+      Array.try_convert(x).should equal(x)
+    end
+    
+    it "converts using :to_ary" do
+      arr = ArraySpecs::ArrayConvertable.new(1,2,3)
+      Array.try_convert(arr).should == [1,2,3]
+      arr.called.should == :to_ary
+    end
+    
+    it "returns nil when there is no :to_ary" do
+      Array.try_convert(-1).should be_nil
+    end
+    
+    it "should not rescue errors" do
+      lambda{
+        Array.try_convert(ArraySpecs::ArrayNotReallyConvertable.new)
+      }.should raise_error
+    end
+    
+    it "checks the result of the conversion" do
+      obj = mock('crazy to_ary')
+      obj.should_receive(:to_ary).and_return(:confused)
+      lambda{
+        Array.try_convert(obj)
+      }.should raise_error(TypeError)
+    end
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/core/binding/eval_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/binding/eval_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/binding/eval_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,24 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Binding#eval" do
+  ruby_version_is '1.8.7' do
+    it "behaves like Kernel.eval(..., self)" do
+      obj = BindingSpecs::Demo.new(1)
+      bind1 = obj.get_binding
+      bind2 = obj.dup.get_binding
+      { "@secret += square(3)" => 10,
+        "a" => true,
+        "class Inside ; end" => nil,
+        "Inside.name" => "BindingSpecs::Demo::Inside"
+      }.each do |test, result|
+        r1 = bind1.eval(test)
+        r2 = Kernel.eval(test, bind2)
+        r1.should == r2
+        r1.should == result
+      end
+    end
+  
+    it "needs to be completed"
+  end
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/dir/each_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/dir/each_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/dir/each_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -26,6 +26,20 @@
     @dir.rewind
     ls.should include(@dir.read)
   end
+  
+  ruby_version_is '' ... '1.8.7' do
+    it 'raises a LocalJumpError if no block given' do
+      lambda{ @dir.each }.should raise_error(LocalJumpError)
+    end
+  end
+
+  ruby_version_is '1.8.7' do
+    it 'returns an Enumerator if no block given' do
+      @dir.each.should be_kind_of(enumerator_class)
+      @dir.each.to_a.should == DirSpecs.expected_paths
+    end
+  end
+
 end
 
 describe "Dir#each" do

Modified: MacRuby/branches/experimental/spec/frozen/core/dir/fixtures/common.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/dir/fixtures/common.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/dir/fixtures/common.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,12 +1,8 @@
 require 'fileutils'
 
 module DirSpecs
-  def DirSpecs.mock_dir
-    unless defined? @mock_dir then
-      @mock_dir = File.expand_path(tmp('mock'))
-    end
-
-    @mock_dir
+  def DirSpecs.mock_dir(dirs = ['mock'])
+    File.expand_path(tmp(File.join(dirs)))
   end
 
   def DirSpecs.nonexistent
@@ -87,6 +83,41 @@
     File.umask umask
   end
 
+  def self.mock_rmdir(*dirs)
+    mock_dir ['rmdir_dirs'].concat(dirs)
+  end
+
+  def self.rmdir_dirs(create = true)
+    dirs = %w[
+      empty
+      nonempty
+      nonempty/child
+      noperm
+      noperm/child
+    ]
+
+    base_dir = mock_dir ['rmdir_dirs']
+
+    dirs.reverse_each do |d|
+      dir = File.join base_dir, d
+      if File.exists? dir
+        File.chmod 0777, dir
+        FileUtils.rm_rf dir
+      end
+    end
+    FileUtils.rm_rf base_dir
+
+    if create
+      dirs.each do |d|
+        dir = File.join base_dir, d
+        unless File.exists? dir
+          FileUtils.mkdir_p dir
+          File.chmod 0777, dir
+        end
+      end
+    end
+  end
+
   def self.expected_paths
     %w[
       .

Modified: MacRuby/branches/experimental/spec/frozen/core/dir/foreach_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/dir/foreach_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/dir/foreach_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -19,4 +19,18 @@
   it "raises a SystemCallError if passed a nonexistent directory" do
     lambda { Dir.foreach(DirSpecs.nonexistent) {} }.should raise_error(SystemCallError)
   end
+  
+  ruby_version_is '' ... '1.8.7' do
+    it 'raises a LocalJumpError if no block given' do
+      lambda{ Dir.foreach(DirSpecs.mock_dir) }.should raise_error(LocalJumpError)
+    end
+  end
+
+  ruby_version_is '1.8.7' do
+    it 'returns an Enumerator if no block given' do
+      Dir.foreach(DirSpecs.mock_dir).should be_kind_of(enumerator_class)
+      Dir.foreach(DirSpecs.mock_dir).to_a.should == DirSpecs.expected_paths
+    end
+  end
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/dir/shared/delete.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/dir/shared/delete.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/dir/shared/delete.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,26 +1,26 @@
 describe :dir_delete, :shared => true do
+  before :all do
+    DirSpecs.rmdir_dirs
+  end
+
+  after :all do
+    DirSpecs.rmdir_dirs false
+  end
+
   it "removes empty directories" do
-    Dir.mkdir 'empty_subdir'
-    Dir.send(@method, 'empty_subdir').should == 0
+    Dir.send(@method, DirSpecs.mock_rmdir("empty")).should == 0
   end
 
   it "raises a SystemCallError when trying to remove a nonempty directory" do
-    lambda { Dir.send @method, 'subdir_one' }.should raise_error(SystemCallError)
+    lambda do
+      Dir.send @method, DirSpecs.mock_rmdir("nonempty")
+    end.should raise_error(SystemCallError)
   end
 
   it "raises a SystemCallError if lacking adequate permissions to remove the directory" do
-    FileUtils.mkdir_p("noperm_#{@method}/child")
-    File.chmod(0000, "noperm_#{@method}")
-
-    lambda { Dir.send @method, "noperm_#{@method}/child" }.should raise_error(SystemCallError)
-
-    platform_is_not(:windows) do
-    system "chmod 0777 noperm_#{@method}"
-    end
-    platform_is(:windows) do
-      File.chmod(0666, "noperm_#{@method}")
-    end
-    Dir.rmdir "noperm_#{@method}/child"
-    Dir.rmdir "noperm_#{@method}"
+    File.chmod(0000, DirSpecs.mock_rmdir("noperm"))
+    lambda do
+      Dir.send @method, DirSpecs.mock_rmdir("noperm", "child")
+    end.should raise_error(SystemCallError)
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/enumerable/collect_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/collect_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/collect_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -4,18 +4,4 @@
 
 describe "Enumerable#collect" do   
   it_behaves_like(:enumerable_collect , :collect)
-
-  ruby_version_is "" ... "1.9" do
-    it "gathers whole arrays as elements when each yields multiple" do
-      multi = EnumerableSpecs::YieldsMulti.new
-      multi.collect {|e| e}.should == [[1,2],[3,4,5],[6,7,8,9]]
-    end
-  end
-
-  ruby_version_is "1.9" do
-    it "gathers initial args as elements when each yields multiple" do
-      multi = EnumerableSpecs::YieldsMulti.new
-      multi.collect {|e| e}.should == [1,3,6]
-    end
-  end
 end

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/count_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/count_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/count_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,31 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Enumerable#count" do
+  ruby_version_is '1.8.7' do
+    before :each do
+      @elements = [1, 2, 4, 2]
+      @numerous = EnumerableSpecs::Numerous.new(*@elements)
+    end
+  
+    it "returns size when no argument or a block" do
+      @numerous.count.should == 4
+    end
+
+    it "counts nils if given nil as an argument" do
+      EnumerableSpecs::Numerous.new(nil, nil, nil, false).count(nil).should == 3
+    end
+
+    it "accepts an argument for comparison using ==" do
+      @numerous.count(2).should == 2
+    end
+
+    it "uses a block for comparison" do
+      @numerous.count{|x| x%2==0 }.should == 3
+    end
+
+    it "ignores the block when given an argument" do
+      @numerous.count(4){|x| x%2==0 }.should == 1
+    end
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/cycle_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/cycle_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/cycle_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,56 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Enumerable#cycle" do
+  ruby_version_is '1.8.7' do
+
+    it "loops indefinitely if no argument or nil argument" do
+      [[],[nil]].each do |args|
+        bomb = 10
+        EnumerableSpecs::Numerous.new.cycle(*args) do
+          bomb -= 1
+          break 42 if bomb <= 0
+        end.should == 42
+        bomb.should == 0
+      end
+    end
+
+    describe "passed a number n as an argument" do
+      it "returns nil and does nothing for non positive n" do
+        EnumerableSpecs::ThrowingEach.new.cycle(0){}.should be_nil
+        EnumerableSpecs::NoEach.new.cycle(-22){}.should be_nil
+      end
+
+      it "calls each at most once" do
+        enum = EnumerableSpecs::EachCounter.new(1, 2)
+        enum.cycle(3).to_a.should == [1,2,1,2,1,2]
+        enum.times_called.should == 1
+      end
+
+      it "yields only when necessary" do
+        enum = EnumerableSpecs::EachCounter.new(10, 20, 30)
+        enum.cycle(3){|x| break if x == 20}
+        enum.times_yielded.should == 2
+      end
+
+      it "tries to convert n to an Integer using #to_int" do
+        enum = EnumerableSpecs::Numerous.new(3, 2, 1)
+        enum.cycle(2.3).to_a.should == [3, 2, 1, 3, 2, 1]
+
+        obj = mock('to_int')
+        obj.should_receive(:to_int).and_return(2)
+        enum.cycle(obj).to_a.should == [3, 2, 1, 3, 2, 1]
+      end
+
+      it "raises a TypeError when the passed n can be coerced to Integer" do
+        enum = EnumerableSpecs::Numerous.new
+        lambda{ enum.cycle("cat"){} }.should raise_error(TypeError)
+      end
+
+      it "raises an ArgumentError if more arguments are passed" do
+        enum = EnumerableSpecs::Numerous.new
+        lambda{ enum.cycle(1, 2){} }.should raise_error(ArgumentError)
+      end
+    end
+  end
+end

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/drop_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/drop_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/drop_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,45 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Enumerable#drop" do
+  ruby_version_is '1.8.7' do
+    before :each do
+      @enum = EnumerableSpecs::Numerous.new(3, 2, 1, :go)
+    end
+
+    it "requires exactly one argument" do
+      lambda{ @enum.drop{} }.should raise_error(ArgumentError)
+      lambda{ @enum.drop(1, 2){} }.should raise_error(ArgumentError)
+    end
+
+    describe "passed a number n as an argument" do
+      it "raise ArgumentError if n < 0" do
+        lambda{ @enum.drop(-1) }.should raise_error(ArgumentError)
+      end
+
+      it "tries to convert n to an Integer using #to_int" do
+        @enum.drop(2.3).should == [1, :go]
+
+        obj = mock('to_int')
+        obj.should_receive(:to_int).and_return(2)
+        @enum.drop(obj).should == [1, :go]
+      end
+
+      it "returns [] for empty enumerables" do
+        EnumerableSpecs::Empty.new.drop(0).should == []
+        EnumerableSpecs::Empty.new.drop(2).should == []
+      end
+
+      it "returns [] if dropping all" do
+        @enum.drop(5).should == []
+        EnumerableSpecs::Numerous.new(3, 2, 1, :go).drop(4).should == []
+      end
+
+      it "raises a TypeError when the passed n can be coerced to Integer" do
+        lambda{ @enum.drop("hat") }.should raise_error(TypeError)
+        lambda{ @enum.drop(nil) }.should raise_error(TypeError)
+      end
+
+    end
+  end
+end

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/drop_while_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/drop_while_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/drop_while_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,44 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Enumerable#drop_while" do
+  ruby_version_is '1.8.7' do
+    before :each do
+      @enum = EnumerableSpecs::Numerous.new(3, 2, 1, :go)
+    end
+
+    it 'returns an Enumerator if no block given' do
+      @enum.drop_while.should be_kind_of(enumerator_class)
+    end
+
+    it "returns no/all elements for {true/false} block" do
+      @enum.drop_while{true}.should == []
+      @enum.drop_while{false}.should == @enum.to_a
+    end
+    
+    it "accepts returns other than true/false" do
+      @enum.drop_while{1}.should == []
+      @enum.drop_while{nil}.should == @enum.to_a
+    end
+  
+    it "passes elements to the block until the first false" do
+      a = []
+      @enum.drop_while{|obj| (a << obj).size < 3}.should == [1, :go]
+      a.should == [3, 2, 1]
+    end
+
+    it "will only go through what's needed" do
+      enum = EnumerableSpecs::EachCounter.new(1,2,3,4)
+      enum.drop_while { |x|
+        break 42 if x == 3
+        true
+      }.should == 42
+      enum.times_yielded.should == 3
+    end
+
+    it "doesn't return self when it could" do
+      a = [1,2,3]
+      a.drop_while{false}.should_not equal(a)
+    end
+  end
+end

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/each_cons_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/each_cons_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/each_cons_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,57 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+require 'enumerator'
+
+describe "Enumerable#each_cons" do
+  before :each do
+    @enum = EnumerableSpecs::Numerous.new(4,3,2,1)
+    @in_threes = [[4,3,2],[3,2,1]]
+  end
+
+  it "passes element groups to the block" do 
+    acc = []
+    @enum.each_cons(3){|g| acc << g}.should be_nil
+    acc.should == @in_threes
+  end
+
+  it "raises an Argument Error if there is not a single parameter > 0" do 
+    lambda{ @enum.each_cons(0){}    }.should raise_error(ArgumentError)
+    lambda{ @enum.each_cons(-2){}   }.should raise_error(ArgumentError)
+    lambda{ @enum.each_cons{}       }.should raise_error(ArgumentError)
+    lambda{ @enum.each_cons(2,2){}  }.should raise_error(ArgumentError)
+  end
+
+  it "tries to convert n to an Integer using #to_int" do
+    acc = []
+    @enum.each_cons(3.3){|g| acc << g}.should == nil
+    acc.should == @in_threes
+  
+    obj = mock('to_int')
+    obj.should_receive(:to_int).and_return(3)
+    @enum.each_cons(obj){|g| break g.length}.should == 3
+  end
+
+  it "works when n is >= full length" do
+    full = @enum.to_a
+    acc = []
+    @enum.each_cons(full.length){|g| acc << g}
+    acc.should == [full]
+    acc = []
+    @enum.each_cons(full.length+1){|g| acc << g}
+    acc.should == []
+  end
+
+  it "yields only as much as needed" do
+    cnt = EnumerableSpecs::EachCounter.new(1, 2, :stop, "I said stop!", :got_it)
+    cnt.each_cons(2) {|g| break 42 if g[-1] == :stop }.should == 42
+    cnt.times_yielded.should == 3
+  end
+
+  ruby_version_is '1.8.7' do
+    it "returns an enumerator if no block" do 
+      e = @enum.each_cons(3)
+      e.should be_kind_of(enumerator_class)
+      e.to_a.should == @in_threes
+    end
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/each_slice_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/each_slice_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/each_slice_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,57 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+require 'enumerator'
+
+describe "Enumerable#each_slice" do
+  before :each do
+    @enum = EnumerableSpecs::Numerous.new(7,6,5,4,3,2,1)
+    @sliced = [[7,6,5],[4,3,2],[1]]
+  end
+
+  it "passes element groups to the block" do 
+    acc = []
+    @enum.each_slice(3){|g| acc << g}.should be_nil
+    acc.should == @sliced
+  end
+
+  it "raises an Argument Error if there is not a single parameter > 0" do 
+    lambda{ @enum.each_slice(0){}    }.should raise_error(ArgumentError)
+    lambda{ @enum.each_slice(-2){}   }.should raise_error(ArgumentError)
+    lambda{ @enum.each_slice{}       }.should raise_error(ArgumentError)
+    lambda{ @enum.each_slice(2,2){}  }.should raise_error(ArgumentError)
+  end
+
+  it "tries to convert n to an Integer using #to_int" do
+    acc = []
+    @enum.each_slice(3.3){|g| acc << g}.should == nil
+    acc.should == @sliced
+  
+    obj = mock('to_int')
+    obj.should_receive(:to_int).and_return(3)
+    @enum.each_slice(obj){|g| break g.length}.should == 3
+  end
+
+  it "works when n is >= full length" do
+    full = @enum.to_a
+    acc = []
+    @enum.each_slice(full.length){|g| acc << g}
+    acc.should == [full]
+    acc = []
+    @enum.each_slice(full.length+1){|g| acc << g}
+    acc.should == [full]
+  end
+
+  it "yields only as much as needed" do
+    cnt = EnumerableSpecs::EachCounter.new(1, 2, :stop, "I said stop!", :got_it)
+    cnt.each_slice(2) {|g| break 42 if g[0] == :stop }.should == 42
+    cnt.times_yielded.should == 4
+  end
+
+  ruby_version_is '1.8.7' do
+    it "returns an enumerator if no block" do 
+      e = @enum.each_slice(3)
+      e.should be_kind_of(enumerator_class)
+      e.to_a.should == @sliced
+    end
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/enumerable/each_with_index_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/each_with_index_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/each_with_index_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -4,12 +4,12 @@
 describe "Enumerable#each_with_index" do
 
   before :each do
-    @b = [2, 5, 3, 6, 1, 4]  
+    @b = EnumerableSpecs::Numerous.new(2, 5, 3, 6, 1, 4)
   end 
   
   it "passes each element and its index to block" do
     @a = []
-    EnumerableSpecs::Numerous.new.each_with_index { |o, i| @a << [o, i] }
+    @b.each_with_index { |o, i| @a << [o, i] }
     @a.should == [[2, 0], [5, 1], [3, 2], [6, 3], [1, 4], [4, 5]]
   end
   
@@ -25,13 +25,31 @@
     acc = [] 
     res = @b.each_with_index {|a,i| acc << [a,i]}
     [[2, 0], [5, 1], [3, 2], [6, 3], [1, 4], [4, 5]].should == acc
-    @b.should == res
+    res.should eql(@b)
   end
 
   it "binds splat arguments properly" do
     acc = []
     res = @b.each_with_index { |*b| c,d = b; acc << c; acc << d }
     [2, 0, 5, 1, 3, 2, 6, 3, 1, 4, 4, 5].should == acc
-    @b.should == res
+    res.should eql(@b)
   end
+  
+  ruby_version_is '1.8.7' do
+    it "returns an enumerator if no block" do 
+      e = @b.each_with_index
+      e.should be_kind_of(enumerator_class)
+      e.to_a.should == [[2, 0], [5, 1], [3, 2], [6, 3], [1, 4], [4, 5]]
+    end    
+  end
+  
+  ruby_version_is '1.9' do
+    it "passes extra parameters to each" do 
+      count = EnumerableSpecs::EachCounter.new(:apple)
+      e = count.each_with_index(:foo, :bar)
+      e.to_a.should == [[:apple, 0]]
+      count.arguments_passed.should == [:foo, :bar]
+    end    
+
+  end
 end

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/each_with_object_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/each_with_object_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/each_with_object_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,33 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Enumerable#each_with_object" do
+  ruby_version_is '1.9' do
+    before :each do
+      @values = [2, 5, 3, 6, 1, 4]
+      @enum = EnumerableSpecs::Numerous.new(*@values)
+      @initial = "memo"
+    end 
+  
+    it "passes each element and its argument to the block" do
+      acc = []
+      @enum.each_with_object(@initial) do |elem, obj|
+        obj.should equal(@initial)
+        obj = 42
+        acc << elem
+      end.should equal(@initial)
+      acc.should == @values
+    end
+
+    it "returns an enumerator if no block" do
+      acc = []
+      e = @enum.each_with_object(@initial)
+      e.each do |elem, obj|
+        obj.should equal(@initial)
+        obj = 42
+        acc << elem
+      end.should equal(@initial)
+      acc.should == @values
+    end
+  end  
+end

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/find_index.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/find_index.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/find_index.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,54 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Enumerable#find_index" do  
+  ruby_version_is "1.8.7" do
+    before :each do
+      @elements = [2, 4, 6, 8, 10]
+      @numerous = EnumerableSpecs::Numerous.new(*@elements)
+    end
+
+    it "passes each entry in enum to block while block when block is false" do
+      visited_elements = []
+      @numerous.find_index do |element|
+        visited_elements << element
+        false
+      end
+      visited_elements.should == @elements
+    end
+
+    it "returns nil when the block is false" do
+      @numerous.find_index {|e| false }.should == nil
+    end
+
+    it "returns the first index for which the block is not false" do
+      @elements.each_with_index do |element, index|
+        @numerous.find_index {|e| e > element - 1 }.should == index
+      end
+    end
+
+    it "returns the first index found" do
+      repeated = [10, 11, 11, 13, 11, 13, 10, 10, 13, 11]
+      numerous_repeat = EnumerableSpecs::Numerous.new(*repeated)
+      repeated.each do |element|
+        numerous_repeat.find_index(element).should == element - 10
+      end
+    end
+
+    it "returns nil when the element not found" do
+      @numerous.find_index(-1).should == nil
+    end
+
+    it "ignores the block if an argument is given" do
+      @numerous.find_index(-1) {|e| true }.should == nil
+    end
+    
+    ruby_version_is '1.8.7' do
+      it 'returns an Enumerator if no block given' do
+        @numerous.find_index.should be_kind_of(enumerator_class)
+      end
+    end
+
+  end
+
+end

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/first_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/first_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/first_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,20 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/take'
+
+describe "Enumerable#first" do
+  ruby_version_is '1.8.7' do
+    it "returns the first element" do
+      EnumerableSpecs::Numerous.new.first.should == 2
+      EnumerableSpecs::Empty.new.first.should == nil
+    end
+  
+    it "returns nil if self is empty" do
+      EnumerableSpecs::Empty.new.first.should == nil
+    end
+    
+    describe "when passed an argument" do
+      it_behaves_like :enumerable_take, :first
+    end
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/enumerable/fixtures/classes.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/fixtures/classes.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/fixtures/classes.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,7 +2,6 @@
 
   class Numerous
     include Enumerable
-    
     def initialize(*list)
       @list = list.empty? ? [2, 5, 3, 6, 1, 4] : list
     end
@@ -12,6 +11,24 @@
     end      
   end
 
+  class EachCounter < Numerous
+    attr_reader :times_called, :times_yielded, :arguments_passed
+    def initialize(*list)
+      super(*list)
+      @times_yielded = @times_called = 0
+    end
+    
+    def each(*arg)
+      @times_called += 1
+      @times_yielded = 0
+      @arguments_passed = arg
+      @list.each do |i|
+        @times_yielded +=1 
+        yield i
+      end
+    end      
+  end
+
   class Empty
     include Enumerable
     def each
@@ -98,8 +115,8 @@
       @values
     end
     
-    def to_arr
-      self.called = :to_arr
+    def to_ary
+      self.called = :to_ary
       @values
     end
   end
@@ -122,4 +139,29 @@
     end
   end
 
+  class ReverseComparable
+    include Comparable
+    def initialize(num)
+      @num = num
+    end
+
+    attr_accessor :num
+
+    # Reverse comparison
+    def <=>(other)
+      other.num <=> @num
+    end
+  end
+  
+  class ComparableWithFixnum
+    include Comparable
+    def initialize(num)
+      @num = num
+    end
+
+    def <=>(fixnum)
+      @num <=> fixnum
+    end
+  end
+
 end # EnumerableSpecs utility classes

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/group_by_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/group_by_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/group_by_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,19 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Enumerable#group_by" do
+  ruby_version_is "1.8.7" do
+    it "returns a hash with values grouped according to the block" do
+      EnumerableSpecs::Numerous.new(*%w(foo bar baz)).group_by{ |word| word[0..0].to_sym }.
+        should == { :f => ["foo"], :b => ["bar", "baz"]}
+    end
+
+    it "returns an empty hash for empty enumerables" do
+      EnumerableSpecs::Empty.new.group_by { |x| x}.should == {}
+    end
+  
+    it "returns an Enumerator if called without a block" do
+      EnumerableSpecs::Numerous.new.group_by.should be_kind_of(enumerator_class)
+    end
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/enumerable/inject_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/inject_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/inject_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,58 +1,7 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/inject'
 
-describe "Enumerable#inject" do  
-  it "inject with argument takes a block with an accumulator (with argument as initial value) and the current element. Value of block becomes new accumulator" do
-    a = []
-    EnumerableSpecs::Numerous.new.inject(0) { |memo, i| a << [memo, i]; i }
-    a.should == [[0, 2], [2, 5], [5, 3], [3, 6], [6, 1], [1, 4]]
-    EnumerableSpecs::EachDefiner.new(true, true, true).inject(nil) {|result, i| i && result}.should == nil
-  end
-
-  it "produces an array of the accumulator and the argument when given a block with a *arg" do
-    a = []
-    [1,2].inject(0) {|*args| a << args; args[0] + args[1]}
-    a.should == [[0, 1], [1, 2]]
-  end
-  
-  it "only takes one argument" do
-    lambda { EnumerableSpecs::Numerous.new.inject(0, 1) { |memo, i| i } }.should raise_error(ArgumentError)
-  end
-    
-  it "inject without argument takes a block with an accumulator (with first element as initial value) and the current element. Value of block becomes new accumulator" do
-    a = []
-    EnumerableSpecs::Numerous.new.inject { |memo, i| a << [memo, i]; i }
-    a.should == [[2, 5], [5, 3], [3, 6], [6, 1], [1, 4]]
-  end  
-  
-  it "inject with inject arguments(legacy rubycon)" do
-    # with inject argument
-    EnumerableSpecs::EachDefiner.new().inject(1) {|acc,x| 999 }.should == 1
-    EnumerableSpecs::EachDefiner.new(2).inject(1) {|acc,x| 999 }.should ==  999
-    EnumerableSpecs::EachDefiner.new(2).inject(1) {|acc,x| acc }.should == 1
-    EnumerableSpecs::EachDefiner.new(2).inject(1) {|acc,x| x }.should == 2
-
-    EnumerableSpecs::EachDefiner.new(1,2,3,4).inject(100) {|acc,x| acc + x }.should == 110
-    EnumerableSpecs::EachDefiner.new(1,2,3,4).inject(100) {|acc,x| acc * x }.should == 2400
-
-    EnumerableSpecs::EachDefiner.new('a','b','c').inject("z") {|result, i| i+result}.should == "cbaz"
-  end
-  
-  it "inject withou inject arguments(legacy rubycon)" do
-    # no inject argument
-    EnumerableSpecs::EachDefiner.new(2).inject {|acc,x| 999 } .should == 2
-    EnumerableSpecs::EachDefiner.new(2).inject {|acc,x| acc }.should == 2
-    EnumerableSpecs::EachDefiner.new(2).inject {|acc,x| x }.should == 2
-
-    EnumerableSpecs::EachDefiner.new(1,2,3,4).inject {|acc,x| acc + x }.should == 10
-    EnumerableSpecs::EachDefiner.new(1,2,3,4).inject {|acc,x| acc * x }.should == 24
-
-    EnumerableSpecs::EachDefiner.new('a','b','c').inject {|result, i| i+result}.should == "cba"
-    EnumerableSpecs::EachDefiner.new(3, 4, 5).inject {|result, i| result*i}.should == 60
-    EnumerableSpecs::EachDefiner.new([1], 2, 'a','b').inject{|r,i| r<<i}.should == [1, 2, 'a', 'b']
-
-  end
-  it "return nil when fails(legacy rubycon)" do
-    EnumerableSpecs::EachDefiner.new().inject {|acc,x| 999 }.should == nil 
-  end
-end
+describe "Enumerable#inject" do
+  it_behaves_like :enumerable_inject, :inject
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/max_by_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/max_by_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/max_by_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,38 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Enumerable#max_by" do
+  ruby_version_is '1.8.7' do
+    it "returns an enumerator if no block" do
+      EnumerableSpecs::Numerous.new(42).max_by.should be_kind_of(enumerator_class)
+    end
+
+    it "returns nil if #each yields no objects" do
+      EnumerableSpecs::Empty.new.max_by {|o| o.nonesuch }.should == nil
+    end
+
+
+    it "returns the object for whom the value returned by block is the largest" do
+      EnumerableSpecs::Numerous.new(*%w[1 2 3]).max_by {|obj| obj.to_i }.should == '3'
+      EnumerableSpecs::Numerous.new(*%w[three five]).max_by {|obj| obj.length }.should == 'three'
+    end
+
+    it "returns the object that appears first in #each in case of a tie" do
+      a, b, c = '1', '2', '2'
+      EnumerableSpecs::Numerous.new(a, b, c).max_by {|obj| obj.to_i }.should equal(b)
+    end
+
+    it "uses max.<=>(current) to determine order" do
+      a, b, c = (1..3).map{|n| EnumerableSpecs::ReverseComparable.new(n)}
+
+      # Just using self here to avoid additional complexity
+      EnumerableSpecs::Numerous.new(a, b, c).max_by {|obj| obj }.should == a
+    end
+
+    it "is able to return the maximum for enums that contain nils" do
+      enum = EnumerableSpecs::Numerous.new(nil, nil, true)
+      enum.max_by {|o| o.nil? ? 0 : 1 }.should == true
+      enum.max_by {|o| o.nil? ? 1 : 0 }.should == nil
+    end
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/min_by_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/min_by_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/min_by_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,38 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Enumerable#min_by" do
+  ruby_version_is '1.8.7' do
+    it "returns an enumerator if no block" do
+      EnumerableSpecs::Numerous.new(42).min_by.should be_kind_of(enumerator_class)
+    end
+
+    it "returns nil if #each yields no objects" do
+      EnumerableSpecs::Empty.new.min_by {|o| o.nonesuch }.should == nil
+    end
+
+
+    it "returns the object for whom the value returned by block is the largest" do
+      EnumerableSpecs::Numerous.new(*%w[3 2 1]).min_by {|obj| obj.to_i }.should == '1'
+      EnumerableSpecs::Numerous.new(*%w[five three]).min_by {|obj| obj.length }.should == 'five'
+    end
+
+    it "returns the object that appears first in #each in case of a tie" do
+      a, b, c = '2', '1', '1'
+      EnumerableSpecs::Numerous.new(a, b, c).min_by {|obj| obj.to_i }.should equal(b)
+    end
+
+    it "uses min.<=>(current) to determine order" do
+      a, b, c = (1..3).map{|n| EnumerableSpecs::ReverseComparable.new(n)}
+
+      # Just using self here to avoid additional complexity
+      EnumerableSpecs::Numerous.new(a, b, c).min_by {|obj| obj }.should == c
+    end
+
+    it "is able to return the maximum for enums that contain nils" do
+      enum = EnumerableSpecs::Numerous.new(nil, nil, true)
+      enum.min_by {|o| o.nil? ? 0 : 1 }.should == nil
+      enum.min_by {|o| o.nil? ? 1 : 0 }.should == true
+    end
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/minmax_by_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/minmax_by_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/minmax_by_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,38 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Enumerable#minmax_by" do
+  ruby_version_is '1.8.7' do
+    it "returns an enumerator if no block" do
+      EnumerableSpecs::Numerous.new(42).minmax_by.should be_kind_of(enumerator_class)
+    end
+
+    it "returns nil if #each yields no objects" do
+      EnumerableSpecs::Empty.new.minmax_by {|o| o.nonesuch }.should == [nil, nil]
+    end
+
+    it "returns the object for whom the value returned by block is the largest" do
+      EnumerableSpecs::Numerous.new(*%w[1 2 3]).minmax_by {|obj| obj.to_i }.should == ['1', '3']
+      EnumerableSpecs::Numerous.new(*%w[three five]).minmax_by {|obj| obj.length }.should == ['five', 'three']
+    end
+
+    it "returns the object that appears first in #each in case of a tie" do
+      a, b, c, d = '1', '1', '2', '2'
+      mm = EnumerableSpecs::Numerous.new(a, b, c, d).minmax_by {|obj| obj.to_i }
+      mm[0].should equal(a)
+      mm[1].should equal(c)
+    end
+
+    it "uses min/max.<=>(current) to determine order" do
+      a, b, c = (1..3).map{|n| EnumerableSpecs::ReverseComparable.new(n)}
+
+      # Just using self here to avoid additional complexity
+      EnumerableSpecs::Numerous.new(a, b, c).minmax_by {|obj| obj }.should == [c, a]
+    end
+
+    it "is able to return the maximum for enums that contain nils" do
+      enum = EnumerableSpecs::Numerous.new(nil, nil, true)
+      enum.minmax_by {|o| o.nil? ? 0 : 1 }.should == [nil, true]
+    end
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/minmax_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/minmax_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/minmax_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,35 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Enumerable#minmax" do
+  ruby_version_is '1.8.7' do
+    before :each do
+      @enum = EnumerableSpecs::Numerous.new(6, 4, 5, 10, 8)
+
+      @strs = EnumerableSpecs::Numerous.new("333", "2", "60", "55555", "1010", "111")
+    end
+
+    it "min should return the minimum element" do
+      @enum.minmax.should == [4, 10]
+      @strs.minmax.should == ["1010", "60" ]
+    end
+
+    it "return nil when error" do
+      EnumerableSpecs::Empty.new.minmax.should == [nil, nil]
+      lambda {
+        EnumerableSpecs::Numerous.new(Object.new, Object.new).minmax
+      }.should raise_error(NoMethodError)
+      lambda {
+        EnumerableSpecs::Numerous.new(11,"22").minmax
+      }.should raise_error(ArgumentError)
+      lambda {
+        EnumerableSpecs::Numerous.new(11,12,22,33).minmax{|a, b| nil}
+      }.should raise_error(ArgumentError)
+    end
+
+    it "return the minimun when using a block rule" do
+      @enum.minmax {|a,b| b <=> a }.should == [10, 4]
+      @strs.minmax {|a,b| a.length <=> b.length }.should == ["2", "55555"]
+    end
+  end
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/enumerable/partition_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/partition_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/partition_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -14,7 +14,7 @@
 
   ruby_version_is "1.8.7" do
     it "returns an Enumerator if called without a block" do
-      EnumerableSpecs::Numerous.new.partition.should be_kind_of(Enumerable::Enumerator)
+      EnumerableSpecs::Numerous.new.partition.should be_kind_of(enumerator_class)
     end
   end
 end

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/reduce_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/reduce_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/reduce_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,9 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/inject'
+
+describe "Enumerable#reduce" do
+  ruby_version_is '1.8.7' do
+    it_behaves_like :enumerable_inject, :reduce
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/enumerable/reject_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/reject_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/reject_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -19,7 +19,7 @@
 
   ruby_version_is "1.8.7" do
     it "returns an Enumerator if called without a block" do
-      EnumerableSpecs::Numerous.new.reject.should be_kind_of(Enumerable::Enumerator)
+      EnumerableSpecs::Numerous.new.reject.should be_kind_of(enumerator_class)
     end
   end
 end

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/reverse_each_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/reverse_each_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/reverse_each_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,19 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+ruby_version_is '1.8.7' do
+  describe "Enumerable#reverse_each" do
+
+    it "traverses enum in reverse order and pass each element to block" do
+      a=[]
+      EnumerableSpecs::Numerous.new.reverse_each { |i| a << i }
+      a.should == [4, 1, 6, 3, 5, 2]
+    end
+
+    it 'returns an Enumerator if no block given' do
+      enum = EnumerableSpecs::Numerous.new.reverse_each
+      enum.should be_kind_of(enumerator_class)
+      enum.to_a.should == [4, 1, 6, 3, 5, 2]
+    end
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/collect.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/collect.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/collect.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -5,4 +5,33 @@
     numerous.send(@method) { |i| i % 2 }.should == [0, 1, 1, 0, 1, 0]
     numerous.send(@method) { |i| i }.should == entries
   end 
+
+  ruby_version_is "" ... "1.9" do
+    it "gathers whole arrays as elements when each yields multiple" do
+      multi = EnumerableSpecs::YieldsMulti.new
+      multi.send(@method) {|e| e}.should == [[1,2],[3,4,5],[6,7,8,9]]
+    end
+  end
+
+  ruby_version_is "1.9" do
+    it "gathers initial args as elements when each yields multiple" do
+      multi = EnumerableSpecs::YieldsMulti.new
+      multi.send(@method) {|e| e}.should == [1,3,6]
+    end
+  end
+
+  ruby_version_is "" ... "1.9" do
+    it "returns to_a when no block given" do
+      EnumerableSpecs::Numerous.new.send(@method).should == [2, 5, 3, 6, 1, 4]
+    end
+  end
+  ruby_version_is "1.9" do
+    it "returns an enumerator when no block given" do
+      enum = EnumerableSpecs::Numerous.new.send(@method)
+      enum.should be_kind_of(enumerator_class)
+      enum.each { |i| -i }.should == [-2, -5, -3, -6, -1, -4]
+    end
+  end
+
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/entries.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/entries.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/entries.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,15 +1,14 @@
 describe :enumerable_entries, :shared => true do
-  before :each do
-    @entries = [2, 4, 6, 8, 10]
-    @numerous = EnumerableSpecs::Numerous.new(*@entries)
-  end
-  
-  it "returns an array containing the items in enum." do
-    @numerous.send(@method).should == @entries
-  end
-
   it "returns an array containing the elements" do
     numerous = EnumerableSpecs::Numerous.new(1, nil, 'a', 2, false, true)
     numerous.send(@method).should == [1, nil, "a", 2, false, true]
   end
+  
+  ruby_version_is '1.8.7' do
+    it "passes arguments to each" do
+      count = EnumerableSpecs::EachCounter.new(1, 2, 3)
+      count.to_a(:hello, "world").should == [1, 2, 3]
+      count.arguments_passed.should == [:hello, "world"]
+    end
+  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/find.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/find.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/find.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -39,4 +39,22 @@
     fail_proc = lambda { times += 1; raise if times > 1; "cheeseburgers" }
     @numerous.send(@method, fail_proc) {|e| false }.should == "cheeseburgers"
   end
+  
+  ruby_version_is "" ... "1.8.7" do
+    it "raises a LocalJumpError if no block given" do
+      lambda { @numerous.send(@method) }.should raise_error(LocalJumpError)
+    end
+  end
+  ruby_version_is "1.8.7" do
+    it "returns an enumerator when no block given" do
+      @numerous.send(@method).should be_kind_of(enumerator_class)
+    end
+    
+    it "passes the ifnone proc to the enumerator" do
+      times = 0
+      fail_proc = lambda { times += 1; raise if times > 1; "cheeseburgers" }
+      @numerous.send(@method, fail_proc).each {|e| false }.should == "cheeseburgers"
+    end
+  end
+  
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/find_all.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/find_all.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/find_all.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,9 +1,24 @@
 describe :enumerable_find_all, :shared => true do
+  before :each do
+    @elements = (1..10).to_a
+    @numerous = EnumerableSpecs::Numerous.new(*@elements)
+  end
+
   it "returns all elements for which the block is not false" do
-    entries = (1..10).to_a
-    numerous = EnumerableSpecs::Numerous.new(*entries)
-    numerous.send(@method) {|i| i % 3 == 0 }.should == [3, 6, 9]
-    numerous.send(@method) {|i| true }.should == (1..10).to_a
-    numerous.send(@method) {|i| false }.should == []
+    @numerous.send(@method) {|i| i % 3 == 0 }.should == [3, 6, 9]
+    @numerous.send(@method) {|i| true }.should == @elements
+    @numerous.send(@method) {|i| false }.should == []
   end
+  
+  ruby_version_is "" ... "1.8.7" do
+    it "raises a LocalJumpError if no block given" do
+      lambda { @numerous.send(@method) }.should raise_error(LocalJumpError)
+    end
+  end
+  ruby_version_is "1.8.7" do
+    it "returns an enumerator when no block given" do
+      @numerous.send(@method).should be_kind_of(enumerator_class)
+    end
+  end
+  
 end

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/inject.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/inject.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/inject.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,72 @@
+describe :enumerable_inject, :shared => true do
+  it "with argument takes a block with an accumulator (with argument as initial value) and the current element. Value of block becomes new accumulator" do
+    a = []
+    EnumerableSpecs::Numerous.new.send(@method, 0) { |memo, i| a << [memo, i]; i }
+    a.should == [[0, 2], [2, 5], [5, 3], [3, 6], [6, 1], [1, 4]]
+    EnumerableSpecs::EachDefiner.new(true, true, true).send(@method, nil) {|result, i| i && result}.should == nil
+  end
+
+  it "produces an array of the accumulator and the argument when given a block with a *arg" do
+    a = []
+    [1,2].send(@method, 0) {|*args| a << args; args[0] + args[1]}
+    a.should == [[0, 1], [1, 2]]
+  end
+  
+  ruby_version_is ''...'1.8.7' do
+    it "takes only one argument" do
+      lambda { EnumerableSpecs::Numerous.new.send(@method, 0, 1) { |memo, i| i } }.should raise_error(ArgumentError)
+    end
+  end
+  
+  ruby_version_is '1.8.7' do
+    it "can take two argument" do
+      EnumerableSpecs::Numerous.new(1, 2, 3).send(@method, 10, :-).should == 4
+    end
+
+    it "ignores the block if two arguments" do
+      EnumerableSpecs::Numerous.new(1, 2, 3).send(@method, 10, :-){ raise "we never get here"}.should == 4
+    end
+
+    it "can take a symbol argument" do
+      EnumerableSpecs::Numerous.new(10, 1, 2, 3).send(@method, :-).should == 4
+    end
+  end
+  
+  it "without argument takes a block with an accumulator (with first element as initial value) and the current element. Value of block becomes new accumulator" do
+    a = []
+    EnumerableSpecs::Numerous.new.send(@method) { |memo, i| a << [memo, i]; i }
+    a.should == [[2, 5], [5, 3], [3, 6], [6, 1], [1, 4]]
+  end  
+  
+  it "with inject arguments(legacy rubycon)" do
+    # with inject argument
+    EnumerableSpecs::EachDefiner.new().send(@method, 1) {|acc,x| 999 }.should == 1
+    EnumerableSpecs::EachDefiner.new(2).send(@method, 1) {|acc,x| 999 }.should ==  999
+    EnumerableSpecs::EachDefiner.new(2).send(@method, 1) {|acc,x| acc }.should == 1
+    EnumerableSpecs::EachDefiner.new(2).send(@method, 1) {|acc,x| x }.should == 2
+
+    EnumerableSpecs::EachDefiner.new(1,2,3,4).send(@method, 100) {|acc,x| acc + x }.should == 110
+    EnumerableSpecs::EachDefiner.new(1,2,3,4).send(@method, 100) {|acc,x| acc * x }.should == 2400
+
+    EnumerableSpecs::EachDefiner.new('a','b','c').send(@method, "z") {|result, i| i+result}.should == "cbaz"
+  end
+  
+  it "without inject arguments(legacy rubycon)" do
+    # no inject argument
+    EnumerableSpecs::EachDefiner.new(2).send(@method) {|acc,x| 999 } .should == 2
+    EnumerableSpecs::EachDefiner.new(2).send(@method) {|acc,x| acc }.should == 2
+    EnumerableSpecs::EachDefiner.new(2).send(@method) {|acc,x| x }.should == 2
+
+    EnumerableSpecs::EachDefiner.new(1,2,3,4).send(@method) {|acc,x| acc + x }.should == 10
+    EnumerableSpecs::EachDefiner.new(1,2,3,4).send(@method) {|acc,x| acc * x }.should == 24
+
+    EnumerableSpecs::EachDefiner.new('a','b','c').send(@method) {|result, i| i+result}.should == "cba"
+    EnumerableSpecs::EachDefiner.new(3, 4, 5).send(@method) {|result, i| result*i}.should == 60
+    EnumerableSpecs::EachDefiner.new([1], 2, 'a','b').send(@method){|r,i| r<<i}.should == [1, 2, 'a', 'b']
+
+  end
+
+  it "returns nil when fails(legacy rubycon)" do
+    EnumerableSpecs::EachDefiner.new().send(@method) {|acc,x| 999 }.should == nil 
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/take.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/take.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/shared/take.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,50 @@
+describe :enumerable_take, :shared => true do
+  before :each do
+    @values = [4,3,2,1]
+    @enum = EnumerableSpecs::Numerous.new(*@values)
+  end
+
+  ruby_version_is '1.8.7' do
+    it "returns the first count elements if given a count" do
+      @enum.send(@method, 2).should == [4, 3]
+    end
+
+    it "returns an empty array when passed count on an empty array" do
+      empty = EnumerableSpecs::Empty.new
+      empty.send(@method, 0).should == []
+      empty.send(@method, 1).should == []
+      empty.send(@method, 2).should == []
+    end
+
+    it "returns an empty array when passed count == 0" do
+      @enum.send(@method, 0).should == []
+    end
+
+    it "returns an array containing the first element when passed count == 1" do
+      @enum.send(@method, 1).should == [4]
+    end
+
+    it "raises an ArgumentError when count is negative" do
+      lambda { @enum.send(@method, -1) }.should raise_error(ArgumentError)
+    end
+
+    it "returns the entire array when count > length" do
+      @enum.send(@method, 10).should == @values
+    end
+
+    it "tries to convert the passed argument to an Integer using #to_int" do
+      obj = mock('to_int')
+      obj.should_receive(:to_int).and_return(3).at_most(:twice) # called twice, no apparent reason. should we care?
+      @enum.send(@method, obj).should == [4, 3, 2]
+    end
+
+    it "raises a TypeError if the passed argument is not numeric" do
+      lambda { @enum.send(@method, nil) }.should raise_error(TypeError)
+      lambda { @enum.send(@method, "a") }.should raise_error(TypeError)
+
+      obj = mock("nonnumeric")
+      lambda { @enum.send(@method, obj) }.should raise_error(TypeError)
+    end
+
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/enumerable/sort_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/sort_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/sort_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -27,5 +27,16 @@
       x <=> y
     }.should == [true, true, nil, nil, nil, nil, nil, false, false]
   end
+  
+  it "compare values returned by block with 0" do
+    EnumerableSpecs::Numerous.new.sort { |n, m| -(n+m) * (n <=> m) }.should == [6, 5, 4, 3, 2, 1]
+    EnumerableSpecs::Numerous.new.sort { |n, m|
+      EnumerableSpecs::ComparableWithFixnum.new(-(n+m) * (n <=> m))
+    }.should == [6, 5, 4, 3, 2, 1]
+    lambda {
+      EnumerableSpecs::Numerous.new.sort { |n, m| (n <=> m).to_s }
+    }.should raise_error(ArgumentError)
+  end
+  
 end
 

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/take_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/take_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/take_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,15 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/take'
+
+describe "Enumerable#take" do
+  ruby_version_is '1.8.7' do
+    it "requires an argument" do
+      lambda{ EnumerableSpecs::Numerous.new.take}.should raise_error(ArgumentError)
+    end
+    
+    describe "when passed an argument" do
+      it_behaves_like :enumerable_take, :take
+    end
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/core/enumerable/take_while_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/take_while_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/take_while_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,44 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Enumerable#take_while" do
+  ruby_version_is '1.8.7' do
+    before :each do
+      @enum = EnumerableSpecs::Numerous.new(3, 2, 1, :go)
+    end
+
+    it 'returns an Enumerator if no block given' do
+      @enum.take_while.should be_kind_of(enumerator_class)
+    end
+
+    it "returns no/all elements for {true/false} block" do
+      @enum.take_while{true}.should == @enum.to_a
+      @enum.take_while{false}.should == []
+    end
+
+    it "accepts returns other than true/false" do
+      @enum.take_while{1}.should == @enum.to_a
+      @enum.take_while{nil}.should == []
+    end
+
+    it "passes elements to the block until the first false" do
+      a = []
+      @enum.take_while{|obj| (a << obj).size < 3}.should == [3, 2]
+      a.should == [3, 2, 1]
+    end
+
+    it "will only go through what's needed" do
+      enum = EnumerableSpecs::EachCounter.new(4, 3, 2, 1, :stop)
+      enum.take_while { |x|
+        break 42 if x == 3
+        true
+      }.should == 42
+      enum.times_yielded.should == 2
+    end
+
+    it "doesn't return self when it could" do
+      a = [1,2,3]
+      a.take_while{true}.should_not equal(a)
+    end
+  end
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/enumerable/zip_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/enumerable/zip_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/enumerable/zip_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -20,11 +20,21 @@
     EnumerableSpecs::Numerous.new(1,2,3).zip([4,5,6], [7,8]).should == [[1,4,7],[2,5,8],[3,6,nil]]
   end
   
-  it "converts arguments to arrays using #to_a" do
-    convertable = EnumerableSpecs::ArrayConvertable.new(4,5,6)
-    EnumerableSpecs::Numerous.new(1,2,3).zip(convertable).should == [[1,4],[2,5],[3,6]]
-    convertable.called.should == :to_a
+  ruby_version_is ''...'1.9' do
+    it "converts arguments to arrays using #to_a" do
+      convertable = EnumerableSpecs::ArrayConvertable.new(4,5,6)
+      EnumerableSpecs::Numerous.new(1,2,3).zip(convertable).should == [[1,4],[2,5],[3,6]]
+      convertable.called.should == :to_a
+    end
   end
-
+  
+  ruby_version_is '1.9' do
+    it "converts arguments to arrays using #to_ary" do
+      convertable = EnumerableSpecs::ArrayConvertable.new(4,5,6)
+      EnumerableSpecs::Numerous.new(1,2,3).zip(convertable).should == [[1,4],[2,5],[3,6]]
+      convertable.called.should == :to_ary
+    end
+  end
+  
 end
 

Modified: MacRuby/branches/experimental/spec/frozen/core/env/delete_if_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/env/delete_if_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/env/delete_if_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -20,7 +20,7 @@
 
   ruby_version_is "1.8.7" do
     it "returns an Enumerator if no block given" do
-      ENV.delete_if.should be_kind_of(Enumerable::Enumerator)
+      ENV.delete_if.should be_kind_of(enumerator_class)
     end
   end
 

Modified: MacRuby/branches/experimental/spec/frozen/core/env/each_key_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/env/each_key_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/env/each_key_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -25,7 +25,7 @@
 
   ruby_version_is "1.8.7" do
     it "returns an Enumerator if called without a block" do
-      ENV.each_key.should be_kind_of(Enumerable::Enumerator)
+      ENV.each_key.should be_kind_of(enumerator_class)
     end
   end
 

Modified: MacRuby/branches/experimental/spec/frozen/core/env/each_value_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/env/each_value_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/env/each_value_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -25,7 +25,7 @@
 
   ruby_version_is "1.8.7" do
     it "returns an Enumerator if called without a block" do
-      ENV.each_value.should be_kind_of(Enumerable::Enumerator)
+      ENV.each_value.should be_kind_of(enumerator_class)
     end
   end
 

Modified: MacRuby/branches/experimental/spec/frozen/core/env/reject_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/env/reject_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/env/reject_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -28,7 +28,7 @@
 
   ruby_version_is "1.8.7" do
     it "returns an Enumerator if called without a block" do
-      ENV.reject!.should be_kind_of(Enumerable::Enumerator)
+      ENV.reject!.should be_kind_of(enumerator_class)
     end
   end
 
@@ -72,7 +72,7 @@
 
   ruby_version_is "1.8.7" do
     it "returns an Enumerator if called without a block" do
-      ENV.reject.should be_kind_of(Enumerable::Enumerator)
+      ENV.reject.should be_kind_of(enumerator_class)
     end
   end
 

Modified: MacRuby/branches/experimental/spec/frozen/core/env/select_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/env/select_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/env/select_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -16,7 +16,7 @@
 
   ruby_version_is "1.8.7" do
     it "returns an Enumerator when no block is given" do
-      ENV.select.should be_kind_of(Enumerable::Enumerator)
+      ENV.select.should be_kind_of(enumerator_class)
     end
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/env/shared/each.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/env/shared/each.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/env/shared/each.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -22,7 +22,7 @@
 
   ruby_version_is "1.8.7" do
     it "returns an Enumerator if called without a block" do
-      ENV.send(@method).should be_kind_of(Enumerable::Enumerator)
+      ENV.send(@method).should be_kind_of(enumerator_class)
     end
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/exception/fixtures/common.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/exception/fixtures/common.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/exception/fixtures/common.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -12,3 +12,7 @@
 
   class NoMethodErrorD; end
 end
+
+module ExceptionSpecs
+  class Exceptional < Exception; end
+end  

Added: MacRuby/branches/experimental/spec/frozen/core/exception/shared/to_s.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/exception/shared/to_s.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/exception/shared/to_s.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../fixtures/common'
+
+describe :to_s, :shared => true do
+
+  it "returns the self's name if no message is set" do
+    Exception.new.send(@method).should == 'Exception'
+    ExceptionSpecs::Exceptional.new.send(@method).should == 'ExceptionSpecs::Exceptional'
+  end
+
+  it "returns self's message if set" do  
+    ExceptionSpecs::Exceptional.new('!!').send(@method).should == '!!'
+  end
+
+end  

Modified: MacRuby/branches/experimental/spec/frozen/core/exception/to_s_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/exception/to_s_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/exception/to_s_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1 +1,6 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/to_s'
+
+describe "Exception#to_s" do
+  it_behaves_like :to_s, :to_s
+end  

Modified: MacRuby/branches/experimental/spec/frozen/core/exception/to_str_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/exception/to_str_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/exception/to_str_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1 +1,17 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/to_s'
+
+ruby_version_is ""..."1.9" do
+  describe "Exception#to_str" do
+    it_behaves_like :to_s, :to_str
+  end  
+end
+
+ruby_version_is "1.9" do
+  describe "Exception#to_str" do
+    it "has been deprecated" do
+      Exception.new.should_not respond_to(:to_str)
+    end 
+  end  
+end
+

Modified: MacRuby/branches/experimental/spec/frozen/core/file/stat/comparison_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/file/stat/comparison_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/file/stat/comparison_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -11,8 +11,8 @@
   after :each do
     @file1.close unless @file1.closed?
     @file2.close unless @file2.closed?
-    File.delete @name1
-    File.delete @name2
+    File.delete @name1 if File.exists? @name1
+    File.delete @name2 if File.exists? @name2
   end
 
   it "is able to compare files by the same modification times" do

Modified: MacRuby/branches/experimental/spec/frozen/core/file/symlink_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/file/symlink_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/file/symlink_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -48,4 +48,5 @@
 
 describe "File.symlink?" do
   it_behaves_like :file_symlink, :symlink?, File
+  it_behaves_like :file_symlink_nonexistent, :symlink?, File
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/filetest/symlink_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/filetest/symlink_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/filetest/symlink_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,4 +3,5 @@
 
 describe "FileTest.symlink?" do
   it_behaves_like :file_symlink, :symlink?, FileTest
+  it_behaves_like :file_symlink_nonexistent, :symlink?, File
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/float/to_s_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/float/to_s_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/float/to_s_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -7,16 +7,28 @@
     0.0.to_s.should == "0.0"
     1000000000000.to_f.to_s.should == "1000000000000.0"
     10000000000000.to_f.to_s.should == "10000000000000.0"
-    100000000000000.to_f.to_s.should == "1.0e+14"
     -10000000000000.to_f.to_s.should == "-10000000000000.0"
-    -100000000000000.to_f.to_s.should == "-1.0e+14"
     1.87687113714737e-40.to_s.should == "1.87687113714737e-40"
     (0.0 / 0.0).to_s.should == "NaN"
     (1.0 / 0.0).to_s.should == "Infinity"
     (-1.0 / 0.0).to_s.should == "-Infinity"
     1.50505000e-20.to_s.should == "1.50505e-20"
   end
-  
+
+  ruby_version_is "" ... "1.9" do
+    it "returns a string representation of self" do
+      100000000000000.to_f.to_s.should == "1.0e+14"
+      -100000000000000.to_f.to_s.should == "-1.0e+14"
+    end
+  end
+
+  ruby_version_is "1.9" do
+    it "returns a string representation of self" do
+      100000000000000.to_f.to_s.should == "100000000000000.0"
+      -100000000000000.to_f.to_s.should == "-100000000000000.0"
+    end
+  end
+
   platform_is_not :openbsd do
     it "returns the correct values for -0.0" do
       -0.0.to_s.should == "-0.0"

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/allocate_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/allocate_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/allocate_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,12 +2,12 @@
 
 describe "Hash.allocate" do
   it "returns an instance of Hash" do
-    hsh = Hash.allocate
+    hsh = hash_class.allocate
     hsh.should be_kind_of(Hash)
   end
   
   it "returns a fully-formed instance of Hash" do
-    hsh = Hash.allocate
+    hsh = hash_class.allocate
     hsh.size.should == 0
     hsh[:a] = 1
     hsh.should == { :a => 1 }

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/clear_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/clear_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/clear_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,24 +3,24 @@
 
 describe "Hash#clear" do
   it "removes all key, value pairs" do
-    h = { 1 => 2, 3 => 4 }
+    h = new_hash(1 => 2, 3 => 4)
     h.clear.should equal(h)
-    h.should == {}
+    h.should == new_hash
   end
 
   it "does not remove default values" do
-    h = Hash.new(5)
+    h = new_hash 5
     h.clear
     h.default.should == 5
 
-    h = { "a" => 100, "b" => 200 }
+    h = new_hash("a" => 100, "b" => 200)
     h.default = "Go fish"
     h.clear
     h["z"].should == "Go fish"
   end
 
   it "does not remove default procs" do
-    h = Hash.new { 5 }
+    h = new_hash { 5 }
     h.clear
     h.default_proc.should_not == nil
   end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/clone_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/clone_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/clone_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,7 +2,7 @@
 
 describe "Hash#clone" do
   it "copies instance variable but not the objects they refer to" do
-    hash = { 'key' => 'value' }
+    hash = new_hash('key' => 'value')
 
     clone = hash.clone
 

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/constructor_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/constructor_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/constructor_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,33 +1,46 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
 
 describe "Hash.[]" do
   it "creates a Hash; values can be provided as the argument list" do
-    Hash[:a, 1, :b, 2].should == {:a => 1, :b => 2}
-    Hash[].should == {}
-    Hash[:a, 1, :b, {:c => 2}].should == {:a => 1, :b => {:c => 2}}
+    hash_class[:a, 1, :b, 2].should == new_hash(:a => 1, :b => 2)
+    hash_class[].should == new_hash
+    hash_class[:a, 1, :b, new_hash(:c => 2)].should ==
+      new_hash(:a => 1, :b => new_hash(:c => 2))
   end
 
   it "creates a Hash; values can be provided as one single hash" do
-    Hash[:a => 1, :b => 2].should == {:a => 1, :b => 2}
-    Hash[{1 => 2, 3 => 4}].should == {1 => 2, 3 => 4}
-    Hash[{}].should == {}
+    hash_class[:a => 1, :b => 2].should == new_hash(:a => 1, :b => 2)
+    hash_class[new_hash(1 => 2, 3 => 4)].should == new_hash(1 => 2, 3 => 4)
+    hash_class[new_hash].should == new_hash
   end
 
+  ruby_version_is '1.8.7' do
+    # Not officially documented yet, see http://redmine.ruby-lang.org/issues/show/1385
+    it "creates a Hash; values can be provided as a list of value-pairs in an array" do
+      hash_class[[[:a, 1], [:b, 2]]].should == new_hash(:a => 1, :b => 2)
+      hash_class[[[:a, 1], [:b], 42, [:d, 2], [:e, 2, 3], []]].should == new_hash(:a => 1, :b => nil, :d => 2)
+      obj = mock('x')
+      def obj.to_ary() [:b, 2] end
+      hash_class[[[:a, 1], obj]].should == new_hash(:a => 1, :b => 2)
+    end
+  end
+  
   it "raises an ArgumentError when passed an odd number of arguments" do
-    lambda { Hash[1, 2, 3] }.should raise_error(ArgumentError)
-    lambda { Hash[1, 2, {3 => 4}] }.should raise_error(ArgumentError)
+    lambda { hash_class[1, 2, 3] }.should raise_error(ArgumentError)
+    lambda { hash_class[1, 2, new_hash(3 => 4)] }.should raise_error(ArgumentError)
   end
 
-  ruby_bug "#", "1.8.6" do
-    it "call to_hash" do
+  ruby_version_is '1.8.7' do
+    it "calls to_hash" do
       obj = mock('x')
-      def obj.to_hash() { 1 => 2, 3 => 4 } end
-      Hash[obj].should == { 1 => 2, 3 => 4 }
+      def obj.to_hash() new_hash(1 => 2, 3 => 4) end
+      hash_class[obj].should == new_hash(1 => 2, 3 => 4)
     end
   end
 
   it "returns an instance of the class it's called on" do
-    Hash[MyHash[1, 2]].class.should == Hash
-    MyHash[Hash[1, 2]].class.should == MyHash
+    hash_class[MyHash[1, 2]].class.should == hash_class
+    MyHash[hash_class[1, 2]].class.should == MyHash
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/default_proc_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/default_proc_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/default_proc_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,12 +3,43 @@
 
 describe "Hash#default_proc" do
   it "returns the block passed to Hash.new" do
-    h = Hash.new { |i| 'Paris' }
+    h = new_hash { |i| 'Paris' }
     p = h.default_proc
     p.call(1).should == 'Paris'
   end
-  
+
   it "returns nil if no block was passed to proc" do
-    Hash.new.default_proc.should == nil
+    new_hash.default_proc.should == nil
   end
 end
+
+describe "Hash#default_proc=" do
+  ruby_version_is "1.9" do
+    it "replaces the block passed to Hash.new" do
+      h = new_hash { |i| 'Paris' }
+      h.default_proc = Proc.new { 'Montreal' }
+      p = h.default_proc
+      p.call(1).should == 'Montreal'
+    end
+
+    it "uses :to_proc on its argument" do
+      h = new_hash { |i| 'Paris' }
+      obj = mock('to_proc')
+      obj.should_receive(:to_proc).and_return(Proc.new { 'Montreal' })
+      (h.default_proc = obj).should equal(obj)
+      h[:cool_city].should == 'Montreal'
+    end
+
+    it "overrides the static default" do
+      h = new_hash(42)
+      h.default_proc = Proc.new { 6 }
+      h.default.should be_nil
+      h.default_proc.call.should == 6
+    end
+
+    it "raise an error if passed stuff not convertible to procs" do
+      lambda{new_hash.default_proc = nil}.should raise_error(TypeError)
+      lambda{new_hash.default_proc = 42}.should raise_error(TypeError)
+    end
+  end
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/default_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/default_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/default_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,35 +3,35 @@
 
 describe "Hash#default" do
   it "returns the default value" do
-    h = Hash.new(5)
+    h = new_hash 5
     h.default.should == 5
     h.default(4).should == 5
-    {}.default.should == nil
-    {}.default(4).should == nil
+    new_hash.default.should == nil
+    new_hash.default(4).should == nil
   end
 
   it "uses the default proc to compute a default value, passing given key" do
-    h = Hash.new { |*args| args }
+    h = new_hash { |*args| args }
     h.default(nil).should == [h, nil]
     h.default(5).should == [h, 5]
   end
 
   it "calls default proc with nil arg if passed a default proc but no arg" do
-    h = Hash.new { |*args| args }
+    h = new_hash { |*args| args }
     h.default.should == nil
   end
 end
 
 describe "Hash#default=" do
   it "sets the default value" do
-    h = Hash.new
+    h = new_hash
     h.default = 99
     h.default.should == 99
   end
 
   it "unsets the default proc" do
     [99, nil, lambda { 6 }].each do |default|
-      h = Hash.new { 5 }
+      h = new_hash { 5 }
       h.default_proc.should_not == nil
       h.default = default
       h.default.should == default

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/delete_if_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/delete_if_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/delete_if_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -5,18 +5,18 @@
 describe "Hash#delete_if" do
   it "yields two arguments: key and value" do
     all_args = []
-    {1 => 2, 3 => 4}.delete_if { |*args| all_args << args }
+    new_hash(1 => 2, 3 => 4).delete_if { |*args| all_args << args }
     all_args.sort.should == [[1, 2], [3, 4]]
   end
 
   it "removes every entry for which block is true and returns self" do
-    h = {:a => 1, :b => 2, :c => 3, :d => 4}
+    h = new_hash(:a => 1, :b => 2, :c => 3, :d => 4)
     h.delete_if { |k,v| v % 2 == 1 }.should equal(h)
-    h.should == {:b => 2, :d => 4}
+    h.should == new_hash(:b => 2, :d => 4)
   end
 
   it "processes entries with the same order as each()" do
-    h = {:a => 1, :b => 2, :c => 3, :d => 4}
+    h = new_hash(:a => 1, :b => 2, :c => 3, :d => 4)
 
     each_pairs = []
     delete_pairs = []
@@ -42,6 +42,5 @@
   end
 
 
-  it_behaves_like(:hash_iteration_method, :delete_if)
   it_behaves_like(:hash_iteration_no_block, :delete_if)
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/delete_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/delete_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/delete_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,21 +3,21 @@
 
 describe "Hash#delete" do
   it "removes the entry and returns the deleted value" do
-    h = {:a => 5, :b => 2}
+    h = new_hash(:a => 5, :b => 2)
     h.delete(:b).should == 2
-    h.should == {:a => 5}
+    h.should == new_hash(:a => 5)
   end
 
   it "calls supplied block if the key is not found" do
-    {:a => 1, :b => 10, :c => 100 }.delete(:d) { 5 }.should == 5
-    Hash.new(:default).delete(:d) { 5 }.should == 5
-    Hash.new() { :defualt }.delete(:d) { 5 }.should == 5
+    new_hash(:a => 1, :b => 10, :c => 100).delete(:d) { 5 }.should == 5
+    new_hash(:default).delete(:d) { 5 }.should == 5
+    new_hash { :defualt }.delete(:d) { 5 }.should == 5
   end
 
   it "returns nil if the key is not found when no block is given" do
-    {:a => 1, :b => 10, :c => 100 }.delete(:d).should == nil
-    Hash.new(:default).delete(:d).should == nil
-    Hash.new() { :defualt }.delete(:d).should == nil
+    new_hash(:a => 1, :b => 10, :c => 100).delete(:d).should == nil
+    new_hash(:default).delete(:d).should == nil
+    new_hash { :defualt }.delete(:d).should == nil
   end
 
   ruby_version_is "" ... "1.9" do

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/each_key_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/each_key_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/each_key_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -4,20 +4,19 @@
 
 describe "Hash#each_key" do
   it "calls block once for each key, passing key" do
-    r = {}
-    h = {1 => -1, 2 => -2, 3 => -3, 4 => -4 }
+    r = new_hash
+    h = new_hash(1 => -1, 2 => -2, 3 => -3, 4 => -4)
     h.each_key { |k| r[k] = k }.should equal(h)
-    r.should == { 1 => 1, 2 => 2, 3 => 3, 4 => 4 }
+    r.should == new_hash(1 => 1, 2 => 2, 3 => 3, 4 => 4)
   end
 
   it "processes keys in the same order as keys()" do
     keys = []
-    h = {1 => -1, 2 => -2, 3 => -3, 4 => -4 }
+    h = new_hash(1 => -1, 2 => -2, 3 => -3, 4 => -4)
     h.each_key { |k| keys << k }
     keys.should == h.keys
   end
 
-  it_behaves_like(:hash_iteration_method, :each_key)
   it_behaves_like(:hash_iteration_modifying, :each_key)
   it_behaves_like(:hash_iteration_no_block, :each_key)
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/each_pair_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/each_pair_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/each_pair_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -6,14 +6,13 @@
   it "processes all pairs, yielding two arguments: key and value" do
     all_args = []
 
-    h = {1 => 2, 3 => 4}
+    h = new_hash(1 => 2, 3 => 4)
     h2 = h.each_pair { |*args| all_args << args }
     h2.should equal(h)
 
-    all_args.should == [[1, 2], [3, 4]]
+    all_args.sort.should == [[1, 2], [3, 4]]
   end
 
-  it_behaves_like(:hash_iteration_method, :each_pair)
   it_behaves_like(:hash_iteration_modifying, :each_pair)
   it_behaves_like(:hash_iteration_no_block, :each_pair)
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/each_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/each_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/each_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -5,19 +5,19 @@
 describe "Hash#each" do
   it "yields one argument: [key, value]" do
     all_args = []
-    {1 => 2, 3 => 4}.each { |*args| all_args << args }
-    all_args.should == [[[1, 2]], [[3, 4]]]
+    new_hash(1 => 2, 3 => 4).each { |*args| all_args << args }
+    all_args.sort.should == [[[1, 2]], [[3, 4]]]
   end
-  
+
   it "calls block once for each entry, passing key, value" do
-    r = {}
-    h = {:a => 1, :b => 2, :c => 3, :d => 5}
+    r = new_hash
+    h = new_hash(:a => 1, :b => 2, :c => 3, :d => 5)
     h.each { |k,v| r[k.to_s] = v.to_s }.should equal(h)
-    r.should == {"a" => "1", "b" => "2", "c" => "3", "d" => "5" }
+    r.should == new_hash("a" => "1", "b" => "2", "c" => "3", "d" => "5")
   end
 
   it "uses the same order as keys() and values()" do
-    h = {:a => 1, :b => 2, :c => 3, :d => 5}
+    h = new_hash(:a => 1, :b => 2, :c => 3, :d => 5)
     keys = []
     values = []
 
@@ -25,12 +25,11 @@
       keys << k
       values << v
     end
-    
+
     keys.should == h.keys
     values.should == h.values
   end
 
-  it_behaves_like(:hash_iteration_method, :each)
   it_behaves_like(:hash_iteration_modifying, :each)
   it_behaves_like(:hash_iteration_no_block, :each)
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/each_value_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/each_value_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/each_value_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -5,19 +5,18 @@
 describe "Hash#each_value" do
   it "calls block once for each key, passing value" do
     r = []
-    h = { :a => -5, :b => -3, :c => -2, :d => -1, :e => -1 }
+    h = new_hash(:a => -5, :b => -3, :c => -2, :d => -1, :e => -1)
     h.each_value { |v| r << v }.should equal(h)
     r.sort.should == [-5, -3, -2, -1, -1]
   end
 
   it "processes values in the same order as values()" do
     values = []
-    h = { :a => -5, :b => -3, :c => -2, :d => -1, :e => -1 }
+    h = new_hash(:a => -5, :b => -3, :c => -2, :d => -1, :e => -1)
     h.each_value { |v| values << v }
     values.should == h.values
   end
 
-  it_behaves_like(:hash_iteration_method, :each_value)
   it_behaves_like(:hash_iteration_modifying, :each_value)
   it_behaves_like(:hash_iteration_no_block, :each_value)
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/element_reference_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/element_reference_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/element_reference_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -4,7 +4,7 @@
 describe "Hash#[]" do
   it "returns the value for key" do
     obj = mock('x')
-    h = { 1 => 2, 3 => 4, "foo" => "bar", obj => obj, [] => "baz" }
+    h = new_hash(1 => 2, 3 => 4, "foo" => "bar", obj => obj, [] => "baz")
     h[1].should == 2
     h[3].should == 4
     h["foo"].should == "bar"
@@ -13,11 +13,11 @@
   end
 
   it "returns nil as default default value" do
-    { 0 => 0 }[5].should == nil
+    new_hash(0 => 0)[5].should == nil
   end
 
   it "returns the default (immediate) value for missing keys" do
-    h = Hash.new(5)
+    h = new_hash 5
     h[:a].should == 5
     h[:a] = 0
     h[:a].should == 0
@@ -31,7 +31,7 @@
 
   it "does not create copies of the immediate default value" do
     str = "foo"
-    h = Hash.new(str)
+    h = new_hash(str)
     a = h[:a]
     b = h[:b]
     a << "bar"
@@ -42,33 +42,33 @@
   end
 
   it "returns the default (dynamic) value for missing keys" do
-    h = Hash.new { |hsh, k| k.kind_of?(Numeric) ? hsh[k] = k + 2 : hsh[k] = k }
+    h = new_hash { |hsh, k| k.kind_of?(Numeric) ? hsh[k] = k + 2 : hsh[k] = k }
     h[1].should == 3
     h['this'].should == 'this'
-    h.should == {1 => 3, 'this' => 'this'}
+    h.should == new_hash(1 => 3, 'this' => 'this')
 
     i = 0
-    h = Hash.new { |hsh, key| i += 1 }
+    h = new_hash { |hsh, key| i += 1 }
     h[:foo].should == 1
     h[:foo].should == 2
     h[:bar].should == 3
   end
 
   it "does not return default values for keys with nil values" do
-    h = Hash.new(5)
+    h = new_hash 5
     h[:a] = nil
     h[:a].should == nil
 
-    h = Hash.new() { 5 }
+    h = new_hash() { 5 }
     h[:a] = nil
     h[:a].should == nil
   end
 
   it "compares keys with eql? semantics" do
-    { 1.0 => "x" }[1].should == nil
-    { 1.0 => "x" }[1.0].should == "x"
-    { 1 => "x" }[1.0].should == nil
-    { 1 => "x" }[1].should == "x"
+    new_hash(1.0 => "x")[1].should == nil
+    new_hash(1.0 => "x")[1.0].should == "x"
+    new_hash(1 => "x")[1.0].should == nil
+    new_hash(1 => "x")[1].should == "x"
   end
 
   it "compares key via hash" do
@@ -76,7 +76,7 @@
     x = mock('0')
     def x.hash() 0 end
 
-    { }[x].should == nil
+    new_hash[x].should == nil
   end
 
   it "does not compare key with unknown hash codes via eql?" do
@@ -88,7 +88,7 @@
     def x.hash() 0 end
     def y.hash() 1 end
 
-    { y => 1 }[x].should == nil
+    new_hash(y => 1)[x].should == nil
   end
 
   it "compares key with found hash code via eql?" do
@@ -102,7 +102,7 @@
       return 0
     end
 
-    { y => 1 }[x].should == nil
+    new_hash(y => 1)[x].should == nil
     x.tainted?.should == true
 
     x = mock('0')
@@ -111,7 +111,7 @@
       return 0
     end
 
-    { y => 1 }[x].should == 1
+    new_hash(y => 1)[x].should == 1
     x.tainted?.should == true
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/empty_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/empty_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/empty_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,13 +3,13 @@
 
 describe "Hash#empty?" do
   it "returns true if the hash has no entries" do
-    {}.empty?.should == true
-    {1 => 1}.empty?.should == false
+    new_hash.empty?.should == true
+    new_hash(1 => 1).empty?.should == false
   end
 
   it "returns true if the hash has no entries and has a default value" do
-    Hash.new(5).empty?.should == true
-    Hash.new { 5 }.empty?.should == true
-    Hash.new { |hsh, k| hsh[k] = k }.empty?.should == true
+    new_hash(5).empty?.should == true
+    new_hash { 5 }.empty?.should == true
+    new_hash { |hsh, k| hsh[k] = k }.empty?.should == true
   end
 end

Added: MacRuby/branches/experimental/spec/frozen/core/hash/eql_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/eql_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/eql_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,13 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/eql'
+
+# Do not use #should_receive(:eql?) mocks in these specs
+# because MSpec uses Hash for mocks and Hash calls #eql?.
+
+describe "Hash#eql?" do
+  it_behaves_like :hash_eql, :eql?
+  ruby_version_is '1.8.7' do
+    it_behaves_like :hash_eql_additional, :eql?
+  end  
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/equal_value_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/equal_value_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/equal_value_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,158 +1,12 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/eql'
 
 describe "Hash#==" do
-  it "returns true if other Hash has the same number of keys and each key-value pair matches" do
-    Hash.new(5).should == Hash.new(1)
-    Hash.new {|h, k| 1}.should == Hash.new {}
-    Hash.new {|h, k| 1}.should == Hash.new(2)
-
-    a = {:a => 5}
-    b = {}
-    a.should_not == b
-
-    b[:a] = 5
-    a.should == b
-
-    c = {"a" => 5}
-    a.should_not == c
-
-    d = Hash.new {|h, k| 1}
-    e = Hash.new {}
-    d[1] = 2
-    e[1] = 2
-    d.should == e
-  end
-
-  it "does not call to_hash on hash subclasses" do
-    {5 => 6}.should == ToHashHash[5 => 6]
-  end
-
-  it "returns false when the numbers of keys differ without comparing any elements" do
-    obj = mock('x')
-    h = { obj => obj }
-
-    obj.should_not_receive(:==)
-    obj.should_not_receive(:eql?)
-
-    {}.should_not == h
-    h.should_not == {}
-  end
-
-  it "compares keys with eql? semantics" do
-    { 1.0 => "x" }.should == { 1.0 => "x" }
-    { 1 => "x" }.should_not == { 1.0 => "x" }
-    { 1.0 => "x" }.should_not == { 1 => "x" }
-  end
-
-  it "first compares keys via hash" do
-    # Can't use should_receive because it uses hash internally
-    x = mock('x')
-    def x.hash() 0 end
-    y = mock('y')
-    def y.hash() 0 end
-
-    { x => 1 }.should_not == { y => 1 }
-  end
-
-  it "does not compare keys with different hash codes via eql?" do
-    # Can't use should_receive because it uses hash and eql? internally
-    x = mock('x')
-    y = mock('y')
-    x.instance_variable_set(:@other, y)
-    y.instance_variable_set(:@other, x)
-    def x.eql?(o)
-      raise("x Shouldn't receive eql?") if o == @other
-      self == o
-    end
-    def y.eql?(o)
-      raise("y Shouldn't receive eql?") if o == @other
-      self == o
-    end
-
-    def x.hash() 0 end
-    def y.hash() 1 end
-
-    { x => 1 }.should_not == { y => 1 }
-  end
-
-  it "compares keys with matching hash codes via eql?" do
-    # Can't use should_receive because it uses hash and eql? internally
-    a = Array.new(2) do
-      obj = mock('0')
-
-      def obj.hash()
-        return 0
-      end
-      # It's undefined whether the impl does a[0].eql?(a[1]) or
-      # a[1].eql?(a[0]) so we taint both.
-      def obj.eql?(o)
-        return true if self == o
-        taint
-        o.taint
-        false
-      end
-
-      obj
-    end
-
-    { a[0] => 1 }.should_not == { a[1] => 1 }
-    a[0].tainted?.should == true
-    a[1].tainted?.should == true
-
-    a = Array.new(2) do
-      obj = mock('0')
-
-      def obj.hash()
-        # It's undefined whether the impl does a[0].eql?(a[1]) or
-        # a[1].eql?(a[0]) so we taint both.
-        def self.eql?(o) taint; o.taint; true; end
-        return 0
-      end
-
-      obj
-    end
-
-    { a[0] => 1 }.should == { a[1] => 1 }
-    a[0].tainted?.should == true
-    a[1].tainted?.should == true
-  end
-
-  it "computes equality for recursive hashes" do
-    h = {}
-    h[:a] = h
-    h.eql?(h[:a]).should == true
-    (h == h[:a]).should == true
-  end
-
+  it_behaves_like :hash_eql, :==
+  it_behaves_like :hash_eql_additional, :==
+  
   it "compares values with == semantics" do
-    { "x" => 1.0 }.should == { "x" => 1 }
+    new_hash("x" => 1.0).should == new_hash("x" => 1)
   end
-
-  it "does not compare values when keys don't match" do
-    value = mock('x')
-    value.should_not_receive(:==)
-    { 1 => value }.should_not == { 2 => value }
-  end
-
-  it "compares values when keys match" do
-    x = mock('x')
-    y = mock('y')
-    def x.==(o) false end
-    def y.==(o) false end
-    { 1 => x }.should_not == { 1 => y }
-
-    x = mock('x')
-    y = mock('y')
-    def x.==(o) true end
-    def y.==(o) true end
-    { 1 => x }.should == { 1 => y }
-  end
-
-  it "ignores hash class differences" do
-    h = { 1 => 2, 3 => 4 }
-    MyHash[h].should == h
-    MyHash[h].should == MyHash[h]
-    h.should == MyHash[h]
-  end
-end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/fetch_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/fetch_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/fetch_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,31 +3,31 @@
 
 describe "Hash#fetch" do
   it "returns the value for key" do
-    { :a => 1, :b => -1 }.fetch(:b).should == -1
+    new_hash(:a => 1, :b => -1).fetch(:b).should == -1
   end
-  
+
   it "raises an IndexError if key is not found" do
-    lambda { {}.fetch(:a)             }.should raise_error(IndexError)
-    lambda { Hash.new(5).fetch(:a)    }.should raise_error(IndexError)
-    lambda { Hash.new { 5 }.fetch(:a) }.should raise_error(IndexError)
+    lambda { new_hash.fetch(:a)             }.should raise_error(IndexError)
+    lambda { new_hash(5).fetch(:a)    }.should raise_error(IndexError)
+    lambda { new_hash { 5 }.fetch(:a) }.should raise_error(IndexError)
   end
-  
+
   it "returns default if key is not found when passed a default" do
-    {}.fetch(:a, nil).should == nil
-    {}.fetch(:a, 'not here!').should == "not here!"
-    { :a => nil }.fetch(:a, 'not here!').should == nil
+    new_hash.fetch(:a, nil).should == nil
+    new_hash.fetch(:a, 'not here!').should == "not here!"
+    new_hash(:a => nil).fetch(:a, 'not here!').should == nil
   end
-  
+
   it "returns value of block if key is not found when passed a block" do
-    {}.fetch('a') { |k| k + '!' }.should == "a!"
+    new_hash.fetch('a') { |k| k + '!' }.should == "a!"
   end
 
   it "gives precedence to the default block over the default argument when passed both" do
-    {}.fetch(9, :foo) { |i| i * i }.should == 81
+    new_hash.fetch(9, :foo) { |i| i * i }.should == 81
   end
 
   it "raises an ArgumentError when not passed one or two arguments" do
-    lambda { {}.fetch()        }.should raise_error(ArgumentError)
-    lambda { {}.fetch(1, 2, 3) }.should raise_error(ArgumentError)
+    lambda { new_hash.fetch()        }.should raise_error(ArgumentError)
+    lambda { new_hash.fetch(1, 2, 3) }.should raise_error(ArgumentError)
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/fixtures/classes.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/fixtures/classes.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/fixtures/classes.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,6 +1,6 @@
-class MyHash < Hash; end
+class MyHash < hash_class; end
 
-class NewHash < Hash
+class NewHash < hash_class
   def initialize(*args)
     args.each_with_index do |val, index|
       self[index] = val
@@ -8,25 +8,27 @@
   end
 end
 
-class DefaultHash < Hash
+class DefaultHash < hash_class
   def default(key)
     100
   end
 end
 
-class ToHashHash < Hash
-  def to_hash() { "to_hash" => "was", "called!" => "duh." } end
+class ToHashHash < hash_class
+  def to_hash
+    new_hash "to_hash" => "was", "called!" => "duh."
+  end
 end
 
 module HashSpecs
   def self.empty_frozen_hash
-    @empty ||= {}
+    @empty ||= new_hash
     @empty.freeze
     @empty
   end
   
   def self.frozen_hash
-    @hash ||= {1 => 2, 3 => 4}
+    @hash ||= new_hash(1 => 2, 3 => 4)
     @hash.freeze
     @hash
   end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/hash_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/hash_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/hash_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,7 +2,7 @@
 
 describe "Hash" do
   it "includes Enumerable" do
-    Hash.include?(Enumerable).should == true
+    hash_class.include?(Enumerable).should == true
   end
 end
 
@@ -11,20 +11,20 @@
   ruby_version_is "1.8.7" do
     ruby_bug "#", "1.8.7.10" do
       it "returns a value which doesn't depend on the hash order" do
-        {0=>2, 11=>1}.hash.should == {11=>1, 0=>2}.hash
+        new_hash(0=>2, 11=>1).hash.should == new_hash(11=>1, 0=>2).hash
       end
     end
   end
 
   it "generates a hash for recursive hash structures" do
-    h = {}
+    h = new_hash
     h[:a] = h
     (h.hash == h[:a].hash).should == true
   end
 
   ruby_version_is "" .. "1.8.6" do
     it "computes recursive hash keys with identical hashes" do
-      h = {}
+      h = new_hash
       h[h] = h
       (h.hash == h[h].hash).should == true
     end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/index_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/index_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/index_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,27 +1,7 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/index'
 
 describe "Hash#index" do
-  it "returns the corresponding key for value" do
-    {2 => 'a', 1 => 'b'}.index('b').should == 1
-  end
-
-  it "returns nil if the value is not found" do
-    {:a => -1, :b => 3.14, :c => 2.718}.index(1).should == nil
-  end
-
-  it "doesn't return default value if the value is not found" do
-    Hash.new(5).index(5).should == nil
-  end
-
-  it "compares values using ==" do
-    {1 => 0}.index(0.0).should == 1
-    {1 => 0.0}.index(0).should == 1
-
-    needle = mock('needle')
-    inhash = mock('inhash')
-    inhash.should_receive(:==).with(needle).and_return(true)
-
-    {1 => inhash}.index(needle).should == 1
-  end
+  it_behaves_like :hash_index, :index
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/initialize_copy_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/initialize_copy_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/initialize_copy_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -4,7 +4,7 @@
 
 describe "Hash#initialize_copy" do
   it "is private" do
-    {}.private_methods.map { |m| m.to_s }.include?("initialize_copy").should == true
+    hash_class.should have_private_instance_method("initialize_copy")
   end
 
   it_behaves_like(:hash_replace, :initialize_copy)

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/initialize_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/initialize_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/initialize_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,11 +3,11 @@
 
 describe "Hash#initialize" do
   it "is private" do
-    {}.private_methods.map { |m| m.to_s }.include?("initialize").should == true
+    hash_class.should have_private_instance_method("initialize")
   end
 
   it "can be used to reset default_proc" do
-    h = { "foo" => 1, "bar" => 2 }
+    h = new_hash("foo" => 1, "bar" => 2)
     h.default_proc.should == nil
     h.instance_eval { initialize { |h, k| k * 2 } }
     h.default_proc.should_not == nil

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/inspect_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/inspect_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/inspect_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,57 +1,42 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/to_s'
 
 describe "Hash#inspect" do
-  it "returns a string representation with same order as each()" do
-    h = {:a => [1, 2], :b => -2, :d => -6, nil => nil}
-    
-    pairs = []
-    h.each do |key, value|
-      pairs << key.inspect + "=>" + value.inspect
-    end
-    
-    str = '{' + pairs.join(', ') + '}'
-    h.inspect.should == str
-  end
-
-  it "calls inspect on keys and values" do
-    key = mock('key')
-    val = mock('val')
-    key.should_receive(:inspect).and_return('key')
-    val.should_receive(:inspect).and_return('val')
-    
-    { key => val }.inspect.should == '{key=>val}'
-  end
-
+  it_behaves_like :to_s, :inspect
+ 
+  # FIXME: When http://redmine.ruby-lang.org/issues/show/1533 is fixed, this
+  # block can be removed, as the behaviour will then be shared with to_s
+  # completely. 
   it "handles recursive hashes" do
-    x = {}
+    x = new_hash
     x[0] = x
     x.inspect.should == '{0=>{...}}'
 
-    x = {}
+    x = new_hash
     x[x] = 0
     x.inspect.should == '{{...}=>0}'
 
-    x = {}
+    x = new_hash
     x[x] = x
     x.inspect.should == '{{...}=>{...}}'
 
-    x = {}
-    y = {}
+    x = new_hash
+    y = new_hash
     x[0] = y
     y[1] = x
     x.inspect.should == "{0=>{1=>{...}}}"
     y.inspect.should == "{1=>{0=>{...}}}"
 
-    x = {}
-    y = {}
+    x = new_hash
+    y = new_hash
     x[y] = 0
     y[x] = 1
     x.inspect.should == "{{{...}=>1}=>0}"
     y.inspect.should == "{{{...}=>0}=>1}"
     
-    x = {}
-    y = {}
+    x = new_hash
+    y = new_hash
     x[y] = x
     y[x] = y
     x.inspect.should == "{{{...}=>{...}}=>{...}}"

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/invert_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/invert_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/invert_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,24 +3,25 @@
 
 describe "Hash#invert" do
   it "returns a new hash where keys are values and vice versa" do
-    { 1 => 'a', 2 => 'b', 3 => 'c' }.invert.should == { 'a' => 1, 'b' => 2, 'c' => 3 }
+    new_hash(1 => 'a', 2 => 'b', 3 => 'c').invert.should ==
+      new_hash('a' => 1, 'b' => 2, 'c' => 3)
   end
-  
+
   it "handles collisions by overriding with the key coming later in keys()" do
-    h = { :a => 1, :b => 1 }
+    h = new_hash(:a => 1, :b => 1)
     override_key = h.keys.last
     h.invert[1].should == override_key
   end
 
   it "compares new keys with eql? semantics" do
-    h = { :a => 1.0, :b => 1 }
+    h = new_hash(:a => 1.0, :b => 1)
     i = h.invert
     i[1.0].should == :a
     i[1].should == :b
   end
-  
+
   it "does not return subclass instances for subclasses" do
-    MyHash[1 => 2, 3 => 4].invert.class.should == Hash
-    MyHash[].invert.class.should == Hash
+    MyHash[1 => 2, 3 => 4].invert.class.should == hash_class
+    MyHash[].invert.class.should == hash_class
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/key_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/key_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/key_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,7 +1,14 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
 require File.dirname(__FILE__) + '/shared/key'
+require File.dirname(__FILE__) + '/shared/index'
 
 describe "Hash#key?" do
   it_behaves_like(:hash_key_p, :key?)
 end
+
+ruby_version_is "1.9" do
+  describe "Hash#key" do
+    it_behaves_like(:hash_index, :key)
+  end
+end  

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/keys_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/keys_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/keys_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -5,32 +5,32 @@
 
   ruby_version_is ""..."1.9" do
     it "returns an array populated with keys" do
-      {}.keys.should == []
-      {}.keys.class.should == Array
-      Hash.new(5).keys.should == []
-      Hash.new { 5 }.keys.should == []
-      { 1 => 2, 2 => 4, 4 => 8 }.keys.sort.should == [1, 2, 4]
-      { 1 => 2, 2 => 4, 4 => 8 }.keys.should be_kind_of(Array)
-      { nil => nil }.keys.should == [nil]
+      new_hash.keys.should == []
+      new_hash.keys.class.should == Array
+      new_hash(5).keys.should == []
+      new_hash { 5 }.keys.should == []
+      new_hash(1 => 2, 2 => 4, 4 => 8).keys.sort.should == [1, 2, 4]
+      new_hash(1 => 2, 2 => 4, 4 => 8).keys.should be_kind_of(Array)
+      new_hash(nil => nil).keys.should == [nil]
     end
   end
 
   ruby_version_is "1.9" do
     it "returns an array with the keys in the order they were inserted" do
-      {}.keys.should == []
-      {}.keys.class.should == Array
-      Hash.new(5).keys.should == []
-      Hash.new { 5 }.keys.should == []
-      { 1 => 2, 4 => 8, 2 => 4 }.keys.should == [1, 4, 2]
-      { 1 => 2, 2 => 4, 4 => 8 }.keys.should be_kind_of(Array)
-      { nil => nil }.keys.should == [nil]
+      new_hash.keys.should == []
+      new_hash.keys.class.should == Array
+      new_hash(5).keys.should == []
+      new_hash { 5 }.keys.should == []
+      new_hash(1 => 2, 4 => 8, 2 => 4).keys.should == [1, 4, 2]
+      new_hash(1 => 2, 2 => 4, 4 => 8).keys.should be_kind_of(Array)
+      new_hash(nil => nil).keys.should == [nil]
     end
   end
 
 
   it "it uses the same order as #values" do
-    h = { 1 => "1", 2 => "2", 3 => "3", 4 => "4" }
-    
+    h = new_hash(1 => "1", 2 => "2", 3 => "3", 4 => "4")
+
     h.size.times do |i|
       h[h.keys[i]].should == h.values[i]
     end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/merge_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/merge_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/merge_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -5,47 +5,47 @@
 
 describe "Hash#merge" do
   it "returns a new hash by combining self with the contents of other" do
-    h = { 1 => :a, 2 => :b, 3 => :c }.merge(:a => 1, :c => 2)
-    h.should == { :c => 2, 1 => :a, 2 => :b, :a => 1, 3 => :c }
+    h = new_hash(1 => :a, 2 => :b, 3 => :c).merge(:a => 1, :c => 2)
+    h.should == new_hash(:c => 2, 1 => :a, 2 => :b, :a => 1, 3 => :c)
   end
 
   it "sets any duplicate key to the value of block if passed a block" do
-    h1 = { :a => 2, :b => 1, :d => 5}
-    h2 = { :a => -2, :b => 4, :c => -3 }
+    h1 = new_hash(:a => 2, :b => 1, :d => 5)
+    h2 = new_hash(:a => -2, :b => 4, :c => -3)
     r = h1.merge(h2) { |k,x,y| nil }
-    r.should == { :a => nil, :b => nil, :c => -3, :d => 5 }
+    r.should == new_hash(:a => nil, :b => nil, :c => -3, :d => 5)
 
     r = h1.merge(h2) { |k,x,y| "#{k}:#{x+2*y}" }
-    r.should == { :a => "a:-2", :b => "b:9", :c => -3, :d => 5 }
+    r.should == new_hash(:a => "a:-2", :b => "b:9", :c => -3, :d => 5)
 
     lambda {
       h1.merge(h2) { |k, x, y| raise(IndexError) }
     }.should raise_error(IndexError)
 
     r = h1.merge(h1) { |k,x,y| :x }
-    r.should == { :a => :x, :b => :x, :d => :x }
+    r.should == new_hash(:a => :x, :b => :x, :d => :x)
   end
 
   it "tries to convert the passed argument to a hash using #to_hash" do
     obj = mock('{1=>2}')
-    obj.should_receive(:to_hash).and_return({1 => 2})
-    {3 => 4}.merge(obj).should == {1 => 2, 3 => 4}
+    obj.should_receive(:to_hash).and_return(new_hash(1 => 2))
+    new_hash(3 => 4).merge(obj).should == new_hash(1 => 2, 3 => 4)
   end
 
   it "does not call to_hash on hash subclasses" do
-    {3 => 4}.merge(ToHashHash[1 => 2]).should == {1 => 2, 3 => 4}
+    new_hash(3 => 4).merge(ToHashHash[1 => 2]).should == new_hash(1 => 2, 3 => 4)
   end
 
   it "returns subclass instance for subclasses" do
-    MyHash[1 => 2, 3 => 4].merge({1 => 2}).class.should == MyHash
-    MyHash[].merge({1 => 2}).class.should == MyHash
+    MyHash[1 => 2, 3 => 4].merge(new_hash(1 => 2)).class.should == MyHash
+    MyHash[].merge(new_hash(1 => 2)).class.should == MyHash
 
-    {1 => 2, 3 => 4}.merge(MyHash[1 => 2]).class.should == Hash
-    {}.merge(MyHash[1 => 2]).class.should == Hash
+    new_hash(1 => 2, 3 => 4).merge(MyHash[1 => 2]).class.should == hash_class
+    new_hash.merge(MyHash[1 => 2]).class.should == hash_class
   end
 
   it "processes entries with same order as each()" do
-    h = {1 => 2, 3 => 4, 5 => 6, "x" => nil, nil => 5, [] => []}
+    h = new_hash(1 => 2, 3 => 4, 5 => 6, "x" => nil, nil => 5, [] => [])
     merge_pairs = []
     each_pairs = []
     h.each_pair { |*pair| each_pairs << pair }
@@ -53,14 +53,25 @@
     merge_pairs.should == each_pairs
   end
 
-  it_behaves_like(:hash_iteration_method, :merge)
   it_behaves_like(:hash_iteration_modifying, :merge)
 end
 
 describe "Hash#merge!" do
   it_behaves_like(:hash_update, :merge!)
 
-  it_behaves_like(:hash_iteration_method, :merge!)
+  # This bug is far too odd to explain in a comment; see
+  # http://redmine.ruby-lang.org/issues/show/1535 for the closest I've got to
+  # an explanation.
+  ruby_bug "#1535", "1.8.7.167" do
+    it "shouldn't raise spurious RuntimeErrors" do
+      hash = {1 => 2, 3 => 4, 5 => 6}
+      big_hash = {}
+      64.times { |k| big_hash[k.to_s] = k }
+      lambda{
+        hash.each { hash.merge!(big_hash) }
+      }.should_not raise_error(RuntimeError)
+    end
+  end
 
   compliant_on :rubinius do
     it_behaves_like(:hash_iteration_modifying, :merge!)

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/new_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/new_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/new_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,30 +2,35 @@
 require File.dirname(__FILE__) + '/fixtures/classes'
 
 describe "Hash.new" do
-  it "creates a new Hash with default object if pass a default argument " do
-    Hash.new(5).default.should == 5
-    Hash.new({}).default.should == {}
+  it "creates an empty Hash if passed no arguments" do
+    hash_class.new.should == {}
+    hash_class.new.size.should == 0
   end
 
+  it "creates a new Hash with default object if passed a default argument " do
+    hash_class.new(5).default.should == 5
+    hash_class.new(new_hash).default.should == new_hash
+  end
+
   it "does not create a copy of the default argument" do
     str = "foo"
-    Hash.new(str).default.should equal(str)
+    hash_class.new(str).default.should equal(str)
   end
-  
+
   it "creates a Hash with a default_proc if passed a block" do
-    Hash.new.default_proc.should == nil
-    
-    h = Hash.new { |x| "Answer to #{x}" }
+    hash_class.new.default_proc.should == nil
+
+    h = hash_class.new { |x| "Answer to #{x}" }
     h.default_proc.call(5).should == "Answer to 5"
     h.default_proc.call("x").should == "Answer to x"
   end
-  
+
   it "raises an ArgumentError if more than one argument is passed" do
-    lambda { Hash.new(5,6) }.should raise_error(ArgumentError)
+    lambda { hash_class.new(5,6) }.should raise_error(ArgumentError)
   end
-  
+
   it "raises an ArgumentError if passed both default argument and default block" do
-    lambda { Hash.new(5) { 0 }   }.should raise_error(ArgumentError)
-    lambda { Hash.new(nil) { 0 } }.should raise_error(ArgumentError)
+    lambda { hash_class.new(5) { 0 }   }.should raise_error(ArgumentError)
+    lambda { hash_class.new(nil) { 0 } }.should raise_error(ArgumentError)
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/rehash_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/rehash_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/rehash_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -5,7 +5,7 @@
   it "reorganizes the hash by recomputing all key hash codes" do
     k1 = [1]
     k2 = [2]
-    h = {}
+    h = new_hash
     h[k1] = 0
     h[k2] = 1
 
@@ -26,7 +26,7 @@
     def v1.hash() raise("values shouldn't be rehashed"); end
     def v2.hash() raise("values shouldn't be rehashed"); end
 
-    h = { k1 => v1, k2 => v2 }
+    h = new_hash(k1 => v1, k2 => v2)
 
     def k1.hash() 0 end
     def k2.hash() 0 end
@@ -36,23 +36,16 @@
     h[k2].should == v2
   end
 
-  compliant_on :rubinius do
-    it "gives precedence to keys coming later in keys() on collisions" do
-      k1 = [1]
-      k2 = [2]
-      h = {}
-      h[k1] = 0
-      h[k2] = 1
-
-      k1.replace(k2)
-      override_val = h[h.keys.last]
-      h.rehash
-      h[k1].should == override_val
-    end
-  end
-
   it "raises a TypeError if called on a frozen instance" do
     lambda { HashSpecs.frozen_hash.rehash  }.should raise_error(TypeError)
     lambda { HashSpecs.empty_frozen_hash.rehash }.should raise_error(TypeError)
   end
+
+  it "causes a RuntimeError to be raised if called inside an iterator block" do
+    [:delete_if, :each, :each_pair, :each_value, 
+     :reject!, :select, :sort_by].each do |method|
+      h = new_hash(:foo => :bar)
+      lambda { h.send(method) { h.rehash } }.should raise_error(RuntimeError)
+    end  
+  end  
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/reject_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/reject_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/reject_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -4,17 +4,17 @@
 
 describe "Hash#reject" do
   it "is equivalent to hsh.dup.delete_if" do
-    h = { :a => 'a', :b => 'b', :c => 'd' }
+    h = new_hash(:a => 'a', :b => 'b', :c => 'd')
     h.reject { |k,v| k == 'd' }.should == (h.dup.delete_if { |k, v| k == 'd' })
 
     all_args_reject = []
     all_args_delete_if = []
-    h = {1 => 2, 3 => 4}
+    h = new_hash(1 => 2, 3 => 4)
     h.reject { |*args| all_args_reject << args }
     h.delete_if { |*args| all_args_delete_if << args }
     all_args_reject.should == all_args_delete_if
 
-    h = { 1 => 2 }
+    h = new_hash(1 => 2)
     # dup doesn't copy singleton methods
     def h.to_a() end
     h.reject { false }.to_a.should == [[1, 2]]
@@ -26,7 +26,7 @@
   end
 
   it "processes entries with the same order as reject!" do
-    h = {:a => 1, :b => 2, :c => 3, :d => 4}
+    h = new_hash(:a => 1, :b => 2, :c => 3, :d => 4)
 
     reject_pairs = []
     reject_bang_pairs = []
@@ -41,14 +41,15 @@
 
 describe "Hash#reject!" do
   before(:each) do
-    @hsh = {1 => 2, 3 => 4, 5 => 6}
-    @empty = {}
+    @hsh = new_hash(1 => 2, 3 => 4, 5 => 6)
+    @empty = new_hash
   end
 
   it "is equivalent to delete_if if changes are made" do
-    {:a => 2}.reject! { |k,v| v > 1 }.should == ({:a => 2}.delete_if { |k, v| v > 1 })
+    new_hash(:a => 2).reject! { |k,v| v > 1 }.should ==
+      new_hash(:a => 2).delete_if { |k, v| v > 1 }
 
-    h = {1 => 2, 3 => 4}
+    h = new_hash(1 => 2, 3 => 4)
     all_args_reject = []
     all_args_delete_if = []
     h.dup.reject! { |*args| all_args_reject << args }
@@ -57,11 +58,11 @@
   end
 
   it "returns nil if no changes were made" do
-    { :a => 1 }.reject! { |k,v| v > 1 }.should == nil
+    new_hash(:a => 1).reject! { |k,v| v > 1 }.should == nil
   end
 
   it "processes entries with the same order as delete_if" do
-    h = {:a => 1, :b => 2, :c => 3, :d => 4}
+    h = new_hash(:a => 1, :b => 2, :c => 3, :d => 4)
 
     reject_bang_pairs = []
     delete_if_pairs = []
@@ -88,13 +89,12 @@
 
   ruby_version_is "1.8.7" do
     it "returns an Enumerator when called on a non-empty hash without a block" do
-      @hsh.reject!.should be_kind_of(Enumerable::Enumerator)
+      @hsh.reject!.should be_kind_of(enumerator_class)
     end
 
     it "returns an Enumerator when called on an empty hash without a block" do
-      @empty.reject!.should be_kind_of(Enumerable::Enumerator)
+      @empty.reject!.should be_kind_of(enumerator_class)
     end
   end
 
-  it_behaves_like(:hash_iteration_method, :reject!)
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/select_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/select_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/select_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -4,23 +4,34 @@
 
 describe "Hash#select" do
   before(:each) do
-    @hsh = {1 => 2, 3 => 4, 5 => 6}
-    @empty = {}
+    @hsh = new_hash(1 => 2, 3 => 4, 5 => 6)
+    @empty = new_hash
   end
 
   it "yields two arguments: key and value" do
     all_args = []
-    {1 => 2, 3 => 4}.select { |*args| all_args << args }
+    new_hash(1 => 2, 3 => 4).select { |*args| all_args << args }
     all_args.sort.should == [[1, 2], [3, 4]]
   end
 
-  it "returns an array of entries for which block is true" do
-    a_pairs = { 'a' => 9, 'c' => 4, 'b' => 5, 'd' => 2 }.select { |k,v| v % 2 == 0 }
-    a_pairs.sort.should == [['c', 4], ['d', 2]]
+  ruby_version_is ""..."1.9" do
+    it "returns an Array of entries for which block is true" do
+      a_pairs = new_hash('a' => 9, 'c' => 4, 'b' => 5, 'd' => 2).select { |k,v| v % 2 == 0 }
+      a_pairs.should be_an_instance_of(Array)
+      a_pairs.sort.should == [['c', 4], ['d', 2]]
+    end
   end
 
+  ruby_version_is "1.9" do
+    it "returns a Hash of entries for which block is true" do
+      a_pairs = new_hash('a' => 9, 'c' => 4, 'b' => 5, 'd' => 2).select { |k,v| v % 2 == 0 }
+      a_pairs.should be_an_instance_of(Hash)
+      a_pairs.sort.should == [['c', 4], ['d', 2]]
+    end
+  end
+
   it "processes entries with the same order as reject" do
-    h = { :a => 9, :c => 4, :b => 5, :d => 2 }
+    h = new_hash(:a => 9, :c => 4, :b => 5, :d => 2)
 
     select_pairs = []
     reject_pairs = []
@@ -42,14 +53,13 @@
 
   ruby_version_is "1.8.7" do
     it "returns an Enumerator when called on a non-empty hash without a block" do
-      @hsh.select.should be_kind_of(Enumerable::Enumerator)
+      @hsh.select.should be_kind_of(enumerator_class)
     end
 
     it "returns an Enumerator when called on an empty hash without a block" do
-      @empty.select.should be_kind_of(Enumerable::Enumerator)
+      @empty.select.should be_kind_of(enumerator_class)
     end
   end
 
-  it_behaves_like(:hash_iteration_method, :select)
   it_behaves_like(:hash_iteration_modifying, :select)
 end

Added: MacRuby/branches/experimental/spec/frozen/core/hash/shared/eql.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/eql.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/eql.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,210 @@
+describe :hash_eql, :shared => true do
+
+  it "does not compare values when keys don't match" do
+    value = mock('x')
+    value.should_not_receive(:==)
+    value.should_not_receive(:eql?)
+    new_hash(1 => value).send(@method, new_hash(2 => value)).should == false
+  end
+
+  it "returns false when the numbers of keys differ without comparing any elements" do
+    obj = mock('x')
+    h = new_hash(obj => obj)
+
+    obj.should_not_receive(:==)
+    obj.should_not_receive(:eql?)
+
+    new_hash.send(@method, h).should == false
+    h.send(@method, new_hash).should == false
+  end
+
+  it "first compares keys via hash" do
+    # Can't use should_receive because it uses hash internally
+    x = mock('x')
+    def x.hash() 0 end
+    y = mock('y')
+    def y.hash() 0 end
+
+    new_hash(x => 1).send(@method, new_hash(y => 1)).should == false
+  end
+
+  it "does not compare keys with different hash codes via eql?" do
+    # Can't use should_receive because it uses hash and eql? internally
+    x = mock('x')
+    y = mock('y')
+    x.instance_variable_set(:@other, y)
+    y.instance_variable_set(:@other, x)
+    def x.eql?(o)
+      raise("x Shouldn't receive eql?") if o == @other
+      self == o
+    end
+    def y.eql?(o)
+      raise("y Shouldn't receive eql?") if o == @other
+      self == o
+    end
+
+    def x.hash() 0 end
+    def y.hash() 1 end
+
+    new_hash(x => 1).send(@method, new_hash(y => 1)).should == false
+  end
+
+  it "computes equality for recursive hashes" do
+    h = new_hash
+    h[:a] = h
+    h.send(@method, h[:a]).should == true
+    (h == h[:a]).should == true
+  end
+  
+  it "doesn't call to_hash on objects" do
+    mock_hash = mock("fake hash")
+    def mock_hash.to_hash() new_hash end
+    new_hash.send(@method, mock_hash).should be_false
+  end
+    
+  ruby_bug "redmine #2448", "1.9.1" do
+    it "computes equality for complex recursive hashes" do
+      a, b = {}, {}
+      a.merge! :self => a, :other => b
+      b.merge! :self => b, :other => a
+      a.send(@method, b).should == true # they both have the same structure!
+
+      c = {}
+      c.merge! :other => c, :self => c
+      c.send(@method, a).should == true # subtle, but they both have the same structure!
+      a[:delta] = c[:delta] = a
+      c.send(@method, a).should == false # not quite the same structure, as a[:other][:delta] = nil
+      c[:delta] = 42
+      c.send(@method, a).should == false
+      a[:delta] = 42
+      c.send(@method, a).should == false
+      b[:delta] = 42
+      c.send(@method, a).should == true   
+    end
+  
+    it "computes equality for recursive hashes & arrays" do
+      x, y, z = [], [], []
+      a, b, c = {:foo => x, :bar => 42}, {:foo => y, :bar => 42}, {:foo => z, :bar => 42}
+      x << a
+      y << c
+      z << b
+      b.send(@method, c).should == true # they clearly have the same structure!
+      y.send(@method, z).should == true
+      a.send(@method, b).should == true # subtle, but they both have the same structure!
+      x.send(@method, y).should == true
+      y << x
+      y.send(@method, z).should == false
+      z << x
+      y.send(@method, z).should == true
+    
+      a[:foo], a[:bar] = a[:bar], a[:foo]
+      a.send(@method, b).should == false
+      b[:bar] = b[:foo]
+      b.send(@method, c).should == false
+    end
+  end # ruby_bug
+end
+
+# All these tests are true for ==, and for eql? when Ruby >= 1.8.7
+describe :hash_eql_additional, :shared => true do
+  it "compares values when keys match" do
+    x = mock('x')
+    y = mock('y')
+    def x.==(o) false end
+    def y.==(o) false end
+    def x.eql?(o) false end
+    def y.eql?(o) false end
+    new_hash(1 => x).send(@method, new_hash(1 => y)).should == false
+
+    x = mock('x')
+    y = mock('y')
+    def x.==(o) true end
+    def y.==(o) true end
+    def x.eql?(o) true end
+    def y.eql?(o) true end
+    new_hash(1 => x).send(@method, new_hash(1 => y)).should == true
+  end
+  
+  it "compares keys with eql? semantics" do
+    new_hash(1.0 => "x").send(@method, new_hash(1.0 => "x")).should == true
+    new_hash(1.0 => "x").send(@method, new_hash(1.0 => "x")).should == true
+    new_hash(1 => "x").send(@method, new_hash(1.0 => "x")).should == false
+    new_hash(1.0 => "x").send(@method, new_hash(1 => "x")).should == false
+  end
+    
+  it "returns true if other Hash has the same number of keys and each key-value pair matches" do
+    new_hash(5).send(@method, new_hash(1)).should == true
+    new_hash {|h, k| 1}.send(@method, new_hash {}).should == true
+    new_hash {|h, k| 1}.send(@method, new_hash(2)).should == true
+
+    a = new_hash(:a => 5)
+    b = new_hash
+    a.send(@method, b).should == false
+
+    b[:a] = 5
+    a.send(@method, b).should == true
+
+    c = new_hash("a" => 5)
+    a.send(@method, c).should == false
+
+    d = new_hash {|h, k| 1}
+    e = new_hash {}
+    d[1] = 2
+    e[1] = 2
+    d.send(@method, e).should == true
+  end
+  
+  it "does not call to_hash on hash subclasses" do
+    new_hash(5 => 6).send(@method, ToHashHash[5 => 6]).should == true
+  end
+
+  it "ignores hash class differences" do
+    h = new_hash(1 => 2, 3 => 4)
+    MyHash[h].send(@method, h).should == true
+    MyHash[h].send(@method, MyHash[h]).should == true
+    h.send(@method, MyHash[h]).should == true
+  end
+
+  # Why isn't this true of eql? too ?
+  it "compares keys with matching hash codes via eql?" do
+    # Can't use should_receive because it uses hash and eql? internally
+    a = Array.new(2) do
+      obj = mock('0')
+
+      def obj.hash()
+        return 0
+      end
+      # It's undefined whether the impl does a[0].eql?(a[1]) or
+      # a[1].eql?(a[0]) so we taint both.
+      def obj.eql?(o)
+        return true if self == o
+        taint
+        o.taint
+        false
+      end
+
+      obj
+    end
+
+    new_hash(a[0] => 1).send(@method, new_hash(a[1] => 1)).should == false
+    a[0].tainted?.should == true
+    a[1].tainted?.should == true
+
+    a = Array.new(2) do
+      obj = mock('0')
+
+      def obj.hash()
+        # It's undefined whether the impl does a[0].send(@method, a[1]) or
+        # a[1].send(@method, a[0]) so we taint both.
+        def self.eql?(o) taint; o.taint; true; end
+        return 0
+      end
+
+      obj
+    end
+
+    new_hash(a[0] => 1).send(@method, new_hash(a[1] => 1)).should == true
+    a[0].tainted?.should == true
+    a[1].tainted?.should == true
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/core/hash/shared/equal.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/equal.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/equal.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,99 @@
+describe :hash_equal, :shared => true do
+  it "does not compare values when keys don't match" do
+    value = mock('x')
+    value.should_not_receive(:==)
+    value.should_not_receive(:eql?)
+    new_hash(1 => value).send(@method, new_hash(2 => value)).should be_false
+  end
+
+  it "returns false when the numbers of keys differ without comparing any elements" do
+    obj = mock('x')
+    h = new_hash(obj => obj)
+
+    obj.should_not_receive(:==)
+    obj.should_not_receive(:eql?)
+
+    new_hash.send(@method, h).should be_false
+    h.send(@method, new_hash).should be_false
+  end
+
+  it "first compares keys via hash" do
+    # Can't use should_receive because it uses hash internally
+    x = mock('x')
+    def x.hash() 0 end
+    y = mock('y')
+    def y.hash() 0 end
+
+    new_hash(x => 1).send(@method, new_hash(y => 1)).should be_false
+  end
+
+  it "does not compare keys with different hash codes via eql?" do
+    # Can't use should_receive because it uses hash and eql? internally
+    x = mock('x')
+    y = mock('y')
+    x.instance_variable_set(:@other, y)
+    y.instance_variable_set(:@other, x)
+    def x.eql?(o)
+      raise("x Shouldn't receive eql?") if o == @other
+      self == o
+    end
+    def y.eql?(o)
+      raise("y Shouldn't receive eql?") if o == @other
+      self == o
+    end
+
+    def x.hash() 0 end
+    def y.hash() 1 end
+
+    new_hash(x => 1).send(@method, new_hash(y => 1)).should be_false
+  end
+
+  it "computes equality for recursive hashes" do
+    h = new_hash
+    h[:a] = h
+    h.send(@method, h[:a]).should be_true
+    (h == h[:a]).should be_true
+  end
+
+  ruby_bug "redmine #2448", "1.9.1" do
+    it "computes equality for complex recursive hashes" do
+      a, b = {}, {}
+      a.merge! :self => a, :other => b
+      b.merge! :self => b, :other => a
+      a.send(@method, b).should be_true # they both have the same structure!
+
+      c = {}
+      c.merge! :other => c, :self => c
+      c.send(@method, a).should be_true # subtle, but they both have the same structure!
+      a[:delta] = c[:delta] = a
+      c.send(@method, a).should be_false # not quite the same structure, as a[:other][:delta] = nil
+      c[:delta] = 42
+      c.send(@method, a).should be_false
+      a[:delta] = 42
+      c.send(@method, a).should be_false
+      b[:delta] = 42
+      c.send(@method, a).should be_true
+    end
+
+    it "computes equality for recursive hashes & arrays" do
+      x, y, z = [], [], []
+      a, b, c = {:foo => x, :bar => 42}, {:foo => y, :bar => 42}, {:foo => z, :bar => 42}
+      x << a
+      y << c
+      z << b
+      b.send(@method, c).should be_true # they clearly have the same structure!
+      y.send(@method, z).should be_true
+      a.send(@method, b).should be_true # subtle, but they both have the same structure!
+      x.send(@method, y).should be_true
+      y << x
+      y.send(@method, z).should be_false
+      z << x
+      y.send(@method, z).should be_true
+
+      a[:foo], a[:bar] = a[:bar], a[:foo]
+      a.send(@method, b).should be_false
+      b[:bar] = b[:foo]
+      b.send(@method, c).should be_false
+    end
+  end # ruby_bug
+end

Added: MacRuby/branches/experimental/spec/frozen/core/hash/shared/index.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/index.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/index.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,27 @@
+require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.dirname(__FILE__) + '/../fixtures/classes'
+
+describe :hash_index, :shared => true do
+  it "returns the corresponding key for value" do
+    new_hash(2 => 'a', 1 => 'b').send(@method, 'b').should == 1
+  end
+
+  it "returns nil if the value is not found" do
+    new_hash(:a => -1, :b => 3.14, :c => 2.718).send(@method, 1).should be_nil
+  end
+
+  it "doesn't return default value if the value is not found" do
+    new_hash(5).send(@method, 5).should be_nil
+  end
+
+  it "compares values using ==" do
+    new_hash(1 => 0).send(@method, 0.0).should == 1
+    new_hash(1 => 0.0).send(@method, 0).should == 1
+
+    needle = mock('needle')
+    inhash = mock('inhash')
+    inhash.should_receive(:==).with(needle).and_return(true)
+
+    new_hash(1 => inhash).send(@method, needle).should == 1
+  end
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/shared/iteration.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/iteration.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/iteration.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,63 +1,34 @@
-describe :hash_iteration_method, :shared => true do
-  # These are the only ones that actually have the exceptions on MRI 1.8.
-  # sort and reject don't raise!
-  # 
-  #   delete_if each each_key each_pair each_value merge merge! reject!
-  #   select update
-  #
-  hsh = {1 => 2, 3 => 4, 5 => 6}  
-  big_hash = {}
-  64.times { |k| big_hash[k.to_s] = k }    
-     
-  # it "raises a RuntimeError if #rehash is called from block" do
-  #   h = hsh.dup
-  #   args = @method.to_s[/merge|update/] ? [h] : []
-  #   
-  #   lambda {
-  #     h.send(@method, *args) { h.rehash }
-  #   }.should raise_error(RuntimeError)
-  # end
-  # 
-  # # This specification seems arbitrary, but describes the behavior of MRI
-  # it "raises if more than 63 new entries are added from block" do
-  #   h = hsh.dup
-  #   args = @method.to_s[/merge|update/] ? [h] : []
-  # 
-  #   lambda {
-  #     h.send(@method, *args) { |*x| h.merge!(big_hash) }
-  #   }.should raise_error(RuntimeError)
-  # end
+describe :hash_iteration_modifying, :shared => true do
+  # TODO: Revise this test as per the outcome of
+  # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/23630
+  ruby_bug "ruby-core[#23630]", "1.9.129" do
+    it "does not affect yielded items by removing the current element" do
+      hsh = new_hash(1 => 2, 3 => 4, 5 => 6)
+      big_hash = new_hash
+      100.times { |k| big_hash[k.to_s] = k }
+      n = 3
 
-end
+      h = Array.new(n) { hsh.dup }
+      args = Array.new(n) { |i| @method.to_s[/merge|update/] ? [h[i]] : [] }
+      r = Array.new(n) { [] }
 
-describe :hash_iteration_modifying, :shared => true do
-  hsh = {1 => 2, 3 => 4, 5 => 6}  
-  big_hash = {}
-  100.times { |k| big_hash[k.to_s] = k }    
-     
-  it "does not affect yielded items by removing the current element" do
-    n = 3
-  
-    h = Array.new(n) { hsh.dup }
-    args = Array.new(n) { |i| @method.to_s[/merge|update/] ? [h[i]] : [] }
-    r = Array.new(n) { [] }
-  
-    h[0].send(@method, *args[0]) { |*x| r[0] << x; true }
-    h[1].send(@method, *args[1]) { |*x| r[1] << x; h[1].shift; true }
-    h[2].send(@method, *args[2]) { |*x| r[2] << x; h[2].delete(h[2].keys.first); true }
-  
-    r[1..-1].each do |yielded|
-      yielded.should == r[0]
+      h[0].send(@method, *args[0]) { |*x| r[0] << x; true }
+      h[1].send(@method, *args[1]) { |*x| r[1] << x; h[1].shift; true }
+      h[2].send(@method, *args[2]) { |*x| r[2] << x; h[2].delete(h[2].keys.first); true }
+
+      r[1..-1].each do |yielded|
+        yielded.should == r[0]
+      end
     end
   end
 end
 
 describe :hash_iteration_no_block, :shared => true do
   before(:each) do
-    @hsh = {1 => 2, 3 => 4, 5 => 6}
-    @empty = {}
+    @hsh = new_hash(1 => 2, 3 => 4, 5 => 6)
+    @empty = new_hash
   end
-  
+
   ruby_version_is "" ... "1.8.7" do
     it "raises a LocalJumpError when called on a non-empty hash without a block" do
       lambda { @hsh.send(@method) }.should raise_error(LocalJumpError)
@@ -70,11 +41,11 @@
 
   ruby_version_is "1.8.7" do
     it "returns an Enumerator if called on a non-empty hash without a block" do
-      @hsh.send(@method).should be_kind_of(Enumerable::Enumerator)
+      @hsh.send(@method).should be_kind_of(enumerator_class)
     end
 
     it "returns an Enumerator if called on an empty hash without a block" do
-      @empty.send(@method).should be_kind_of(Enumerable::Enumerator)
+      @empty.send(@method).should be_kind_of(enumerator_class)
     end
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/shared/key.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/key.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/key.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,6 +1,6 @@
 describe :hash_key_p, :shared => true do
   it "returns true if argument is a key" do
-    h = { :a => 1, :b => 2, :c => 3, 4 => 0 }
+    h = new_hash(:a => 1, :b => 2, :c => 3, 4 => 0)
     h.send(@method, :a).should == true
     h.send(@method, :b).should == true
     h.send(@method, 'b').should == false
@@ -10,16 +10,16 @@
   end
 
   it "returns true if the key's matching value was nil" do
-    { :xyz => nil }.send(@method, :xyz).should == true
+    new_hash(:xyz => nil).send(@method, :xyz).should == true
   end
 
   it "returns true if the key's matching value was false" do
-    { :xyz => false }.send(@method, :xyz).should == true
+    new_hash(:xyz => false).send(@method, :xyz).should == true
   end
 
   it "returns true if the key is nil" do
-    { nil => 'b'}.send(@method, nil).should == true
-    { nil => nil}.send(@method, nil).should == true
+    new_hash(nil => 'b').send(@method, nil).should == true
+    new_hash(nil => nil).send(@method, nil).should == true
   end
 
   it "returns false for objects with the same hash" do
@@ -29,6 +29,6 @@
     o2 = Object.new
     def o2.hash() 0 end
 
-    { o1 => nil }.send(@method, o2).should == false
+    new_hash(o1 => nil).send(@method, o2).should == false
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/shared/length.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/length.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/length.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,10 +1,10 @@
 describe :hash_length, :shared => true do
   it "returns the number of entries" do
-    {:a => 1, :b => 'c'}.send(@method).should == 2
-    {:a => 1, :b => 2, :a => 2}.send(@method).should == 2
-    {:a => 1, :b => 1, :c => 1}.send(@method).should == 3
-    {}.send(@method).should == 0
-    Hash.new(5).send(@method).should == 0
-    Hash.new { 5 }.send(@method).should == 0
+    new_hash(:a => 1, :b => 'c').send(@method).should == 2
+    new_hash(:a => 1, :b => 2, :a => 2).send(@method).should == 2
+    new_hash(:a => 1, :b => 1, :c => 1).send(@method).should == 3
+    new_hash().send(@method).should == 0
+    new_hash(5).send(@method).should == 0
+    new_hash { 5 }.send(@method).should == 0
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/shared/replace.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/replace.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/replace.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,38 +1,38 @@
 describe :hash_replace, :shared => true do
   it "replaces the contents of self with other" do
-    h = { :a => 1, :b => 2 }
+    h = new_hash(:a => 1, :b => 2)
     h.send(@method, :c => -1, :d => -2).should equal(h)
-    h.should == { :c => -1, :d => -2 }
+    h.should == new_hash(:c => -1, :d => -2)
   end
 
   it "tries to convert the passed argument to a hash using #to_hash" do
     obj = mock('{1=>2,3=>4}')
-    obj.should_receive(:to_hash).and_return({1 => 2, 3 => 4})
+    obj.should_receive(:to_hash).and_return(new_hash(1 => 2, 3 => 4))
 
-    h = {}
+    h = new_hash
     h.send(@method, obj)
-    h.should == {1 => 2, 3 => 4}
+    h.should == new_hash(1 => 2, 3 => 4)
   end
 
   it "calls to_hash on hash subclasses" do
-    h = {}
+    h = new_hash
     h.send(@method, ToHashHash[1 => 2])
-    h.should == {1 => 2}
+    h.should == new_hash(1 => 2)
   end
 
   it "does not transfer default values" do
-    hash_a = {}
-    hash_b = Hash.new(5)
+    hash_a = new_hash
+    hash_b = new_hash 5
     hash_a.send(@method, hash_b)
     hash_a.default.should == 5
 
-    hash_a = {}
-    hash_b = Hash.new { |h, k| k * 2 }
+    hash_a = new_hash
+    hash_b = new_hash { |h, k| k * 2 }
     hash_a.send(@method, hash_b)
     hash_a.default(5).should == 10
 
-    hash_a = Hash.new { |h, k| k * 5 }
-    hash_b = Hash.new(lambda { raise "Should not invoke lambda" })
+    hash_a = new_hash { |h, k| k * 5 }
+    hash_b = new_hash(lambda { raise "Should not invoke lambda" })
     hash_a.send(@method, hash_b)
     hash_a.default.should == hash_b.default
   end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/shared/store.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/store.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/store.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,21 +1,21 @@
 describe :hash_store, :shared => true do
   it "associates the key with the value and return the value" do
-    h = { :a => 1 }
+    h = new_hash(:a => 1)
     h.send(@method, :b, 2).should == 2
-    h.should == {:b=>2, :a=>1}
+    h.should == new_hash(:b=>2, :a=>1)
   end
 
   it "duplicates string keys using dup semantics" do
     # dup doesn't copy singleton methods
     key = "foo"
     def key.reverse() "bar" end
-    h = {}
+    h = new_hash
     h.send(@method, key, 0)
     h.keys[0].reverse.should == "oof"
   end
 
   it "stores unequal keys that hash to the same value" do
-    h = {}
+    h = new_hash
     k1 = ["x"]
     k2 = ["y"]
     # So they end up in the same bucket
@@ -29,11 +29,11 @@
 
   it "duplicates and freezes string keys" do
     key = "foo"
-    h = {}
+    h = new_hash
     h.send(@method, key, 0)
     key << "bar"
 
-    h.should == { "foo" => 0 }
+    h.should == new_hash("foo" => 0)
     h.keys[0].frozen?.should == true
   end
 

Added: MacRuby/branches/experimental/spec/frozen/core/hash/shared/to_s.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/to_s.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/to_s.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,66 @@
+require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.dirname(__FILE__) + '/../fixtures/classes'
+
+describe :to_s, :shared => true do
+
+  it "returns a string representation with same order as each()" do
+    h = new_hash(:a => [1, 2], :b => -2, :d => -6, nil => nil)
+    
+    pairs = []
+    h.each do |key, value|
+      pairs << key.inspect + '=>' + value.inspect
+    end
+    
+    str = '{' + pairs.join(', ') + '}'
+    h.send(@method).should == str
+  end
+
+  it "calls inspect on keys and values" do
+    key = mock('key')
+    val = mock('val')
+    key.should_receive(:inspect).and_return('key')
+    val.should_receive(:inspect).and_return('val')
+    
+    new_hash(key => val).send(@method).should == '{key=>val}'
+  end
+
+  # There is an inconsistency in the behaviour of #to_s/#inspect on 1.9.1.
+  # ujihisa fixed it and we're waiting for his patch to be committed. See
+  # http://redmine.ruby-lang.org/issues/show/1533 for details. 
+  ruby_bug "1533", "1.9.1.129" do
+    it "handles recursive hashes" do
+      x = new_hash
+      x[0] = x
+      x.send(@method).should == '{0=>{...}}'
+
+      x = new_hash
+      x[x] = 0
+      x.send(@method).should == '{{...}=>0}'
+
+      x = new_hash
+      x[x] = x
+      x.send(@method).should == '{{...}=>{...}}'
+
+      x = new_hash
+      y = new_hash
+      x[0] = y
+      y[1] = x
+      x.send(@method).should == "{0=>{1=>{...}}}"
+      y.send(@method).should == "{1=>{0=>{...}}}"
+
+      x = new_hash
+      y = new_hash
+      x[y] = 0
+      y[x] = 1
+      x.send(@method).should == "{{{...}=>1}=>0}"
+      y.send(@method).should == "{{{...}=>0}=>1}"
+      
+      x = new_hash
+      y = new_hash
+      x[y] = x
+      y[x] = y
+      x.send(@method).should == "{{{...}=>{...}}=>{...}}"
+      y.send(@method).should == "{{{...}=>{...}}=>{...}}"
+    end
+  end    
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/shared/update.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/update.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/update.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,32 +1,32 @@
 describe :hash_update, :shared => true do
   it "adds the entries from other, overwriting duplicate keys. Returns self" do
-    h = { :_1 => 'a', :_2 => '3' }
+    h = new_hash(:_1 => 'a', :_2 => '3')
     h.send(@method, :_1 => '9', :_9 => 2).should equal(h)
-    h.should == {:_1 => "9", :_2 => "3", :_9 => 2}
+    h.should == new_hash(:_1 => "9", :_2 => "3", :_9 => 2)
   end
 
   it "sets any duplicate key to the value of block if passed a block" do
-    h1 = { :a => 2, :b => -1 }
-    h2 = { :a => -2, :c => 1 }
+    h1 = new_hash(:a => 2, :b => -1)
+    h2 = new_hash(:a => -2, :c => 1)
     h1.send(@method, h2) { |k,x,y| 3.14 }.should equal(h1)
-    h1.should == {:c => 1, :b => -1, :a => 3.14}
+    h1.should == new_hash(:c => 1, :b => -1, :a => 3.14)
 
     h1.send(@method, h1) { nil }
-    h1.should == { :a => nil, :b => nil, :c => nil }
+    h1.should == new_hash(:a => nil, :b => nil, :c => nil)
   end
 
   it "tries to convert the passed argument to a hash using #to_hash" do
     obj = mock('{1=>2}')
-    obj.should_receive(:to_hash).and_return({1 => 2})
-    {3 => 4}.send(@method, obj).should == {1 => 2, 3 => 4}
+    obj.should_receive(:to_hash).and_return(new_hash(1 => 2))
+    new_hash(3 => 4).send(@method, obj).should == new_hash(1 => 2, 3 => 4)
   end
 
-  it "does not call to_hash on hash subclasses" do    
-    {3 => 4}.send(@method, ToHashHash[1 => 2]).should == {1 => 2, 3 => 4}
+  it "does not call to_hash on hash subclasses" do
+    new_hash(3 => 4).send(@method, ToHashHash[1 => 2]).should == new_hash(1 => 2, 3 => 4)
   end
 
   it "processes entries with same order as merge()" do
-    h = {1 => 2, 3 => 4, 5 => 6, "x" => nil, nil => 5, [] => []}
+    h = new_hash(1 => 2, 3 => 4, 5 => 6, "x" => nil, nil => 5, [] => [])
     merge_bang_pairs = []
     merge_pairs = []
     h.merge(h) { |*arg| merge_pairs << arg }

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/shared/value.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/value.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/value.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,14 +1,14 @@
 describe :hash_value_p, :shared => true do
   it "returns true if the value exists in the hash" do
-    {:a => :b}.send(@method, :a).should == false
-    {1 => 2}.send(@method, 2).should == true
-    h = Hash.new(5)
+    new_hash(:a => :b).send(@method, :a).should == false
+    new_hash(1 => 2).send(@method, 2).should == true
+    h = new_hash 5
     h.send(@method, 5).should == false
-    h = Hash.new { 5 }
+    h = new_hash { 5 }
     h.send(@method, 5).should == false
   end
 
   it "uses == semantics for comparing values" do
-    { 5 => 2.0 }.send(@method, 2).should == true
+    new_hash(5 => 2.0).send(@method, 2).should == true
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/shift_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shift_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shift_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,27 +2,27 @@
 require File.dirname(__FILE__) + '/fixtures/classes'
 
 describe "Hash#shift" do
-  it "removes a pair from hash and return it (same order as to_a)" do
-    h = { :a => 1, :b => 2, "c" => 3, nil => 4, [] => 5 }
-    pairs = h.to_a
+  it "removes a pair from hash and return it" do
+    h = new_hash(:a => 1, :b => 2, "c" => 3, nil => 4, [] => 5)
+    h2 = h.dup
 
-    h.size.times do
+    h.size.times do |i|
       r = h.shift
       r.class.should == Array
-      r.should == pairs.shift
-      h.size.should == pairs.size
+      h2[r.first].should == r.last
+      h.size.should == h2.size - i - 1
     end
 
-    h.should == {}
+    h.should == new_hash
   end
 
   it "returns nil from an empty hash " do
-    {}.shift.should == nil
+    new_hash.shift.should == nil
   end
 
   it "returns (computed) default for empty hashes" do
-    Hash.new(5).shift.should == 5
-    h = Hash.new { |*args| args }
+    new_hash(5).shift.should == 5
+    h = new_hash { |*args| args }
     h.shift.should == [h, nil]
   end
 

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/sort_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/sort_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/sort_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,14 +3,15 @@
 
 describe "Hash#sort" do
   it "converts self to a nested array of [key, value] arrays and sort with Array#sort" do
-    { 'a' => 'b', '1' => '2', 'b' => 'a' }.sort.should == [["1", "2"], ["a", "b"], ["b", "a"]]
+    new_hash('a' => 'b', '1' => '2', 'b' => 'a').sort.should ==
+      [["1", "2"], ["a", "b"], ["b", "a"]]
   end
-  
+
   it "works when some of the keys are themselves arrays" do
-    { [1,2] => 5, [1,1] => 5 }.sort.should == [[[1,1],5], [[1,2],5]]
+    new_hash([1,2] => 5, [1,1] => 5).sort.should == [[[1,1],5], [[1,2],5]]
   end
-  
+
   it "uses block to sort array if passed a block" do
-    { 1 => 2, 2 => 9, 3 => 4 }.sort { |a,b| b <=> a }.should == [[3, 4], [2, 9], [1, 2]]
+    new_hash(1 => 2, 2 => 9, 3 => 4).sort { |a,b| b <=> a }.should == [[3, 4], [2, 9], [1, 2]]
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/to_a_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/to_a_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/to_a_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,13 +3,13 @@
 
 describe "Hash#to_a" do
   it "returns a list of [key, value] pairs with same order as each()" do
-    h = {:a => 1, 1 => :a, 3 => :b, :b => 5}
+    h = new_hash(:a => 1, 1 => :a, 3 => :b, :b => 5)
     pairs = []
 
     h.each_pair do |*pair|
       pairs << pair
     end
-    
+
     h.to_a.class.should == Array
     h.to_a.should == pairs
   end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/to_hash_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/to_hash_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/to_hash_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,7 +3,7 @@
 
 describe "Hash#to_hash" do
   it "returns self" do
-    h = {}
+    h = new_hash
     h.to_hash.should equal(h)
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/to_s_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/to_s_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/to_s_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,12 +1,20 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/to_s'
 
 describe "Hash#to_s" do
-  it "returns a string by calling Hash#to_a and using Array#join with default separator" do
-    h = { :fun => 'x', 1 => 3, nil => "ok", [] => :y }
-    h.to_a.to_s.should == h.to_s
-    old, $, = $,, ':'
-    h.to_a.to_s.should == h.to_s
-    $, = old
+
+  ruby_version_is "1.9" do
+    it_behaves_like :to_s, :to_s
   end
-end
+  
+  ruby_version_is ""..."1.9" do
+    it "returns a string by calling Hash#to_a and using Array#join with default separator" do
+      h = new_hash(:fun => 'x', 1 => 3, nil => "ok", [] => :y)
+      h.to_a.to_s.should == h.to_s
+      old, $, = $,, ':'
+      h.to_a.to_s.should == h.to_s
+      $, = old
+    end
+  end
+end  

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/update_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/update_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/update_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -6,8 +6,6 @@
 describe "Hash#update" do
   it_behaves_like(:hash_update, :update)
 
-  it_behaves_like(:hash_iteration_method, :update)
-
   compliant_on :rubinius do
     it_behaves_like(:hash_iteration_modifying, :update)
   end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/values_at_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/values_at_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/values_at_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,7 +3,7 @@
 
 describe :hash_values_at, :shared => true do
   it "returns an array of values for the given keys" do
-    h = {:a => 9, :b => 'a', :c => -10, :d => nil}
+    h = new_hash(:a => 9, :b => 'a', :c => -10, :d => nil)
     h.send(@method).class.should == Array
     h.send(@method).should == []
     h.send(@method, :a, :d, :b).class.should == Array
@@ -13,4 +13,4 @@
 
 describe "Hash#values_at" do
   it_behaves_like(:hash_values_at, :values_at)
-end
\ No newline at end of file
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/hash/values_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/values_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/values_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,7 +3,7 @@
 
 describe "Hash#values" do
   it "returns an array of values" do
-    h = { 1 => :a, 'a' => :a, 'the' => 'lang'}
+    h = new_hash(1 => :a, 'a' => :a, 'the' => 'lang')
     h.values.class.should == Array
     h.values.sort {|a, b| a.to_s <=> b.to_s}.should == [:a, :a, 'lang']
   end

Added: MacRuby/branches/experimental/spec/frozen/core/integer/constructor_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/integer/constructor_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/integer/constructor_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,56 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'rational'
+
+describe "Integer()" do
+  it "returns a Fixnum or Bignum object" do
+    Integer(2).should be_an_instance_of(Fixnum)
+    Integer(9**99).should be_an_instance_of(Bignum)
+  end
+  
+  it "calls to_i on a non-numeric argument" do
+    nine = mock('9')
+    nine.should_receive(:to_i).and_return(9)
+    Integer(nine).should == 9
+    Integer('200').should == 200
+  end
+  
+  it "truncates Floats" do
+    Integer(3.14).should == 3
+    Integer(90.8).should == 90
+  end
+    
+  it "calls to_i on Rationals" do
+    Integer(Rational(8,3)).should == 2
+    Integer(3.quo(2)).should == 1
+  end
+
+  it "passes through Bignums as-is" do
+    bignum = 99**99
+    bignum.should be_an_instance_of(Bignum)
+    Integer(bignum).should == bignum
+    Integer(bignum).should be_an_instance_of(Bignum)
+  end
+
+  it "passes through Fixnums as-is" do
+    fixnum = 99
+    fixnum.should be_an_instance_of(Fixnum)
+    Integer(fixnum).should == fixnum
+    Integer(fixnum).should be_an_instance_of(Fixnum)
+  end
+
+  ruby_version_is "1.9" do
+    it "raises a TypeError when passed nil" do
+      lambda { Integer(nil) }.should raise_error(TypeError)
+    end
+  end
+  
+  ruby_version_is ""..."1.9" do
+    it "returns 0 when passed nil" do
+      Integer(nil).should == 0
+    end
+  end
+
+  it "raises a FloatDomainError when passed NaN" do
+    lambda { Integer(0.0/0.0) }.should raise_error(FloatDomainError)
+  end  
+end

Added: MacRuby/branches/experimental/spec/frozen/core/io/bytes_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/bytes_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/io/bytes_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,38 @@
+# encoding: utf-8
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+ruby_version_is '1.8.7' do
+  describe "IO#bytes" do
+    before :each do
+      @original = $KCODE
+      $KCODE = "UTF-8"
+      @io = File.open(IOSpecs.gets_fixtures)
+    end
+
+    after :each do
+      @io.close unless @io.closed?
+      $KCODE = @original
+    end
+
+    it "returns an enumerator of the next bytes from the stream" do
+      enum = @io.bytes
+      enum.should be_kind_of(enumerator_class)
+      @io.readline.should == "Voici la ligne une.\n"
+      enum.first(5).should == [81, 117, 105, 32, 195]
+    end
+
+    it "ignores a block" do
+      @io.bytes{ raise "oups" }.should be_kind_of(enumerator_class)
+    end
+
+    it "raises IOError on closed stream" do
+      enum = IOSpecs.closed_file.bytes
+      lambda { enum.first }.should raise_error(IOError)
+      enum = @io.bytes
+      enum.first.should == 86
+      @io.close
+      lambda { enum.first }.should raise_error(IOError)      
+    end
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/core/io/chars_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/chars_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/io/chars_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,40 @@
+# encoding: utf-8
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+ruby_version_is '1.8.7' do
+  describe "IO#chars" do
+    before :each do
+      @original = $KCODE
+      $KCODE = "UTF-8"
+      @io = File.open(IOSpecs.gets_fixtures)
+    end
+
+    after :each do
+      @io.close unless @io.closed?
+      $KCODE = @original
+    end
+
+    it "returns an enumerator of the next chars from the stream" do
+      enum = @io.chars
+      enum.should be_kind_of(enumerator_class)
+      @io.readline.should == "Voici la ligne une.\n"
+      enum.first(5).should == ["Q", "u", "i", " ", "è"]
+    end
+
+    ruby_version_is '1.9' do
+      it "ignores a block" do
+        @io.chars{ raise "oups" }.should be_kind_of(enumerator_class)
+      end
+    end
+
+    it "raises IOError on closed stream" do
+      enum = IOSpecs.closed_file.chars
+      lambda { enum.first }.should raise_error(IOError)
+      enum = @io.chars
+      enum.first.should == "V"
+      @io.close
+      lambda { enum.first }.should raise_error(IOError)      
+    end
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/io/each_byte_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/each_byte_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/io/each_byte_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,6 +2,14 @@
 require File.dirname(__FILE__) + '/fixtures/classes'
 
 describe "IO#each_byte" do
+  before(:each) do
+    @io = File.open(IOSpecs.gets_fixtures)
+  end
+  
+  after(:each) do
+    @io.close
+  end
+  
   it "raises IOError on closed stream" do
     # each_byte must have a block in order to raise the Error.
     # MRI 1.8.7 returns enumerator if block is not provided.
@@ -10,18 +18,14 @@
   end
 
   it "yields each byte" do
-    open IOSpecs.gets_fixtures do |io|
-      bytes = []
+    bytes = []
 
-      io.each_byte do |byte|
-        bytes << byte if bytes.length < 5
-        # I'm not sure that the break statement is implemented in MR yet,
-        # so I added an if to ensure equivalent behavior.
-        # break if bytes.length >= 5
-      end
+    @io.each_byte do |byte|
+      bytes << byte
+      break if bytes.length >= 5
+    end
 
-      bytes.should == [86, 111, 105, 99, 105]
-    end
+    bytes.should == [86, 111, 105, 99, 105]
   end
 
   it "works on empty streams" do
@@ -32,4 +36,19 @@
     f.close
     File.unlink(tmp("io-each-byte-spec"))
   end
+  
+  ruby_version_is "" ... "1.8.7" do
+    it "yields a LocalJumpError when passed no block" do
+      lambda { @io.each_byte }.should raise_error(LocalJumpError)
+    end
+  end
+
+  ruby_version_is "1.8.7" do
+    it "returns an Enumerator when passed no block" do
+      enum = @io.each_byte
+      enum.instance_of?(enumerator_class).should be_true
+      enum.each.first(10).should == [86, 111, 105, 99, 105, 32, 108, 97, 32, 108]
+    end
+  end
+  
 end

Added: MacRuby/branches/experimental/spec/frozen/core/io/each_char_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/each_char_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/io/each_char_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,49 @@
+# encoding: utf-8
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+ruby_version_is '1.8.7' do
+  describe "IO#each_char" do
+    before :each do
+      @original = $KCODE
+      $KCODE = "UTF-8"
+      @io = File.open(IOSpecs.gets_fixtures)
+    end
+
+    after :each do
+      @io.close unless @io.closed?
+      $KCODE = @original
+    end
+
+    it "raises IOError on closed stream" do
+      lambda { IOSpecs.closed_file.each_char {} }.should raise_error(IOError)
+    end
+
+    it "yields each character" do
+      @io.readline.should == "Voici la ligne une.\n"
+      chars = []
+
+      @io.each_char do |c|
+        chars << c
+        break if chars.length >= 5
+      end
+
+      chars.should == ["Q", "u", "i", " ", "è"]
+    end
+
+    it "works on empty streams" do
+      f = File.new(tmp("io-each-char-spec"), "w+")
+      lambda {
+        f.each_char { |b| raise IOError }
+      }.should_not raise_error
+      f.close
+      File.unlink(tmp("io-each-char-spec"))
+    end
+
+    it "returns an Enumerator when passed no block" do
+      enum = @io.each_char
+      enum.instance_of?(enumerator_class).should be_true
+      enum.each.first(5).should == ["V", "o", "i", "c", "i"]
+    end
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/io/fixtures/classes.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/fixtures/classes.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/io/fixtures/classes.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,3 +1,4 @@
+# encoding: utf-8
 module IOSpecs
   def self.lines
     [ "Voici la ligne une.\n",

Added: MacRuby/branches/experimental/spec/frozen/core/io/getbyte_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/getbyte_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/io/getbyte_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,42 @@
+# encoding: utf-8
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+ruby_version_is '1.8.7' do
+  describe "IO#getbyte" do
+    before :each do
+      @original = $KCODE
+      $KCODE = "UTF-8"
+      @file_name = File.dirname(__FILE__) + '/fixtures/readlines.txt'
+      @file = File.open(@file_name, 'r')
+    end
+
+    after :each do
+      @file.close unless @file.closed?
+      $KCODE = @original
+    end
+
+    it "returns the next byte from the stream" do
+      @file.readline.should == "Voici la ligne une.\n"
+      letters = @file.getbyte, @file.getbyte, @file.getbyte, @file.getbyte, @file.getbyte
+      letters.should == [81, 117, 105, 32, 195]
+    end
+
+    it "returns nil when invoked at the end of the stream" do
+      # read entire content
+      @file.read
+      @file.getbyte.should == nil
+    end
+
+    it "returns nil on empty stream" do
+      File.open(tmp('empty.txt'), "w+") { |empty|
+        empty.getbyte.should == nil
+      }
+      File.unlink(tmp("empty.txt"))
+    end
+
+    it "raises IOError on closed stream" do
+      lambda { IOSpecs.closed_file.getbyte }.should raise_error(IOError)
+    end
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/io/getc_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/getc_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/io/getc_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,33 +3,30 @@
 
 describe "IO#getc" do
   before :each do
+    @original = $KCODE
+    $KCODE = "UTF-8"
     @file_name = File.dirname(__FILE__) + '/fixtures/readlines.txt'
     @file = File.open(@file_name, 'r')
   end
 
   after :each do
     @file.close unless @file.closed?
+    $KCODE = @original
   end
 
-  ruby_version_is "" ... "1.9" do
+  ruby_version_is ''...'1.9' do
     it "returns the next byte from the stream" do
-      @file.getc.should == 86
-      @file.getc.should == 111
-      @file.getc.should == 105
-      # read the rest of line
-      @file.readline.should == "ci la ligne une.\n"
-      @file.getc.should == 81
+      @file.readline.should == "Voici la ligne une.\n"
+      letters = @file.getc, @file.getc, @file.getc, @file.getc, @file.getc
+      letters.should == [81, 117, 105, 32, 195]
     end
   end
 
-  ruby_version_is "1.9" do
+  ruby_version_is '1.9' do
     it "returns the next character from the stream" do
-      @file.getc.should == 'V'
-      @file.getc.should == 'o'
-      @file.getc.should == 'i'
-      # read the rest of line
-      @file.readline.should == "ci la ligne une.\n"
-      @file.getc.should == 'Q'
+      @file.readline.should == "Voici la ligne une.\n"
+      letters = @file.getc, @file.getc, @file.getc, @file.getc, @file.getc
+      letters.should == ["Q", "u", "i", " ", "è"]
     end
   end
 

Modified: MacRuby/branches/experimental/spec/frozen/core/io/gets_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/gets_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/io/gets_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,3 +1,4 @@
+# encoding: utf-8
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
 

Added: MacRuby/branches/experimental/spec/frozen/core/io/lines_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/lines_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/io/lines_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,34 @@
+# encoding: utf-8
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+ruby_version_is '1.8.7' do
+  describe "IO#lines" do
+    before(:each) do
+      @io = File.open(IOSpecs.gets_fixtures)
+    end
+  
+    after(:each) do
+      @io.close
+    end
+
+    it "returns an Enumerator" do
+      enum = @io.lines
+      enum.instance_of?(enumerator_class).should be_true
+  
+      enum.to_a.should == ["Voici la ligne une.\n",
+       "Qui è la linea due.\n",
+       "\n",
+       "\n",
+       "Aquí está la línea tres.\n",
+       "Ist hier Linie vier.\n",
+       "\n",
+       "Está aqui a linha cinco.\n",
+       "Here is line six.\n"]
+    end
+  
+    it "ignores a given block" do
+      @io.lines{ raise "oups" }.instance_of?(enumerator_class).should be_true
+    end
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/io/read_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/read_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/io/read_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,3 +1,4 @@
+# encoding: utf-8
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
 
@@ -99,7 +100,7 @@
   end
 
   it "can read lots of data" do
-    data = "\xaa" * (8096 * 2 + 1024) # HACK IO::BufferSize
+    data = "*" * (8096 * 2 + 1024) # HACK IO::BufferSize
 
     File.open @fname, 'w' do |io| io.write data end
 
@@ -110,12 +111,12 @@
     end
 
     actual.length.should == data.length
-    actual.split('').all? { |c| c == "\xaa" }.should == true
+    actual.split('').all? { |c| c == "*" }.should == true
   end
 
   it "can read lots of data with length" do
     read_length = 8096 * 2 + 1024 # HACK IO::BufferSize
-    data = "\xaa" * (read_length + 8096) # HACK same
+    data = "*" * (read_length + 8096) # HACK same
 
     File.open @fname, 'w' do |io| io.write data end
 
@@ -126,7 +127,7 @@
     end
 
     actual.length.should == read_length
-    actual.split('').all? { |c| c == "\xaa" }.should == true
+    actual.split('').all? { |c| c == "*" }.should == true
   end
 
   it "consumes zero bytes when reading zero bytes" do
@@ -226,5 +227,17 @@
   it "raises IOError on closed stream" do
     lambda { IOSpecs.closed_file.read }.should raise_error(IOError)
   end
+
+  it "ignores unicode encoding" do
+    begin
+      old = $KCODE
+      $KCODE = "UTF-8"
+      File.open(File.dirname(__FILE__) + '/fixtures/readlines.txt', 'r') do |io|
+        io.readline.should == "Voici la ligne une.\n"
+        io.read(5).should == "Qui " + [195].pack("C")
+      end
+    ensure
+      $KCODE = old
+    end
+  end
 end
-

Modified: MacRuby/branches/experimental/spec/frozen/core/io/shared/each.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/shared/each.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/io/shared/each.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -69,7 +69,7 @@
   ruby_version_is "1.8.7" do
     it "returns an Enumerator when passed no block" do
       enum = @io.send(@method)
-      enum.instance_of?(Enumerable::Enumerator).should be_true
+      enum.instance_of?(enumerator_class).should be_true
       
       seen = []
       enum.each { |b| seen << b }

Modified: MacRuby/branches/experimental/spec/frozen/core/io/sysread_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/sysread_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/io/sysread_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -50,10 +50,19 @@
     @file.sysread(5).should == "56789"
   end
   
-  it "throws IOError when called immediately after a buffered IO#read" do
-    @file.read(15)
-    lambda { @file.sysread(5) }.should raise_error(IOError)
+  ruby_version_is "" ... "1.9" do
+    it "throws IOError when called immediately after a buffered IO#read" do
+      @file.read(15)
+      lambda { @file.sysread(5) }.should raise_error(IOError)
+    end
   end
+
+  ruby_version_is "1.9" do
+    it "reads normally even when called immediately after a buffered IO#read" do
+      @file.read(15)
+      @file.sysread(5).should == "56789"
+    end
+  end
   
   it "does not raise error if called after IO#read followed by IO#write" do
     @file.read(5)

Modified: MacRuby/branches/experimental/spec/frozen/core/io/ungetc_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/io/ungetc_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/io/ungetc_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,5 +1,15 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 
+ruby_version_is "1.9" do
+  class IO
+    alias getc_orig getc
+    def getc
+      s = getc_orig
+      s ? s.ord : s
+    end
+  end
+end
+
 describe "IO#ungetc" do
   before :each do
     @file_name = File.dirname(__FILE__) + '/fixtures/readlines.txt'
@@ -93,10 +103,18 @@
     lambda { @file.sysread(1) }.should raise_error(IOError)
   end
 
-  it "raises IOError when invoked on stream that was not yet read" do
-    lambda { @file.ungetc(100) }.should raise_error(IOError)
+  ruby_version_is "" ... "1.9" do
+    it "raises IOError when invoked on stream that was not yet read" do
+      lambda { @file.ungetc(100) }.should raise_error(IOError)
+    end
   end
 
+  ruby_version_is "1.9" do
+    it "returns nil when invoked on stream that was not yet read" do
+      @file.ungetc(100).should be_nil
+    end
+  end
+
   it "raises IOError on closed stream" do
     @file.getc
     @file.close

Added: MacRuby/branches/experimental/spec/frozen/core/kernel/__callee__spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/__callee__spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/__callee__spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,9 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/__method__'
+
+describe "Kernel.__callee__" do
+  ruby_version_is '1.9' do
+    it_behaves_like(:kernel___method__, :__callee__)
+  end
+end

Added: MacRuby/branches/experimental/spec/frozen/core/kernel/__method__spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/__method__spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/__method__spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,9 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/__method__'
+
+describe "Kernel.__method__" do
+  ruby_version_is '1.8.7' do
+    it_behaves_like(:kernel___method__, :__method__)
+  end
+end

Added: MacRuby/branches/experimental/spec/frozen/core/kernel/define_singleton_method.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/define_singleton_method.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/define_singleton_method.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,63 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+ruby_version_is '1.9' do
+  describe "Kernel#define_singleton_method" do
+    describe "when given an UnboundMethod" do
+      class DefineSingletonMethodSpecClass
+        MY_CONST = 42
+        define_singleton_method(:another_test_method, self.method(:constants))
+      end
+
+      it "correctly calls the new method" do
+        klass = DefineSingletonMethodSpecClass
+        klass.another_test_method.should == klass.constants
+      end
+
+      it "adds the new method to the methods list" do
+        DefineSingletonMethodSpecClass.should have_method(:another_test_method)
+      end
+    end
+
+    it "defines a new method with the given name and the given block as body in self" do
+      class DefineSingletonMethodSpecClass
+        define_singleton_method(:block_test1) { self }
+        define_singleton_method(:block_test2, &lambda { self })
+      end
+    
+      o = DefineSingletonMethodSpecClass
+      o.block_test1.should == o
+      o.block_test2.should == o
+    end
+  
+    it "raises a TypeError when the given method is no Method/Proc" do
+      lambda {
+        Class.new { define_singleton_method(:test, "self") }
+      }.should raise_error(TypeError)
+    
+      lambda {
+        Class.new { define_singleton_method(:test, 1234) }
+      }.should raise_error(TypeError)
+    end
+  
+    it "defines a new singleton method for objects" do
+      s = "hello"
+      s.define_singleton_method(:test) { "world!" }
+      s.test.should == "world!"
+      lambda {
+        "hello".test
+      }.should raise_error(NoMethodError)
+    end
+
+    it "maintains the Proc's scope" do
+      class DefineMethodByProcClass
+        in_scope = true
+        method_proc = proc { in_scope }
+      
+        define_singleton_method(:proc_test, &method_proc)
+      end
+    
+      DefineMethodByProcClass.proc_test.should == true
+    end
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/loop_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/loop_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/loop_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -28,15 +28,30 @@
     end.should == nil
   end
 
-  it "raises a LocalJumpError if no block given" do
-    lambda { loop }.should raise_error(LocalJumpError)
+  ruby_version_is ""..."1.9" do
+    it "raises a LocalJumpError if no block given" do
+      lambda { loop }.should raise_error(LocalJumpError)
+    end
   end
 
   ruby_version_is "1.9" do
+    it "returns an enumerator if no block given" do
+      enum = loop
+      enum.instance_of?(enumerator_class).should be_true
+      cnt = 0
+      enum.each do |*args|
+        raise "Args should be empty #{args.inspect}" unless args.empty?
+        cnt += 1
+        break cnt if cnt >= 42
+      end.should == 42
+    end
+  end
+
+  ruby_version_is "1.8.7" do
     it "rescues StopIteration" do
       n = 42
       loop do
-	raise StopIteration
+        raise StopIteration
       end
       42.should == 42
     end
@@ -45,7 +60,7 @@
       finish = Class::new StopIteration
       n = 42
       loop do
-	raise finish
+        raise finish
       end
       42.should == 42
     end

Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/methods_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/methods_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/methods_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -15,70 +15,144 @@
   end
 end
 
-describe "Kernel#methods" do
+# On Ruby < 1.9 #methods returns an Array of Strings
+ruby_version_is ""..."1.9" do
+  describe "Kernel#methods" do
 
-  it "picks up methods added via self.meth" do
-    KernelSpecs::Methods.methods(false).should include("ichi")
-  end
+    it "picks up methods added via self.meth" do
+      KernelSpecs::Methods.methods(false).should include("ichi")
+    end
 
-  it "picks up methods added inside 'class << self'" do
-    KernelSpecs::Methods.methods(false).should include("san")
-  end
+    it "picks up methods added inside 'class << self'" do
+      KernelSpecs::Methods.methods(false).should include("san")
+    end
 
-  it "picks up private methods added via self.meth" do
-    KernelSpecs::Methods.methods(false).should include("shi")
-  end
+    it "picks up private methods added via self.meth" do
+      KernelSpecs::Methods.methods(false).should include("shi")
+    end
 
-  it "picks up methods added inside 'class << self' after private" do
-    KernelSpecs::Methods.methods(false).should include("roku")
-  end
+    it "picks up methods added inside 'class << self' after private" do
+      KernelSpecs::Methods.methods(false).should include("roku")
+    end
 
-  it "doesn't pick up methods added inside 'class << self; private'" do
-    KernelSpecs::Methods.methods(false).should_not include("shichi")
-  end
+    it "doesn't pick up methods added inside 'class << self; private'" do
+      KernelSpecs::Methods.methods(false).should_not include("shichi")
+    end
 
-  it "returns a list of the names of publicly accessible methods in the object" do
-    meths =  KernelSpecs::Methods.methods(false)
+    it "returns a list of the names of publicly accessible methods in the object" do
+      meths =  KernelSpecs::Methods.methods(false)
 
-    ["hachi", "ichi", "juu", "juu_ichi", "juu_ni", "roku", "san", "shi"].each do|m|
-      meths.should include(m)
+      ["hachi", "ichi", "juu", "juu_ichi", "juu_ni", "roku", "san", "shi"].each do|m|
+        meths.should include(m)
+      end
+
+      KernelSpecs::Methods.new.methods(false).should == []
     end
 
-    KernelSpecs::Methods.new.methods(false).should == []
-  end
+    it "returns a list of the names of publicly accessible methods in the object and its ancestors and mixed-in modules" do
+      meths = KernelSpecs::Methods.methods(false) & KernelSpecs::Methods.methods
+      ["hachi", "ichi", "juu", "juu_ichi", "juu_ni", "roku", "san", "shi"].each do |m|
+        meths.should include(m)
+      end
 
-  it "returns a list of the names of publicly accessible methods in the object and its ancestors and mixed-in modules" do
-    meths = KernelSpecs::Methods.methods(false) & KernelSpecs::Methods.methods
-    ["hachi", "ichi", "juu", "juu_ichi", "juu_ni", "roku", "san", "shi"].each do |m|
-      meths.should include(m)
+      m = KernelSpecs::Methods.new.methods
+      m.should include('ku')
+      m.should include('ni')
+      m.should include('juu_san')
     end
 
-    m = KernelSpecs::Methods.new.methods
-    m.should include('ku')
-    m.should include('ni')
-    m.should include('juu_san')
-  end
+    it "does not include any .undef'd methods" do
+      o = KernelSpecs::MethodsUndefd.new
 
-  it "does not include any .undef'd methods" do
-    o = KernelSpecs::MethodsUndefd.new
+      def o.single; end
 
-    def o.single; end
+      o.methods.should include("all")
+      o.methods.should include("single")
 
-    o.methods.should include("all")
-    o.methods.should include("single")
+      KernelSpecs::MethodsUndefd.send :undef_method, :all
 
-    KernelSpecs::MethodsUndefd.send :undef_method, :all
+      o.methods.should_not include("all")
 
-    o.methods.should_not include("all")
+      class << o; self; end.send :undef_method, :single
 
-    class << o; self; end.send :undef_method, :single
+      o.methods.should_not include("single")
+    end
 
-    o.methods.should_not include("single")
+    it "does not include any .undef'd methods even if method is inherited" do
+      o = KernelSpecs::MethodsUndefdChild.new
+      o.methods.should_not include("inh")
+    end
+
   end
+end
 
-  it "does not include any .undef'd methods even if method is inherited" do
-    o = KernelSpecs::MethodsUndefdChild.new
-    o.methods.should_not include("inh")
+# On MRI >= 1.9 #methods returns an Array of Symbols.
+ruby_version_is "1.9" do
+  describe "Kernel#methods" do
+
+    it "picks up methods added via self.meth" do
+      KernelSpecs::Methods.methods(false).should include(:ichi)
+    end
+
+    it "picks up methods added inside 'class << self'" do
+      KernelSpecs::Methods.methods(false).should include(:san)
+    end
+
+    it "picks up private methods added via self.meth" do
+      KernelSpecs::Methods.methods(false).should include(:shi)
+    end
+
+    it "picks up methods added inside 'class << self' after private" do
+      KernelSpecs::Methods.methods(false).should include(:roku)
+    end
+
+    it "doesn't pick up methods added inside 'class << self; private'" do
+      KernelSpecs::Methods.methods(false).should_not include(:shichi)
+    end
+
+    it "returns a list of the names of publicly accessible methods in the object" do
+      meths =  KernelSpecs::Methods.methods(false)
+
+      [:hachi, :ichi, :juu, :juu_ichi, :juu_ni, :roku, :san, :shi].each do|m|
+        meths.should include(m)
+      end
+
+      KernelSpecs::Methods.new.methods(false).should == []
+    end
+
+    it "returns a list of the names of publicly accessible methods in the object and its ancestors and mixed-in modules" do
+      meths = KernelSpecs::Methods.methods(false) & KernelSpecs::Methods.methods
+      [:hachi, :ichi, :juu, :juu_ichi, :juu_ni, :roku, :san, :shi].each do |m|
+        meths.should include(m)
+      end
+
+      m = KernelSpecs::Methods.new.methods
+      m.should include(:ku)
+      m.should include(:ni)
+      m.should include(:juu_san)
+    end
+
+    it "does not include any .undef'd methods" do
+      o = KernelSpecs::MethodsUndefd.new
+
+      def o.single; end
+
+      o.methods.should include(:all)
+      o.methods.should include(:single)
+
+      KernelSpecs::MethodsUndefd.send :undef_method, :all
+
+      o.methods.should_not include(:all)
+
+      class << o; self; end.send :undef_method, :single
+
+      o.methods.should_not include(:single)
+    end
+
+    it "does not include any .undef'd methods even if method is inherited" do
+      o = KernelSpecs::MethodsUndefdChild.new
+      o.methods.should_not include(:inh)
+    end
+
   end
-
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/open_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/open_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/open_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -25,6 +25,7 @@
     @output.should == "This is a test\n"
   end
   
+
   platform_is_not :windows do
     
     it "opens an io when path starts with a pipe" do
@@ -58,11 +59,29 @@
     lambda { open }.should raise_error(ArgumentError)
   end
   
-  it "raises a TypeError if not passed a String type" do
-    lambda { open(nil)       }.should raise_error(TypeError)
-    lambda { open(7)         }.should raise_error(TypeError)
-    lambda { open(mock('x')) }.should raise_error(TypeError)
+  ruby_version_is "1.9" do
+    it "calls #to_open on argument" do
+      obj = mock('fileish')
+      obj.should_receive(:to_open).and_return(File.open(@file))
+      @file = open(obj)
+      @file.class.should == File
+    end
+    
+    it "raises a TypeError if passed a non-String that does not respond to #to_open" do
+      obj = mock('non-fileish')
+      lambda { open(obj) }.should raise_error(TypeError)
+      lambda { open(nil) }.should raise_error(TypeError)
+      lambda { open(7)   }.should raise_error(TypeError)
+    end 
   end
+
+  ruby_version_is ""..."1.9" do
+    it "raises a TypeError if not passed a String type" do
+      lambda { open(nil)       }.should raise_error(TypeError)
+      lambda { open(7)         }.should raise_error(TypeError)
+      lambda { open(mock('x')) }.should raise_error(TypeError)
+    end
+  end
 end
 
 describe "Kernel.open" do

Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/protected_methods_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/protected_methods_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/protected_methods_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,16 +1,34 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
 
+# The reason why having include() and ruby_version_is is to show the specification explicitly.
+# You should use have_protected_method() with the exception of this spec.
 describe "Kernel#protected_methods" do
-  it "returns a list of the names of protected methods accessible in the object" do
-    KernelSpecs::Methods.protected_methods(false).sort.should include("juu_ichi")
-    KernelSpecs::Methods.new.protected_methods(false).should include("ku")
+  ruby_version_is "" ... "1.9" do
+    it "returns a list of the names of protected methods accessible in the object" do
+      KernelSpecs::Methods.protected_methods(false).sort.should include("juu_ichi")
+      KernelSpecs::Methods.new.protected_methods(false).should include("ku")
+    end
+
+    it "returns a list of the names of protected methods accessible in the object and from its ancestors and mixed-in modules" do
+      l1 = KernelSpecs::Methods.protected_methods(false)
+      l2 = KernelSpecs::Methods.protected_methods
+      (l1 & l2).should include("juu_ichi")
+      KernelSpecs::Methods.new.protected_methods.should include('ku')
+    end
   end
-  
-  it "returns a list of the names of protected methods accessible in the object and from its ancestors and mixed-in modules" do
-    l1 = KernelSpecs::Methods.protected_methods(false)
-    l2 = KernelSpecs::Methods.protected_methods
-    (l1 & l2).should include("juu_ichi")
-    KernelSpecs::Methods.new.protected_methods.should include('ku')
+
+  ruby_version_is "1.9" do
+    it "returns a list of the names of protected methods accessible in the object" do
+      KernelSpecs::Methods.protected_methods(false).sort.should include(:juu_ichi)
+      KernelSpecs::Methods.new.protected_methods(false).should include(:ku)
+    end
+
+    it "returns a list of the names of protected methods accessible in the object and from its ancestors and mixed-in modules" do
+      l1 = KernelSpecs::Methods.protected_methods(false)
+      l2 = KernelSpecs::Methods.protected_methods
+      (l1 & l2).should include(:juu_ichi)
+      KernelSpecs::Methods.new.protected_methods.should include(:ku)
+    end
   end
 end

Added: MacRuby/branches/experimental/spec/frozen/core/kernel/shared/__method__.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/shared/__method__.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/shared/__method__.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,52 @@
+def f
+  send(@method)
+end
+alias g f
+
+describe :kernel___method__, :shared => true do
+
+  it "returns the current method, even when aliased" do
+    f.should == :f
+  end
+
+  it "returns the original name when aliased method" do
+    g.should == :f
+  end
+
+  it "returns the caller from blocks too" do
+    def h
+      (1..2).map { send(@method) }
+    end
+    h.should == [:h, :h]
+  end
+
+  it "returns the caller from define_method too" do
+    klass = Class.new {define_method(:f) {__method__}}
+    klass.new.f.should == :f
+  end
+
+  it "returns the caller from block inside define_method too" do
+    klass = Class.new {define_method(:f) { 1.times{break __method__}}}
+    klass.new.f.should == :f
+  end
+
+  it "returns the caller from a define_method called from the same class" do
+    class C
+      define_method(:f) { 1.times{break __method__}}
+      def g; f end
+    end
+    C.new.g.should == :f
+  end
+
+  it "returns method name even from eval" do
+    def h
+      eval @method.to_s
+    end
+    h.should == :h
+  end
+
+  it "returns nil when not called from a method" do
+    send(@method).should == nil
+  end
+
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/singleton_methods_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/singleton_methods_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/singleton_methods_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,31 +1,66 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
 
-describe "Kernel#singleton_methods" do
-  it "returns a list of the names of singleton methods in the object" do
-    m = KernelSpecs::Methods.singleton_methods(false)
-    ["hachi", "ichi", "juu", "juu_ichi", "juu_ni", "roku", "san", "shi"].each do |e|
-      m.should include(e)
+# Prior to MRI 1.9 #singleton_methods returned an Array of Strings
+ruby_version_is ""..."1.9" do
+  describe "Kernel#singleton_methods" do
+    it "returns a list of the names of singleton methods in the object" do
+      m = KernelSpecs::Methods.singleton_methods(false)
+      ["hachi", "ichi", "juu", "juu_ichi", "juu_ni", "roku", "san", "shi"].each do |e|
+        m.should include(e)
+      end
+      
+      KernelSpecs::Methods.new.singleton_methods(false).should == []
     end
     
-    KernelSpecs::Methods.new.singleton_methods(false).should == []
-  end
-  
-  it "should handle singleton_methods call with and without argument" do
-    [1, "string", :symbol, [], {} ].each do |e|
-      lambda {e.singleton_methods}.should_not raise_error
-      lambda {e.singleton_methods(true)}.should_not raise_error
-      lambda {e.singleton_methods(false)}.should_not raise_error
+    it "should handle singleton_methods call with and without argument" do
+      [1, "string", :symbol, [], {} ].each do |e|
+        lambda {e.singleton_methods}.should_not raise_error
+        lambda {e.singleton_methods(true)}.should_not raise_error
+        lambda {e.singleton_methods(false)}.should_not raise_error
+      end
+      
     end
     
+    it "returns a list of the names of singleton methods in the object and its ancestors and mixed-in modules" do
+      m = (KernelSpecs::Methods.singleton_methods(false) & KernelSpecs::Methods.singleton_methods)
+      ["hachi", "ichi", "juu", "juu_ichi", "juu_ni", "roku", "san", "shi"].each do |e|
+        m.should include(e)
+      end
+      
+      KernelSpecs::Methods.new.singleton_methods.should == []
+    end
   end
-  
-  it "returns a list of the names of singleton methods in the object and its ancestors and mixed-in modules" do
-    m = (KernelSpecs::Methods.singleton_methods(false) & KernelSpecs::Methods.singleton_methods)
-    ["hachi", "ichi", "juu", "juu_ichi", "juu_ni", "roku", "san", "shi"].each do |e|
-      m.should include(e)
+end
+
+# In MRI 1.9 #singleton_methods returns an Array of Symbols
+ruby_version_is "1.9" do
+  describe "Kernel#singleton_methods" do
+    it "returns a list of the names of singleton methods in the object" do
+      m = KernelSpecs::Methods.singleton_methods(false)
+      [:hachi, :ichi, :juu, :juu_ichi, :juu_ni, :roku, :san, :shi].each do |e|
+        m.should include(e)
+      end
+      
+      KernelSpecs::Methods.new.singleton_methods(false).should == []
     end
     
-    KernelSpecs::Methods.new.singleton_methods.should == []
+    it "should handle singleton_methods call with and without argument" do
+      [1, "string", :symbol, [], {} ].each do |e|
+        lambda {e.singleton_methods}.should_not raise_error
+        lambda {e.singleton_methods(true)}.should_not raise_error
+        lambda {e.singleton_methods(false)}.should_not raise_error
+      end
+      
+    end
+    
+    it "returns a list of the names of singleton methods in the object and its ancestors and mixed-in modules" do
+      m = (KernelSpecs::Methods.singleton_methods(false) & KernelSpecs::Methods.singleton_methods)
+      [:hachi, :ichi, :juu, :juu_ichi, :juu_ni, :roku, :san, :shi].each do |e|
+        m.should include(e)
+      end
+      
+      KernelSpecs::Methods.new.singleton_methods.should == []
+    end
   end
-end
+end  

Added: MacRuby/branches/experimental/spec/frozen/core/kernel/tap_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/tap_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/tap_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,15 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+ruby_version_is "1.8.7".."" do
+  describe "Kernel#tap" do
+    it "always yields self and returns self" do
+      a = KernelSpecs::A.new
+      a.tap{|o| o.should equal(a); 42}.should equal(a)
+    end
+    
+    it "raises a LocalJumpError when no block given" do
+      lambda { 3.tap }.should raise_error(LocalJumpError)
+    end  
+  end
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/to_a_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/to_a_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/to_a_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,7 +3,7 @@
 
 describe "Kernel#to_a" do
   it "is defined on Kernel" do
-    Kernel.instance_methods.should include('to_a')
+    Kernel.should have_instance_method('to_a')
   end
 end
 
@@ -19,4 +19,4 @@
     object = "I am not an array"
     object.to_a.should == [object]
   end
-end
\ No newline at end of file
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/marshal/dump_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/marshal/dump_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/marshal/dump_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -87,6 +87,23 @@
     lambda { Marshal.dump(Hash.new {}) }.should raise_error(TypeError)
   end
 
+  it "raises a TypeError if marshalling a Method instance" do
+    lambda { Marshal.dump(Marshal.method(:dump)) }.should raise_error(TypeError)
+  end
+
+  it "raises a TypeError if marshalling a Proc" do
+    lambda { Marshal.dump(proc {}) }.should raise_error(TypeError)
+  end
+
+  it "raises a TypeError if dumping a IO/File instance" do
+    lambda { Marshal.dump(STDIN) }.should raise_error(TypeError)
+    lambda { File.open(__FILE__) { |f| Marshal.dump(f) } }.should raise_error(TypeError)
+  end
+
+  it "raises a TypeError if dumping a MatchData instance" do
+    lambda { "foo" =~ /(.)/; Marshal.dump($~) }.should raise_error(TypeError)
+  end
+
   it "dumps an extended_user_hash_default" do
     h = UserHash.new(:Meths).extend(Meths)
     h['three'] = 3

Modified: MacRuby/branches/experimental/spec/frozen/core/method/arity_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/method/arity_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/method/arity_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -8,7 +8,9 @@
 
   it "returns n, where n is the number of required arguments, when there are zero or more required arguments only" do
     @m.method(:zero).arity.should    == 0
+    @m.method(:attr).arity.should    == 0
     @m.method(:one_req).arity.should == 1
+    @m.method(:attr=).arity.should   == 1
     @m.method(:two_req).arity.should == 2
   end
 

Modified: MacRuby/branches/experimental/spec/frozen/core/method/fixtures/classes.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/method/fixtures/classes.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/method/fixtures/classes.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -5,6 +5,8 @@
     end
     alias bar foo
 
+    attr_accessor :attr
+
     def zero; end
     def one_req(a); end
     def two_req(a, b); end

Added: MacRuby/branches/experimental/spec/frozen/core/method/name_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/method/name_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/method/name_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,17 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Method#name" do
+  ruby_version_is '1.8.7' do
+    it "returns the name of the method" do
+      "abc".method(:upcase).name.should == :upcase
+    end
+    
+    it "returns the name even when aliased" do
+      obj = MethodSpecs::Methods.new
+      obj.method(:foo).name.should == :foo
+      obj.method(:bar).name.should == :bar
+      obj.method(:bar).unbind.bind(obj).name.should == :bar
+    end
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/core/method/owner_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/method/owner_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/method/owner_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,22 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Method#owner" do
+  ruby_version_is '1.8.7' do
+    it "returns the owner of the method" do
+      "abc".method(:upcase).owner.should == String
+    end
+    
+    it "returns the name even when aliased" do
+      obj = MethodSpecs::Methods.new
+      obj.method(:foo).owner.should == MethodSpecs::Methods
+      obj.method(:bar).owner.should == MethodSpecs::Methods
+    end
+
+    it "returns the class/module it was defined in" do
+      MethodSpecs::C.new.method(:baz).owner.should == MethodSpecs::A
+      MethodSpecs::MySuper.new.method(:bar).owner.should == MethodSpecs::MyMod
+    end
+
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/core/method/receiver_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/method/receiver_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/method/receiver_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,17 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Method#receiver" do
+  ruby_version_is '1.8.7' do
+    it "returns the receiver of the method" do
+      s = "abc"
+      s.method(:upcase).receiver.should equal(s)
+    end
+    
+    it "returns the right receiver even when aliased" do
+      obj = MethodSpecs::Methods.new
+      obj.method(:foo).receiver.should equal(obj)
+      obj.method(:bar).receiver.should equal(obj)
+    end
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/method/shared/call.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/method/shared/call.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/method/shared/call.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,6 +3,9 @@
     m = 12.method("+")
     m.send(@method, 3).should == 15
     m.send(@method, 20).should == 32
+
+    m = MethodSpecs::Methods.new.method(:attr=)
+    m.send(@method, 42).should == 42
   end
 
   it "raises an ArgumentError when given incorrect number of arguments" do

Modified: MacRuby/branches/experimental/spec/frozen/core/method/shared/to_s.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/method/shared/to_s.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/method/shared/to_s.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -10,6 +10,11 @@
   it "returns a String" do
     @m.send(@method).class.should == String
   end
+  
+  it "returns a String for methods defined with attr_accessor" do
+    m = MethodSpecs::Methods.new.method :attr
+    m.send(@method).class.should == String
+  end
 
   it "returns a String containing 'Method'" do
     @string.should =~ /\bMethod\b/

Modified: MacRuby/branches/experimental/spec/frozen/core/module/define_method_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/define_method_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/module/define_method_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -23,8 +23,7 @@
       end
       define_method(:another_test_method, instance_method(:test_method))
     end
-    
-    klass.new.methods.should include("another_test_method")
+    klass.new.should have_method(:another_test_method)
   end
 end
 

Modified: MacRuby/branches/experimental/spec/frozen/core/module/extended_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/extended_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/module/extended_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -37,4 +37,8 @@
       $extended_object = nil
     end
   end
+
+  it "is private in its default implementation" do
+    Module.new.private_methods.should include("extended")
+  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/module/included_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/included_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/module/included_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -32,4 +32,8 @@
     c = Class.new{ include(m) }
     c.test.should == :passed
   end
+
+  it "is private in its default implementation" do
+    Module.new.private_methods.should include("included")
+  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/module/instance_methods_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/instance_methods_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/module/instance_methods_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,31 +1,67 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
 
-describe "Module#instance_methods" do
-  it "does not return undefined methods" do
-    methods = ModuleSpecs::Parent.instance_methods(false)
-    methods.should_not include("undefed_method")
+# Prior to MRI 1.9 #instance_methods returned an Array of Strings
+ruby_version_is ""..."1.9" do
+  describe "Module#instance_methods" do
+    it "does not return undefined methods" do
+      methods = ModuleSpecs::Parent.instance_methods(false)
+      methods.should_not include("undefed_method")
 
-    ModuleSpecs::Child.send(:undef_method, 'undefed_child')
-    methods = ModuleSpecs::Child.instance_methods
-    methods.should_not include("undefed_method")
-    methods.should_not include("undefed_child")
-  end
+      ModuleSpecs::Child.send(:undef_method, 'undefed_child')
+      methods = ModuleSpecs::Child.instance_methods
+      methods.should_not include("undefed_method")
+      methods.should_not include("undefed_child")
+    end
 
-  it "returns an array containing the public and protected methods of self if include_super is false" do
-    methods = ModuleSpecs::Parent.instance_methods(false)
-    methods.should include("protected_parent", "public_parent")
+    it "returns an array containing the public and protected methods of self if include_super is false" do
+      methods = ModuleSpecs::Parent.instance_methods(false)
+      methods.should include("protected_parent", "public_parent")
 
-    methods = ModuleSpecs::Child.instance_methods(false)
-    methods.should include("protected_child", "public_child")
+      methods = ModuleSpecs::Child.instance_methods(false)
+      methods.should include("protected_child", "public_child")
+    end
+
+    it "returns an array containing the public and protected methods of self and it's ancestors" do
+      methods = ModuleSpecs::Basic.instance_methods
+      methods.should include("protected_module", "public_module")
+
+      methods = ModuleSpecs::Super.instance_methods
+      methods.should include("protected_module", "protected_super_module",
+        "public_module", "public_super_module")
+    end
   end
+end  
 
-  it "returns an array containing the public and protected methods of self and it's ancestors" do
-    methods = ModuleSpecs::Basic.instance_methods
-    methods.should include("protected_module", "public_module")
 
-    methods = ModuleSpecs::Super.instance_methods
-    methods.should include("protected_module", "protected_super_module",
-      "public_module", "public_super_module")
+# As of MRI 1.9 #instance_methods returns an Array of Symbols
+ruby_version_is "1.9" do
+  describe "Module#instance_methods" do
+    it "does not return undefined methods" do
+      methods = ModuleSpecs::Parent.instance_methods(false)
+      methods.should_not include(:undefed_method)
+
+      ModuleSpecs::Child.send(:undef_method, :undefed_child)
+      methods = ModuleSpecs::Child.instance_methods
+      methods.should_not include(:undefed_method)
+      methods.should_not include(:undefed_child)
+    end
+
+    it "returns an array containing the public and protected methods of self if include_super is false" do
+      methods = ModuleSpecs::Parent.instance_methods(false)
+      methods.should include(:protected_parent, :public_parent)
+
+      methods = ModuleSpecs::Child.instance_methods(false)
+      methods.should include(:protected_child, :public_child)
+    end
+
+    it "returns an array containing the public and protected methods of self and it's ancestors" do
+      methods = ModuleSpecs::Basic.instance_methods
+      methods.should include(:protected_module, :public_module)
+
+      methods = ModuleSpecs::Super.instance_methods
+      methods.should include(:protected_module, :protected_super_module,
+        :public_module, :public_super_module)
+    end
   end
-end
+end  

Modified: MacRuby/branches/experimental/spec/frozen/core/module/public_instance_methods_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/public_instance_methods_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/module/public_instance_methods_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,36 +1,77 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
 
-describe "Module#public_instance_methods" do
-  it "returns a list of public methods in module and its ancestors" do
-    methods = ModuleSpecs::CountsMixin.public_instance_methods
-    methods.should include('public_3')
-  
-    methods = ModuleSpecs::CountsParent.public_instance_methods
-    methods.should include('public_3')
-    methods.should include('public_2')
+# Before MRI 1.9 #public_instance_methods returned an Array of Strings
+ruby_version_is ""..."1.9" do
+  describe "Module#public_instance_methods" do
+    it "returns a list of public methods in module and its ancestors" do
+      methods = ModuleSpecs::CountsMixin.public_instance_methods
+      methods.should include('public_3')
+    
+      methods = ModuleSpecs::CountsParent.public_instance_methods
+      methods.should include('public_3')
+      methods.should include('public_2')
 
-    methods = ModuleSpecs::CountsChild.public_instance_methods
-    methods.should include('public_3')
-    methods.should include('public_2')
-    methods.should include('public_1')
+      methods = ModuleSpecs::CountsChild.public_instance_methods
+      methods.should include('public_3')
+      methods.should include('public_2')
+      methods.should include('public_1')
 
-    methods = ModuleSpecs::Child2.public_instance_methods
-    methods.should include('foo')
-  end
+      methods = ModuleSpecs::Child2.public_instance_methods
+      methods.should include('foo')
+    end
 
-  it "when passed false as a parameter, should return only methods defined in that module" do
-    ModuleSpecs::CountsMixin.public_instance_methods(false).should == ['public_3']
-    ModuleSpecs::CountsParent.public_instance_methods(false).should == ['public_2']
-    ModuleSpecs::CountsChild.public_instance_methods(false).should == ['public_1']
+    it "when passed false as a parameter, should return only methods defined in that module" do
+      ModuleSpecs::CountsMixin.public_instance_methods(false).should == ['public_3']
+      ModuleSpecs::CountsParent.public_instance_methods(false).should == ['public_2']
+      ModuleSpecs::CountsChild.public_instance_methods(false).should == ['public_1']
+    end
+
+    it "default list should be the same as passing true as an argument" do
+      ModuleSpecs::CountsMixin.public_instance_methods(true).should ==
+        ModuleSpecs::CountsMixin.public_instance_methods
+      ModuleSpecs::CountsParent.public_instance_methods(true).should ==
+        ModuleSpecs::CountsParent.public_instance_methods
+      ModuleSpecs::CountsChild.public_instance_methods(true).should ==
+        ModuleSpecs::CountsChild.public_instance_methods
+    end
   end
+end
 
-  it "default list should be the same as passing true as an argument" do
-    ModuleSpecs::CountsMixin.public_instance_methods(true).should ==
-      ModuleSpecs::CountsMixin.public_instance_methods
-    ModuleSpecs::CountsParent.public_instance_methods(true).should ==
-      ModuleSpecs::CountsParent.public_instance_methods
-    ModuleSpecs::CountsChild.public_instance_methods(true).should ==
-      ModuleSpecs::CountsChild.public_instance_methods
+
+# As of MRI 1.9 #public_instance_methods returns an Array of Symbols
+ruby_version_is "1.9" do
+  describe "Module#public_instance_methods" do
+    it "returns a list of public methods in module and its ancestors" do
+      methods = ModuleSpecs::CountsMixin.public_instance_methods
+      methods.should include(:public_3)
+    
+      methods = ModuleSpecs::CountsParent.public_instance_methods
+      methods.should include(:public_3)
+      methods.should include(:public_2)
+
+      methods = ModuleSpecs::CountsChild.public_instance_methods
+      methods.should include(:public_3)
+      methods.should include(:public_2)
+      methods.should include(:public_1)
+
+      methods = ModuleSpecs::Child2.public_instance_methods
+      methods.should include(:foo)
+    end
+
+    it "when passed false as a parameter, should return only methods defined in that module" do
+      ModuleSpecs::CountsMixin.public_instance_methods(false).should == [:public_3]
+      ModuleSpecs::CountsParent.public_instance_methods(false).should == [:public_2]
+      ModuleSpecs::CountsChild.public_instance_methods(false).should == [:public_1]
+    end
+
+    it "default list should be the same as passing true as an argument" do
+      ModuleSpecs::CountsMixin.public_instance_methods(true).should ==
+        ModuleSpecs::CountsMixin.public_instance_methods
+      ModuleSpecs::CountsParent.public_instance_methods(true).should ==
+        ModuleSpecs::CountsParent.public_instance_methods
+      ModuleSpecs::CountsChild.public_instance_methods(true).should ==
+        ModuleSpecs::CountsChild.public_instance_methods
+    end
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/numeric/step_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/numeric/step_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/numeric/step_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -37,14 +37,14 @@
       @stop = mock("Stop value")
       @step = mock("Step value")
       
-      @obj.step(@stop, @step).should be_kind_of(Enumerable::Enumerator)
+      @obj.step(@stop, @step).should be_kind_of(enumerator_class)
     end
 
     it "returns an Enumerator when passed no block and self < stop" do
       @stop = mock("Stop value")
       @step = mock("Step value")
       
-      @obj.step(@stop, @step).should be_kind_of(Enumerable::Enumerator)
+      @obj.step(@stop, @step).should be_kind_of(enumerator_class)
     end
   end
   
@@ -189,3 +189,10 @@
     result.should == []
   end
 end
+
+describe "Numeric#step" do
+  it "doesn't catch errors" do
+    lambda{ 1.step(2) { raise ArgumentError, "oups" }}.should raise_error(ArgumentError, "oups")
+    lambda{ 1.step(2) { raise TypeError, "oups" }    }.should raise_error(TypeError, "oups")
+  end
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/objectspace/each_object_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/objectspace/each_object_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/objectspace/each_object_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -10,4 +10,17 @@
     # this is needed to prevent the new_obj from being GC'd too early
     new_obj.should_not == nil
   end
+  
+  ruby_version_is '1.8.7' do
+    it "returns an enumerator if not given a block" do
+      class ObjectSpaceSpecEachOtherObject; end
+      new_obj = ObjectSpaceSpecEachOtherObject.new
+
+      counter = ObjectSpace.each_object(ObjectSpaceSpecEachOtherObject)
+      counter.should be_kind_of(enumerator_class)
+      counter.each{}.should == 1
+      # this is needed to prevent the new_obj from being GC'd too early
+      new_obj.should_not == nil
+    end
+  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/process/egid_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/process/egid_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/process/egid_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,7 +2,7 @@
 
 describe "Process.egid" do
   it "returns the effective group ID for this process" do
-    Process.egid.class.should == Fixnum
+    Process.egid.should be_kind_of(Integer)
   end
 
   it "also goes by Process::GID.eid" do

Modified: MacRuby/branches/experimental/spec/frozen/core/process/kill_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/process/kill_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/process/kill_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -31,6 +31,10 @@
           Process.exit!
         end
       }
+
+      # Give the child enough time to setup the HUP trap.
+      sleep(0.5)
+
       Process.kill(0, pid).should == 1
       Process.kill(1, pid).should == 1
       Process.waitpid(pid)

Modified: MacRuby/branches/experimental/spec/frozen/core/range/each_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/range/each_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/range/each_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -13,7 +13,7 @@
     a = []
     ('A'...'D').each { |i| a << i }
     a.should == ['A','B','C']
-    
+
     a = []
     (0xfffd...0xffff).each { |i| a << i }
     a.should == [0xfffd, 0xfffe]
@@ -25,22 +25,31 @@
     x.should_receive(:succ).any_number_of_times.and_return(y)
     y.should_receive(:<=>).with(x).any_number_of_times.and_return(1)
     y.should_receive(:<=>).with(y).any_number_of_times.and_return(0)
-    
+
     a = []
     (x..y).each { |i| a << i }
     a.should == [x, y]
   end
-  
+
   it "raises a TypeError if the first element does not respond to #succ" do
     lambda { (0.5..2.4).each { |i| i } }.should raise_error(TypeError)
-    
+
     b = mock('x')
     (a = mock('1')).should_receive(:method_missing).with(:<=>, b).and_return(1)
-    
+
     lambda { (a..b).each { |i| i } }.should raise_error(TypeError)
   end
-  
+
   it "returns self" do
     (1..10).each {}.should == (1..10)
   end
+
+  ruby_version_is "1.8.7" do
+    it "returns an enumerator when no block given" do
+      enum = (1..3).each
+      enum.should be_kind_of(enumerator_class)
+      enum.to_a.should == [1, 2, 3]
+    end
+  end
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/range/initialize_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/range/initialize_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/range/initialize_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1 +1,28 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe "Range#initialize" do
+  it "is private" do
+    Range.should have_private_instance_method("initialize")
+  end
+
+  it "raises an ArgumentError if passed without or with only an argument" do
+    lambda { (1..3).__send__(:initialize) }.
+      should raise_error(ArgumentError)
+    lambda { (1..3).__send__(:initialize, 1) }.
+      should raise_error(ArgumentError)
+  end
+
+  it "raises a NameError if passed with two or three arguments" do
+    lambda { (1..3).__send__(:initialize, 1, 3) }.
+      should raise_error(NameError)
+    lambda { (1..3).__send__(:initialize, 1, 3, 5) }.
+      should raise_error(NameError)
+  end
+
+  it "raises an ArgumentError if passed with four or more arguments" do
+    lambda { (1..3).__send__(:initialize, 1, 3, 5, 7) }.
+      should raise_error(ArgumentError)
+    lambda { (1..3).__send__(:initialize, 1, 3, 5, 7, 9) }.
+      should raise_error(ArgumentError)
+  end
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/range/shared/equal_value.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/range/shared/equal_value.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/range/shared/equal_value.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -23,4 +23,11 @@
     (1..10).send(@method, 'a').should == false
     (1..10).send(@method, mock('x')).should == false
   end
+  
+  ruby_bug "redmine #1165", "1.9.2" do
+    it "returns true for subclasses to Range" do
+      class MyRange < Range ; end
+      Range.new(1, 2).send(@method, MyRange.new(1, 2)).should == true
+    end
+  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/range/step_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/range/step_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/range/step_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -13,7 +13,7 @@
     a = []
     ("A"..."G").step(2) { |x| a << x }
     a.should == ["A", "C", "E"]
-    
+
     a = []
     (0.5..2.4).step(0.5) { |x| a << x }
     a.should == [0.5, 1, 1.5, 2]
@@ -28,7 +28,7 @@
   it "raises a TypeError if the first element does not respond to #succ" do
     b = mock('x')
     (a = mock('1')).should_receive(:method_missing).with(:<=>, b).and_return(1)
-    
+
     lambda { (a..b).step(1) { |i| i } }.should raise_error(TypeError)
   end
 
@@ -41,10 +41,19 @@
     lambda { (1..10).step(obj) {} }.should raise_error(TypeError)
   end
 
-  it "coerces the argument to intger by invoking to_int" do
+  it "coerces the argument to integer by invoking to_int" do
     (obj = mock("2")).should_receive(:to_int).and_return(2)
     res = []
     (1..10).step(obj) {|x| res << x}
     res.should == [1, 3, 5, 7, 9]
   end
+
+  ruby_version_is "1.8.7" do
+    it "returns an enumerator when no block given" do
+      enum = (1..10).step(4)
+      enum.should be_kind_of(enumerator_class)
+      enum.to_a.should == [1, 5, 9]
+    end
+  end
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/regexp/union_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/regexp/union_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/regexp/union_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -10,4 +10,18 @@
     Regexp.union("skiing", "sledding").should == /skiing|sledding/
     Regexp.union(/dogs/, /cats/i).should == /(?-mix:dogs)|(?i-mx:cats)/
   end
+
+  it "uses to_str to convert arguments (if not Regexp)" do
+    obj = mock('pattern')
+    obj.should_receive(:to_str).and_return('foo')
+    Regexp.union(obj, "bar").should == /foo|bar/
+  end
+
+  ruby_version_is '1.8.7' do
+    it "accepts a single array of patterns as arguments" do
+      Regexp.union(["skiing", "sledding"]).should == /skiing|sledding/
+      Regexp.union([/dogs/, /cats/i]).should == /(?-mix:dogs)|(?i-mx:cats)/
+      lambda{Regexp.union(["skiing", "sledding"], [/dogs/, /cats/i])}.should raise_error(TypeError)
+    end
+  end
 end

Added: MacRuby/branches/experimental/spec/frozen/core/string/ascii_only_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/ascii_only_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/string/ascii_only_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,64 @@
+# -*- encoding: utf-8 -*-
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes.rb'
+
+ruby_version_is '1.9' do
+  describe "String#ascii_only?" do
+    it "needs to be reviewed for spec completeness"
+    
+    it "returns true if the String contains only ASCII characters" do
+      "hello".ascii_only?.should be_true
+    end
+    
+    it "returns true if the String contains only ASCII characters
+    and is encoded as ASCII" do
+      "hello".force_encoding('ASCII').ascii_only?.should be_true
+      "hello".encode("ASCII").ascii_only?.should be_true
+    end
+
+    it "returns true if the String contains only ASCII characters
+    and is encoded as UTF-8" do
+      "hello".force_encoding('UTF-8').ascii_only?.should be_true
+      "hello".encode('UTF-8').ascii_only?.should be_true
+    end
+    
+    it "returns false if the String contains only non-ASCII characters" do
+      "\u{6666}".ascii_only?.should be_false
+    end
+    
+    it "returns false if the String contains only non-ASCII characters
+    and is encoded as UTF-8" do
+      "\u{6666}".force_encoding('UTF-8').ascii_only?.should be_false
+      "\u{6666}".encode('UTF-8').ascii_only?.should be_false
+    end
+    
+    it "returns false if the String contains only non-ASCII characters
+    and is encoded as ASCII" do
+      "\u{6666}".force_encoding('ASCII').ascii_only?.should be_false
+    end
+    
+    it "returns false if the String contains ASCII and non-ASCII characters" do
+      "hello, \u{6666}".ascii_only?.should be_false
+    end
+
+    it "returns false if the String contains ASCII and non-ASCII characters
+    and is encoded as ASCII" do
+      "hello, \u{6666}".force_encoding('ASCII').ascii_only?.should be_false
+    end
+    
+    it "returns false if the String contains ASCII and non-ASCII characters
+    and is encoded as UTF-8" do
+      "hello, \u{6666}".encode('UTF-8').ascii_only?.should be_false
+      "hello, \u{6666}".force_encoding('UTF-8').ascii_only?.should be_false
+    end
+    
+    it "accepts no arguments" do
+      lambda { "Glark".ascii_only?('?') }.should raise_error(ArgumentError)
+    end
+    
+    it "returns true for the empty String" do
+      ''.ascii_only?.should be_true
+      ''.encode('UTF-8').ascii_only?.should be_true
+    end
+  end
+end

Added: MacRuby/branches/experimental/spec/frozen/core/string/bytesize_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/bytesize_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/string/bytesize_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,37 @@
+# -*- encoding: utf-8 -*-
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes.rb'
+
+ruby_version_is "1.9" do
+  describe "#String#bytesize" do
+    it "needs to be reviewed for spec completeness"
+
+    it "returns the length of self in bytes" do
+      "hello".bytesize.should == 5
+      " ".bytesize.should == 1
+    end
+    
+    it "works with strings containing single UTF-8 characters" do
+      "\u{6666}".bytesize.should == 3
+    end
+
+    it "works with psuedo-ASCII strings containing single UTF-8 characters" do
+      "\u{6666}".force_encoding('ASCII').bytesize.should == 3
+    end
+    
+    it "works with strings containing UTF-8 characters" do
+      "c \u{6666}".force_encoding('UTF-8').bytesize.should == 5
+      "c \u{6666}".bytesize.should == 5
+    end
+    
+    it "works with psuedo-ASCII strings containing UTF-8 characters" do
+      "c \u{6666}".force_encoding('ASCII').bytesize.should == 5
+    end
+    
+    it "returns 0 for the empty string" do
+      "".bytesize.should == 0
+      "".force_encoding('ASCII').bytesize.should == 0
+      "".force_encoding('UTF-8').bytesize.should == 0
+    end
+  end
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/string/each_byte_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/each_byte_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/string/each_byte_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -32,9 +32,18 @@
     s.each_byte { |c| s.slice!(0..-1); r << c }
     r.should == "h"
   end
-  
+
   it "returns self" do
     s = "hello"
     (s.each_byte {}).should equal(s)
   end
+
+  ruby_version_is "1.8.7" do
+    it "returns an enumerator when no block given" do
+      enum = "hello".each_byte
+      enum.should be_kind_of(enumerator_class)
+      enum.to_a.should == [104, 101, 108, 108, 111]
+    end
+  end
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/string/each_char_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/each_char_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/string/each_char_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,11 +1,34 @@
+# encoding: utf-8
 require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
 
-extended_on :rubinius do
+ruby_version_is '1.8.7' do
   describe "String#each_char" do
     it "passes each char in self to the given block" do
       a = []
       "hello".each_char { |c| a << c }
       a.should == ['h', 'e', 'l', 'l', 'o']
     end
+
+    ruby_bug 'redmine #1487', '1.9.1' do
+      it "returns self" do
+        s = StringSpecs::MyString.new "hello"
+        s.each_char{}.should equal(s)
+      end
+    end
+
+    it "returns an enumerator when no block given" do
+      enum = "hello".each_char
+      enum.should be_kind_of(enumerator_class)
+      enum.to_a.should == ['h', 'e', 'l', 'l', 'o']
+    end
+
+    it "is unicode aware" do
+      before = $KCODE
+      $KCODE = "UTF-8"
+      "\303\207\342\210\202\303\251\306\222g".each_char.to_a.should == ["\303\207", "\342\210\202", "\303\251", "\306\222", "g"]
+      $KCODE = before
+    end
+
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/string/each_line_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/each_line_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/string/each_line_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,7 +1,7 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
-require File.dirname(__FILE__) + '/shared/each'
+require File.dirname(__FILE__) + '/shared/each_line'
 
 describe "String#each_line" do
-  it_behaves_like(:string_each, :each_line)
+  it_behaves_like(:string_each_line, :each_line)
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/string/each_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/each_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/string/each_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,7 +1,9 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
-require File.dirname(__FILE__) + '/shared/each'
+require File.dirname(__FILE__) + '/shared/each_line'
 
 describe "String#each" do
-  it_behaves_like(:string_each, :each)
+  ruby_version_is ''...'1.9' do
+    it_behaves_like(:string_each_line, :each)
+  end
 end

Added: MacRuby/branches/experimental/spec/frozen/core/string/end_with_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/end_with_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/string/end_with_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,49 @@
+# -*- encoding: utf-8 -*-
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes.rb'
+
+ruby_version_is '1.8.7' do
+  describe "String#end_with?" do
+    it "returns true only if ends match" do
+      s = "hello"
+      s.end_with?('o').should be_true
+      s.end_with?('llo').should be_true
+      s.end_with?('ll').should be_false
+    end
+
+    it "returns true only if any ending match" do
+      "hello".end_with?('x', 'y', 'llo', 'z').should be_true
+    end
+
+    it "converts its argument using :to_str" do
+      s = "hello"
+      find = mock('o')
+      find.should_receive(:to_str).and_return("o")
+      s.end_with?(find).should be_true
+    end
+
+    it "ignores arguments not convertible to string" do
+      "hello".end_with?().should be_false
+      "hello".end_with?(1).should be_false
+      "hello".end_with?(["o"]).should be_false
+      "hello".end_with?(1, nil, "o").should be_true
+    end
+
+    it "uses only the needed arguments" do
+      find = mock('h')
+      find.should_not_receive(:to_str)
+      "hello".end_with?("o",find).should be_true
+    end
+
+    it "works for multibyte strings" do
+      old_kcode = $KCODE
+      begin
+        $KCODE = "UTF-8"
+        "céréale".end_with?("réale").should be_true
+      ensure
+        $KCODE = old_kcode
+      end
+    end
+
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/string/fixtures/classes.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/fixtures/classes.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/string/fixtures/classes.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -17,4 +17,11 @@
       self.replace(str)
     end
   end
+
+  class StringNotReallyConvertable
+    def to_str
+      raise "Oups"
+    end
+  end
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/string/gsub_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/gsub_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/string/gsub_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -189,6 +189,7 @@
   it "raises a TypeError when pattern can't be converted to a string" do
     lambda { "hello".gsub(:woot, "x") }.should raise_error(TypeError)
     lambda { "hello".gsub(?e, "x")    }.should raise_error(TypeError)
+    lambda { "hello".gsub(nil, "x")   }.should raise_error(TypeError)
   end
   
   it "tries to convert replacement to a string using to_str" do
@@ -201,6 +202,7 @@
   it "raises a TypeError when replacement can't be converted to a string" do
     lambda { "hello".gsub(/[aeiou]/, :woot) }.should raise_error(TypeError)
     lambda { "hello".gsub(/[aeiou]/, ?f)    }.should raise_error(TypeError)
+    lambda { "hello".gsub(/[aeiou]/, nil)   }.should raise_error(TypeError)
   end
   
   it "returns subclass instances when called on a subclass" do

Modified: MacRuby/branches/experimental/spec/frozen/core/string/initialize_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/initialize_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/string/initialize_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -50,10 +50,9 @@
     String.new obj
   end
 
-  # Rubinius String makes a String of 5 NULs.  This behavior may need to be
-  # removed from many places.
   it "raises TypeError on inconvertible object" do
     lambda { String.new 5 }.should raise_error(TypeError)
+    lambda { String.new nil }.should raise_error(TypeError)
   end
 
   it "raises a TypeError if self is frozen" do

Added: MacRuby/branches/experimental/spec/frozen/core/string/partition_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/partition_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/string/partition_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,40 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes.rb'
+
+ruby_version_is '1.8.7' do
+  describe "String#partition with String" do
+    it "returns an array of substrings based on splitting on the given string" do
+      "hello world".partition("o").should == ["hell", "o", " world"]
+    end
+
+    it "always returns 3 elements" do
+      "hello".partition("x").should == ["hello", "", ""]
+      "hello".partition("hello").should == ["", "hello", ""]
+    end
+
+    it "accepts regexp" do
+      "hello!".partition(/l./).should == ["he", "ll", "o!"]
+    end
+
+    ruby_bug "redmine #1510", '1.9.1' do
+      it "converts its argument using :to_str" do
+        find = mock('l')
+        find.should_receive(:to_str).and_return("l")
+        "hello".partition(find).should == ["he","l","lo"]
+      end
+    end
+
+    it "raises error if not convertible to string" do
+      lambda{ "hello".partition(5) }.should raise_error(TypeError)
+      lambda{ "hello".partition(nil) }.should raise_error(TypeError)
+    end
+  end
+end
+
+ruby_version_is ''...'1.9' do
+  describe "String#partition with a block" do
+    it "is still available" do
+      "hello\nworld".partition{|w| w < 'k' }.should == [["hello\n"], ["world"]]
+    end
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/core/string/rpartition_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/rpartition_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/string/rpartition_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,32 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes.rb'
+
+ruby_version_is '1.8.7' do
+  describe "String#rpartition with String" do
+    it "returns an array of substrings based on splitting on the given string" do
+      "hello world".rpartition("o").should == ["hello w", "o", "rld"]
+    end
+
+    it "always returns 3 elements" do
+      "hello".rpartition("x").should == ["", "", "hello"]
+      "hello".rpartition("hello").should == ["", "hello", ""]
+    end
+
+    it "accepts regexp" do
+      "hello!".rpartition(/l./).should == ["hel", "lo", "!"]
+    end
+
+    ruby_bug "redmine #1510", '1.9.1' do
+      it "converts its argument using :to_str" do
+        find = mock('l')
+        find.should_receive(:to_str).and_return("l")
+        "hello".rpartition(find).should == ["hel","l","o"]
+      end
+    end
+
+    it "raises error if not convertible to string" do
+      lambda{ "hello".rpartition(5) }.should raise_error(TypeError)
+      lambda{ "hello".rpartition(nil) }.should raise_error(TypeError)
+    end
+  end
+end
\ No newline at end of file

Deleted: MacRuby/branches/experimental/spec/frozen/core/string/shared/each.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/shared/each.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/string/shared/each.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,88 +0,0 @@
-describe :string_each, :shared => true do
-  it "splits self using the supplied record separator and passes each substring to the block" do
-    a = []
-    "one\ntwo\r\nthree".send(@method, "\n") { |s| a << s }
-    a.should == ["one\n", "two\r\n", "three"]
-
-    b = []
-    "hello\nworld".send(@method, 'l') { |s| b << s }
-    b.should == [ "hel", "l", "o\nworl", "d" ]
-
-    c = []
-    "hello\n\n\nworld".send(@method, "\n") { |s| c << s }
-    c.should == ["hello\n", "\n", "\n", "world"]
-  end
-
-  it "taints substrings that are passed to the block if self is tainted" do
-    "one\ntwo\r\nthree".taint.send(@method) { |s| s.tainted?.should == true }
-
-    "x.y.".send(@method, ".".taint) { |s| s.tainted?.should == false }
-  end
-
-  it "passes self as a whole to the block if the separator is nil" do
-    a = []
-    "one\ntwo\r\nthree".send(@method, nil) { |s| a << s }
-    a.should == ["one\ntwo\r\nthree"]
-  end
-
-  it "appends multiple successive newlines together when the separator is an empty string" do
-    a = []
-    "hello\nworld\n\n\nand\nuniverse\n\n\n\n\n".send(@method, '') { |s| a << s }
-    a.should == ["hello\nworld\n\n\n", "and\nuniverse\n\n\n\n\n"]
-  end
-
-  it "uses $/ as the separator when none is given" do
-    [
-      "", "x", "x\ny", "x\ry", "x\r\ny", "x\n\r\r\ny",
-      "hello hullo bello"
-    ].each do |str|
-      ["", "llo", "\n", "\r", nil].each do |sep|
-        begin
-          expected = []
-          str.send(@method, sep) { |x| expected << x }
-
-          old_rec_sep, $/ = $/, sep
-
-          actual = []
-          str.send(@method) { |x| actual << x }
-
-          actual.should == expected
-        ensure
-          $/ = old_rec_sep
-        end
-      end
-    end
-  end
-
-  it "yields subclass instances for subclasses" do
-    a = []
-    StringSpecs::MyString.new("hello\nworld").send(@method) { |s| a << s.class }
-    a.should == [StringSpecs::MyString, StringSpecs::MyString]
-  end
-
-  it "returns self" do
-    s = "hello\nworld"
-    (s.send(@method) {}).should equal(s)
-  end
-
-  it "tries to convert the separator to a string using to_str" do
-    separator = mock('l')
-    separator.should_receive(:to_str).and_return("l")
-
-    a = []
-    "hello\nworld".send(@method, separator) { |s| a << s }
-    a.should == [ "hel", "l", "o\nworl", "d" ]
-  end
-
-  it "raises a RuntimeError if the string is modified while substituting" do
-    str = "hello\nworld"
-    lambda { str.send(@method) { str[0] = 'x' } }.should raise_error(RuntimeError)
-  end
-
-  it "raises a TypeError when the separator can't be converted to a string" do
-    lambda { "hello world".send(@method, false) {}     }.should raise_error(TypeError)
-    lambda { "hello world".send(@method, ?o) {}        }.should raise_error(TypeError)
-    lambda { "hello world".send(@method, :o) {}        }.should raise_error(TypeError)
-    lambda { "hello world".send(@method, mock('x')) {} }.should raise_error(TypeError)
-  end
-end

Added: MacRuby/branches/experimental/spec/frozen/core/string/shared/each_line.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/shared/each_line.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/string/shared/each_line.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,119 @@
+describe :string_each_line, :shared => true do
+  it "splits self using the supplied record separator and passes each substring to the block" do
+    a = []
+    "one\ntwo\r\nthree".send(@method, "\n") { |s| a << s }
+    a.should == ["one\n", "two\r\n", "three"]
+
+    b = []
+    "hello\nworld".send(@method, 'l') { |s| b << s }
+    b.should == [ "hel", "l", "o\nworl", "d" ]
+
+    c = []
+    "hello\n\n\nworld".send(@method, "\n") { |s| c << s }
+    c.should == ["hello\n", "\n", "\n", "world"]
+  end
+
+  it "taints substrings that are passed to the block if self is tainted" do
+    "one\ntwo\r\nthree".taint.send(@method) { |s| s.tainted?.should == true }
+
+    "x.y.".send(@method, ".".taint) { |s| s.tainted?.should == false }
+  end
+
+  it "passes self as a whole to the block if the separator is nil" do
+    a = []
+    "one\ntwo\r\nthree".send(@method, nil) { |s| a << s }
+    a.should == ["one\ntwo\r\nthree"]
+  end
+
+  it "appends multiple successive newlines together when the separator is an empty string" do
+    a = []
+    "hello\nworld\n\n\nand\nuniverse\n\n\n\n\n".send(@method, '') { |s| a << s }
+    a.should == ["hello\nworld\n\n\n", "and\nuniverse\n\n\n\n\n"]
+  end
+
+  it "uses $/ as the separator when none is given" do
+    [
+      "", "x", "x\ny", "x\ry", "x\r\ny", "x\n\r\r\ny",
+      "hello hullo bello"
+    ].each do |str|
+      ["", "llo", "\n", "\r", nil].each do |sep|
+        begin
+          expected = []
+          str.send(@method, sep) { |x| expected << x }
+
+          old_rec_sep, $/ = $/, sep
+
+          actual = []
+          str.send(@method) { |x| actual << x }
+
+          actual.should == expected
+        ensure
+          $/ = old_rec_sep
+        end
+      end
+    end
+  end
+
+  it "yields subclass instances for subclasses" do
+    a = []
+    StringSpecs::MyString.new("hello\nworld").send(@method) { |s| a << s.class }
+    a.should == [StringSpecs::MyString, StringSpecs::MyString]
+  end
+
+  it "returns self" do
+    s = "hello\nworld"
+    (s.send(@method) {}).should equal(s)
+  end
+
+  it "tries to convert the separator to a string using to_str" do
+    separator = mock('l')
+    separator.should_receive(:to_str).and_return("l")
+
+    a = []
+    "hello\nworld".send(@method, separator) { |s| a << s }
+    a.should == [ "hel", "l", "o\nworl", "d" ]
+  end
+
+  ruby_version_is ''...'1.9' do
+    it "raises a RuntimeError if the string is modified while substituting" do
+      str = "hello\nworld"
+      lambda { str.send(@method) { str[0] = 'x' } }.should raise_error(RuntimeError)
+    end
+  end
+
+  ruby_version_is '1.9' do
+    it "not care if the string is modified while substituting" do
+      str = "hello\nworld."
+      out = []
+      str.send(@method){|x| out << x; str[-1] = '!' }.should == "hello\nworld!"
+      out.should == ["hello\n", "world."]
+    end
+  end
+
+  it "raises a TypeError when the separator can't be converted to a string" do
+    lambda { "hello world".send(@method, false) {}     }.should raise_error(TypeError)
+    lambda { "hello world".send(@method, mock('x')) {} }.should raise_error(TypeError)
+  end
+
+  ruby_version_is ''...'1.9' do
+    it "raises a TypeError when the separator is a character or a symbol" do
+      lambda { "hello world".send(@method, ?o) {}        }.should raise_error(TypeError)
+      lambda { "hello world".send(@method, :o) {}        }.should raise_error(TypeError)
+    end
+  end
+
+  ruby_version_is '1.9' do
+    it "accept string-like separator" do
+      "hello world".send(@method, ?o).to_a.should == ["hello", " wo", "rld"]
+      "hello world".send(@method, :o).to_a.should == ["hello", " wo", "rld"]
+    end
+  end
+
+  ruby_version_is "1.8.7" do
+    it "returns an enumerator when no block given" do
+      enum = "hello world".send(@method, ' ')
+      enum.should be_kind_of(enumerator_class)
+      enum.to_a.should == ["hello ", "world"]
+    end
+  end
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/string/split_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/split_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/string/split_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -245,6 +245,11 @@
 
     "1.2.3.4".split(".", obj).should == ["1", "2.3.4"]
   end
+
+  it "returns a type error if limit can't be converted to an integer" do
+    lambda {"1.2.3.4".split(".", "three")}.should raise_error(TypeError)
+    lambda {"1.2.3.4".split(".", nil)    }.should raise_error(TypeError)
+  end
   
   it "doesn't set $~" do
     $~ = nil

Added: MacRuby/branches/experimental/spec/frozen/core/string/start_with_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/start_with_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/string/start_with_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,48 @@
+# -*- encoding: utf-8 -*-
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes.rb'
+
+ruby_version_is '1.8.7' do
+  describe "String#start_with?" do
+    it "returns true only if beginning match" do
+      s = "hello"
+      s.start_with?('h').should be_true
+      s.start_with?('hel').should be_true
+      s.start_with?('el').should be_false
+    end
+
+    it "returns true only if any beginning match" do
+      "hello".start_with?('x', 'y', 'he', 'z').should be_true
+    end
+
+    it "converts its argument using :to_str" do
+      s = "hello"
+      find = mock('h')
+      find.should_receive(:to_str).and_return("h")
+      s.start_with?(find).should be_true
+    end
+
+    it "ignores arguments not convertible to string" do
+      "hello".start_with?().should be_false
+      "hello".start_with?(1).should be_false
+      "hello".start_with?(["h"]).should be_false
+      "hello".start_with?(1, nil, "h").should be_true
+    end
+
+    it "uses only the needed arguments" do
+      find = mock('h')
+      find.should_not_receive(:to_str)
+      "hello".start_with?("h",find).should be_true
+    end
+  
+    it "works for multibyte strings" do
+      old_kcode = $KCODE
+      begin
+        $KCODE = "UTF-8"
+        "céréale".start_with?("cér").should be_true
+      ensure
+        $KCODE = old_kcode
+      end
+    end
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/string/sub_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/sub_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/string/sub_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -159,6 +159,7 @@
   it "raises a TypeError when pattern can't be converted to a string" do
     lambda { "hello".sub(:woot, "x") }.should raise_error(TypeError)
     lambda { "hello".sub(?e, "x")    }.should raise_error(TypeError)
+    lambda { "hello".sub(?e, nil)    }.should raise_error(TypeError)
   end
 
   it "tries to convert replacement to a string using to_str" do

Added: MacRuby/branches/experimental/spec/frozen/core/string/try_convert_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/try_convert_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/string/try_convert_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,36 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "String.try_convert" do
+  ruby_version_is "1.9" do
+    it "returns self for strings" do
+      x = "abc"
+      String.try_convert(x).should equal(x)
+    end
+    
+    it "converts using :to_str" do
+      str = "hello"
+      obj = mock('stringlike')
+      obj.should_receive(:to_str).and_return(str)
+      String.try_convert(obj).should equal(str)
+    end
+    
+    it "returns nil when there is no :to_ary" do
+      String.try_convert(-1).should be_nil
+    end
+    
+    it "should not rescue errors" do
+      lambda{
+        String.try_convert(StringSpecs::StringNotReallyConvertable.new)
+      }.should raise_error
+    end
+    
+    it "checks the result of the conversion" do
+      obj = mock('crazy to_str')
+      obj.should_receive(:to_str).and_return(:confused)
+      lambda{
+        String.try_convert(obj)
+      }.should raise_error(TypeError)
+    end
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/core/string/upto_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/upto_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/string/upto_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -35,8 +35,8 @@
 
   it "stops iterating as soon as the current value's character count gets higher than stop's" do
     a = []
-    "0".upto("A") { |s| a << s }
-    a.should == ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+    "96".upto("AA") { |s| a << s }
+    a.should == ["96", "97", "98", "99"]
   end
 
   it "returns self" do
@@ -54,12 +54,51 @@
   end
 
   it "raises a TypeError if other can't be converted to a string" do
-    lambda { "abc".upto(123)       }.should raise_error(TypeError)
-    lambda { "abc".upto(:def) { }  }.should raise_error(TypeError)
-    lambda { "abc".upto(mock('x')) }.should raise_error(TypeError)
+    lambda { "abc".upto(123) { }      }.should raise_error(TypeError)
+    lambda { "abc".upto(mock('x')){ } }.should raise_error(TypeError)
   end
 
-  it "raises a LocalJumpError if other is a string but no block was given" do
-    lambda { "abc".upto("def") }.should raise_error(LocalJumpError)
+
+  ruby_version_is ''...'1.9' do
+    it "raises a TypeError on symbols" do
+      lambda { "abc".upto(:def) { }     }.should raise_error(TypeError)
+    end
+
+    it "raises a LocalJumpError if other is a string but no block was given" do
+      lambda { "abc".upto("def") }.should raise_error(LocalJumpError)
+    end
+
+    it "uses succ even for single letters" do
+      a = []
+      "9".upto("A"){ |s| a << s}
+      a.should == ["9"]
+    end
   end
+
+  ruby_version_is '1.9' do
+    it "works with symbols to" do
+      "a".upto(:c).to_a.should == ["a", "b", "c"]
+    end
+
+    it "returns an enumerator when no block given" do
+      enum = "aaa".upto("baa", true)
+      enum.should be_kind_of(enumerator_class)
+      enum.count.should == 26**2
+    end
+
+    it "uses the ASCII map for single letters" do
+      a = []
+      "9".upto("A"){ |s| a << s}
+      a.should == ["9", ":", ";", "<", "=", ">", "?", "@", "A"]
+    end
+  end
+
+  ruby_version_is '1.8.7' do
+    it "stops before the last value if exclusive" do
+      a = []
+      "a".upto("d", true) { |s| a << s}
+      a.should == ["a", "b", "c"]
+    end
+  end
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/struct/each_pair_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/struct/each_pair_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/struct/each_pair_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -19,7 +19,7 @@
   ruby_version_is "1.8.7" do
     it "returns an Enumerator if not passed a block" do
       car = Struct::Car.new('Ford', 'Ranger')
-      car.each_pair.should be_kind_of(Enumerable::Enumerator)
+      car.each_pair.should be_kind_of(enumerator_class)
     end
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/struct/each_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/struct/each_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/struct/each_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -20,7 +20,7 @@
   ruby_version_is "1.8.7" do
     it "returns an Enumerator if not passed a block" do
       car = Struct::Car.new('Ford', 'Ranger')
-      car.each.should be_kind_of(Enumerable::Enumerator)
+      car.each.should be_kind_of(enumerator_class)
     end
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/struct/fixtures/classes.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/struct/fixtures/classes.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/struct/fixtures/classes.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,3 +2,9 @@
 
 Struct.new('Ruby', :version, :platform)
 Struct.new('Car', :make, :model, :year)
+class Honda < Struct::Car
+  def initialize(*args)
+    self.make = "Honda"
+    super(*args)
+  end
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/struct/initialize_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/struct/initialize_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/struct/initialize_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,15 +2,19 @@
 require File.dirname(__FILE__) + '/fixtures/classes'
 
 describe "Struct#initialize" do
-  
+
   it "is private" do
     Struct::Car.should have_private_instance_method(:initialize)
   end
-  
+
   it "does nothing when passed a set of fields equal to self" do
     car = same_car = Struct::Car.new("Honda", "Accord", "1998")
     car.instance_eval { initialize("Honda", "Accord", "1998") }
     car.should == same_car
   end
-  
+
+  it "explicitly sets instance variables to nil when args not provided to initialize" do
+    car = Honda.new
+    car.make.should == nil # still nil despite override in Honda#initialize b/c of super order
+  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/symbol/all_symbols_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/symbol/all_symbols_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/symbol/all_symbols_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -5,5 +5,10 @@
     Symbol.all_symbols.is_a?(Array).should == true
     Symbol.all_symbols.all? { |s| s.is_a?(Symbol) ? true : (p s; false) }.should == true
   end
-  # it "is a pain in the ass to test..."
+
+  it "increases size of the return array when new symbol comes" do
+    num_symbols = Symbol.all_symbols.size
+    eval ":aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+    Symbol.all_symbols.size.should == num_symbols + 1
+  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/symbol/to_i_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/symbol/to_i_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/symbol/to_i_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,11 +1,19 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 
 describe "Symbol#to_i" do
-  not_compliant_on :rubinius do
-    it "returns an integer that is unique for each symbol for each program execution" do
-      :ruby.to_i.is_a?(Integer).should == true
-      :ruby.to_i.should == :ruby.to_i
-      :ruby.to_i.should_not == :rubinius.to_i
+  ruby_version_is ""..."1.9" do
+    not_compliant_on :rubinius do
+      it "returns an integer that is unique for each symbol for each program execution" do
+        :ruby.to_i.is_a?(Integer).should == true
+        :ruby.to_i.should == :ruby.to_i
+        :ruby.to_i.should_not == :rubinius.to_i
+      end
     end
   end
+
+  ruby_version_is "1.9" do
+    it "has been removed as deprecated" do
+      :ruby.should_not respond_to(:to_i)
+    end
+  end 
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/symbol/to_int_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/symbol/to_int_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/symbol/to_int_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,11 +1,18 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 
 describe "Symbol#to_int" do
-  not_compliant_on :rubinius do
-    it "returns Symbol#to_i" do
-      :ruby.to_int.is_a?(Integer).should == true
-      :ruby.to_int.should == :ruby.to_i
-      :ruby.to_int.should_not == :rubinius.to_i
+  ruby_version_is ""..."1.9" do
+    not_compliant_on :rubinius do
+      it "returns Symbol#to_i" do
+        :ruby.to_int.is_a?(Integer).should == true
+        :ruby.to_int.should == :ruby.to_i
+        :ruby.to_int.should_not == :rubinius.to_i
+      end
     end
   end
+  ruby_version_is "1.9" do
+    it "has been removed as deprecated" do
+      :ruby.should_not respond_to(:to_int)
+    end
+  end  
 end

Modified: MacRuby/branches/experimental/spec/frozen/core/time/initialize_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/time/initialize_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/time/initialize_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,2 +1,7 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/methods'
+require File.dirname(__FILE__) + '/shared/now'
+
+describe 'Time.new' do
+  it_behaves_like(:time_now, :new)
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/time/now_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/time/now_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/time/now_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,2 +1,7 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/methods'
+require File.dirname(__FILE__) + '/shared/now'
+
+describe 'Time.now' do
+  it_behaves_like(:time_now, :now)
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/time/plus_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/time/plus_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/time/plus_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -4,9 +4,24 @@
 describe "Time#+" do
   it "increments the time by the specified amount" do
     (Time.at(0) + 100).should == Time.at(100)
-    (Time.at(1.1) + 0.9).should == Time.at(2)
   end
 
+  it "is a commutative operator" do
+    (Time.at(1.1) + 0.9).should == Time.at(0.9) + 1.1
+  end
+
+  ruby_version_is "" ... "1.9" do
+    it "increments the time by the specified amount as float numbers" do
+      (Time.at(1.1) + 0.9).should == Time.at(2)
+    end
+  end
+
+  ruby_version_is "1.9" do
+    it "increments the time by the specified amount as rational numbers" do
+      (Time.at(1.1) + 0.9).should_not == Time.at(2)
+    end
+  end
+
   it "accepts arguments that can be coerced into Float" do
     (obj = mock('10.5')).should_receive(:to_f).and_return(10.5)
     (Time.at(100) + obj).should == Time.at(110.5)

Added: MacRuby/branches/experimental/spec/frozen/core/time/shared/now.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/time/shared/now.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/time/shared/now.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,7 @@
+describe :time_now, :shared => true do
+  it "creates a time based on the current system time" do
+    unless `which date` == ""
+      Time.__send__(@method).to_i.should.be_close(`date +%s`.to_i,1)
+    end
+  end
+end

Modified: MacRuby/branches/experimental/spec/frozen/core/time/times_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/time/times_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/core/time/times_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,2 +1,16 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/methods'
+
+describe 'Time.times' do
+  ruby_version_is "" ... "1.9" do
+    it "is an obsolete method" do
+      lambda { Time.times }.should complain(/obsolete.*use.*Process::times/)
+    end
+  end
+
+  ruby_version_is "1.9" do
+    it "is no longer exist" do
+      lambda { Time.times }.should raise_error(NoMethodError)
+    end
+  end
+end

Added: MacRuby/branches/experimental/spec/frozen/core/unboundmethod/name_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/unboundmethod/name_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/unboundmethod/name_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,17 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "UnboundMethod#name" do
+  ruby_version_is '1.8.7' do
+    it "returns the name of the method" do
+      String.instance_method(:upcase).name.should == :upcase
+    end
+    
+    it "returns the name even when aliased" do
+      obj = UnboundMethodSpecs::Methods.new
+      obj.method(:foo).unbind.name.should == :foo
+      obj.method(:bar).unbind.name.should == :bar
+      UnboundMethodSpecs::Methods.instance_method(:bar).name.should == :bar
+    end
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/core/unboundmethod/owner_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/unboundmethod/owner_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/unboundmethod/owner_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,22 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "UnboundMethod#owner" do
+  ruby_version_is '1.8.7' do
+    it "returns the owner of the method" do
+      "abc".method(:upcase).owner.should == String
+    end
+    
+    it "returns the name even when aliased" do
+      obj = UnboundMethodSpecs::Methods.new
+      obj.method(:foo).owner.should == UnboundMethodSpecs::Methods
+      obj.method(:bar).owner.should == UnboundMethodSpecs::Methods
+    end
+
+    it "returns the class/module it was defined in" do
+      UnboundMethodSpecs::C.new.method(:baz).owner.should == UnboundMethodSpecs::A
+      UnboundMethodSpecs::Methods.new.method(:from_mod).owner.should == UnboundMethodSpecs::Mod
+    end
+
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/language/fixtures/return.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/fixtures/return.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/language/fixtures/return.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,48 @@
+module ReturnSpecs
+  class Blocks
+    def yielding_method
+      yield
+      ScratchPad.record :after_yield
+    end
+
+    def enclosing_method
+      yielding_method do
+        ScratchPad.record :before_return
+        return :return_value
+        ScratchPad.record :after_return
+      end
+
+      ScratchPad.record :after_call
+    end
+  end
+
+  class NestedCalls < Blocks
+    def invoking_method(&b)
+      yielding_method(&b)
+      ScratchPad.record :after_invoke
+    end
+
+    def enclosing_method
+      invoking_method do
+        ScratchPad.record :before_return
+        return :return_value
+        ScratchPad.record :after_return
+      end
+      ScratchPad.record :after_invoke
+    end
+  end
+
+  class NestedBlocks < Blocks
+    def enclosing_method
+      yielding_method do
+        yielding_method do
+          ScratchPad.record :before_return
+          return :return_value
+          ScratchPad.record :after_return
+        end
+        ScratchPad.record :after_invoke1
+      end
+      ScratchPad.record :after_invoke2
+    end
+  end
+end

Modified: MacRuby/branches/experimental/spec/frozen/language/predefined_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/predefined_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/language/predefined_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -331,7 +331,7 @@
     $:.should include(".")
   end
 
-  it "does not include on the taint check level > 1" do
+  it "does not include '.' when the taint check level > 1" do
     begin
       orig_opts, ENV['RUBYOPT'] = ENV['RUBYOPT'], '-T'
       `#{RUBY_EXE} -e 'p $:.include?(".")'`.should == "false\n"

Modified: MacRuby/branches/experimental/spec/frozen/language/return_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/return_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/language/return_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,4 +1,5 @@
 require File.dirname(__FILE__) + '/../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/return'
 
 describe "The return keyword" do
   it "returns any object directly" do
@@ -36,7 +37,6 @@
     end
   end
 
-
   describe "when passed a splat" do
     ruby_version_is "" ... "1.9" do
       it "returns nil when the ary is empty" do
@@ -235,6 +235,10 @@
 
 
   describe "within a block" do
+    before :each do
+      ScratchPad.clear
+    end
+
     ruby_version_is "" ... "1.9" do
       it "raises a LocalJumpError if there is no lexicaly enclosing method" do
         def f; yield; end
@@ -255,42 +259,28 @@
     end
 
     it "causes the method that lexically encloses the block to return" do
-      def meth_with_yield
-        yield
-        fail("return returned to wrong location")
-      end
+      ReturnSpecs::Blocks.new.enclosing_method.should == :return_value
+      ScratchPad.recorded.should == :before_return
+    end
 
-      def enclosing_method
-        meth_with_yield do
-          return :return_value
-          fail("return didn't, well, return")
-        end
-        fail("return should not behave like break")
-      end
+    it "returns from the lexically enclosing method even in case of chained calls" do
+      ReturnSpecs::NestedCalls.new.enclosing_method.should == :return_value
+      ScratchPad.recorded.should == :before_return
+    end
 
-      enclosing_method.should == :return_value
+    it "returns from the lexically enclosing method even in case of chained calls(in yield)" do
+      ReturnSpecs::NestedBlocks.new.enclosing_method.should == :return_value
+      ScratchPad.recorded.should == :before_return
     end
+  end
 
-    it "returns from the lexically enclosing method even in case of chained calls" do
-      class ChainedReturnTest
-        def self.meth_with_yield(&b)
-          yield
-          fail("returned from yield to wrong place")
-        end
-        def self.invoking_method(&b)
-          meth_with_yield(&b)
-          fail("returned from 'meth_with_yield' method to wrong place")
-        end
-        def self.enclosing_method
-          invoking_method do
-            return :return_value
-            fail("return didn't, well, return")
-          end
-          fail("return should not behave like break")
-        end
+  describe "within two blocks" do
+    it "causes the method that lexically encloses the block to return" do
+      def f
+        1.times { 1.times {return true}; false}; false
       end
-
-      ChainedReturnTest.enclosing_method.should == :return_value
+      f.should be_true
     end
   end
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/language/super_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/super_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/language/super_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -75,4 +75,23 @@
       lambda {sub_zsuper.new.foo}.should raise_error(NoMethodError, /super/)
     end
   end
+
+  it "supers up appropriate name even if used for multiple method names" do
+    sup = Class.new do
+      def a; "a"; end
+      def b; "b"; end
+    end
+
+    sub = Class.new(sup) do
+      [:a, :b].each do |name|
+        define_method name do
+          super
+        end
+      end
+    end
+
+    sub.new.a.should == "a"
+    sub.new.b.should == "b"
+    sub.new.a.should == "a"
+  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/language/symbol_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/symbol_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/language/symbol_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -65,6 +65,10 @@
       a.should equal(b)
     }
   end
+
+  it "does not contain null in the string" do
+    lambda { eval ':"\0" ' }.should raise_error(SyntaxError)
+  end
 end
 
-language_version __FILE__, 'symbol'
\ No newline at end of file
+language_version __FILE__, 'symbol'

Modified: MacRuby/branches/experimental/spec/frozen/library/bigdecimal/precs_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/bigdecimal/precs_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/bigdecimal/precs_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -33,16 +33,16 @@
     BigDecimal("3.14159").precs[0].should >= 6
     BigDecimal('1').precs[0].should == BigDecimal('1' + '0' * 100).precs[0]
     [@infinity, @infinity_neg, @nan, @zero, @zero_neg].each do |value|
-      value.precs[0].size.should <= @precision
+      value.precs[0].should <= @precision
     end
   end
 
   it "returns the maximum number of significant digits as the second value" do
     BigDecimal("3.14159").precs[1].should >= 6
-    BigDecimal('1').precs[1].size.should <= @precision
+    BigDecimal('1').precs[1].should >= 1
     BigDecimal('1' + '0' * 100).precs[1] >= 101
     [@infinity, @infinity_neg, @nan, @zero, @zero_neg].each do |value|
-      value.precs[1].size.should <= @precision
+      value.precs[1].should >= 1
     end
   end
 end

Deleted: MacRuby/branches/experimental/spec/frozen/library/enumerator/each_cons_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/enumerator/each_cons_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/enumerator/each_cons_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,11 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/classes'
-require 'enumerator'
-
-describe "Enumerator#each_cons" do
-  it "iterates the block for each array of n consecutive elements" do
-    a = []
-    EnumSpecs::Numerous.new.each_cons(4) { |e| a << e }
-    a.should == [[2, 5, 3, 6], [5, 3, 6, 1], [3, 6, 1, 4]]
-  end
-end

Deleted: MacRuby/branches/experimental/spec/frozen/library/enumerator/each_slice_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/enumerator/each_slice_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/enumerator/each_slice_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,11 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/classes'
-require 'enumerator'
-
-describe "Enumerator#each_slice" do
-  it "iterates the block for each slice of n elements" do
-    a = []
-    EnumSpecs::Numerous.new.each_slice(3) { |e| a << e }
-    a.should == [[2, 5, 3], [6, 1, 4]]
-  end  
-end

Modified: MacRuby/branches/experimental/spec/frozen/library/enumerator/enum_cons_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/enumerator/enum_cons_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/enumerator/enum_cons_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,12 +2,14 @@
 require File.dirname(__FILE__) + '/fixtures/classes'
 require 'enumerator'
 
-describe "Enumerator#enum_cons" do  
-  it "returns an enumerator of the receiver with iteration of each_cons for each array of n concecutive elements" do
-    a = []
-    enum = EnumSpecs::Numerous.new.enum_cons(3)
-    enum.each {|x| a << x}
-    enum.kind_of?(Enumerable::Enumerator).should == true
-    a.should == [[2, 5, 3], [5, 3, 6], [3, 6, 1], [6, 1, 4]]
-  end  
-end
+describe "Enumerator#enum_cons" do
+  ruby_version_is ''...'1.9' do
+    it "returns an enumerator of the receiver with iteration of each_cons for each array of n concecutive elements" do
+      a = []
+      enum = EnumSpecs::Numerous.new.enum_cons(3)
+      enum.each {|x| a << x}
+      enum.should be_kind_of(enumerator_class)
+      a.should == [[2, 5, 3], [5, 3, 6], [3, 6, 1], [6, 1, 4]]
+    end  
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/library/enumerator/enum_slice_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/enumerator/enum_slice_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/enumerator/enum_slice_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,11 +3,13 @@
 require 'enumerator'
 
 describe "Enumerator#enum_slice" do
-  it "returns an enumerator of the receiver with iteration of each_slice for each slice of n elements" do
-    a = []
-    enum = EnumSpecs::Numerous.new.enum_slice(4)
-    enum.kind_of?(Enumerable::Enumerator).should == true
-    enum.each { |e| a << e }
-    a.should == [[2, 5, 3, 6], [1, 4]]
-  end  
-end
+  ruby_version_is ''...'1.9' do
+    it "returns an enumerator of the receiver with iteration of each_slice for each slice of n elements" do
+      a = []
+      enum = EnumSpecs::Numerous.new.enum_slice(4)
+      enum.should be_kind_of(enumerator_class)
+      enum.each { |e| a << e }
+      a.should == [[2, 5, 3, 6], [1, 4]]
+    end  
+  end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/library/enumerator/enum_with_index_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/enumerator/enum_with_index_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/enumerator/enum_with_index_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,11 +3,13 @@
 require 'enumerator'
 
 describe "Enumerator#enum_with_index" do
-  it "returns an enumerator of the receiver with an iteration of each_with_index" do
-    a = []
-    enum = EnumSpecs::Numerous.new.enum_with_index
-    enum.kind_of?(Enumerable::Enumerator).should == true
-    enum.each { |e| a << e }
-    a.should == [[2, 0], [5, 1], [3, 2], [6, 3], [1, 4], [4, 5]]
+  ruby_version_is ''...'1.9' do
+    it "returns an enumerator of the receiver with an iteration of each_with_index" do
+      a = []
+      enum = EnumSpecs::Numerous.new.enum_with_index
+      enum.should be_kind_of(enumerator_class)
+      enum.each { |e| a << e }
+      a.should == [[2, 0], [5, 1], [3, 2], [6, 3], [1, 4], [4, 5]]
+    end
   end
-end
+end
\ No newline at end of file

Modified: MacRuby/branches/experimental/spec/frozen/library/enumerator/new_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/enumerator/new_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/enumerator/new_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,20 +3,62 @@
 
 describe "Enumerator.new" do
   it "creates a new custom enumerator with the given object, iterator and arguments" do
-    enum = Enumerable::Enumerator.new(1, :upto, 3)
-    enum.kind_of?(Enumerable::Enumerator).should == true
+    enum = enumerator_class.new(1, :upto, 3)
+    enum.should be_kind_of(enumerator_class)
   end
 
   it "creates a new custom enumerator that responds to #each" do
-    enum = Enumerable::Enumerator.new(1, :upto, 3)
+    enum = enumerator_class.new(1, :upto, 3)
     enum.respond_to?(:each).should == true
   end
 
   it "creates a new custom enumerator that runs correctly" do
-    Enumerable::Enumerator.new(1, :upto, 3).map{|x|x}.should == [1,2,3]
+    enumerator_class.new(1, :upto, 3).map{|x|x}.should == [1,2,3]
   end
   
   it "aliases the second argument to :each" do
-    Enumerable::Enumerator.new(1..2).to_a.should == Enumerable::Enumerator.new(1..2, :each).to_a
+    enumerator_class.new(1..2).to_a.should == enumerator_class.new(1..2, :each).to_a
   end
+  
+  it "doesn't check for the presence of the iterator method" do
+    enumerator_class.new(nil).should be_kind_of(enumerator_class)
+  end
+
+  it "uses the latest define iterator method" do
+    class StrangeEach
+      def each
+        yield :foo
+      end
+    end
+    enum = enumerator_class.new(StrangeEach.new)
+    enum.to_a.should == [:foo]
+    class StrangeEach
+      def each
+        yield :bar
+      end
+    end
+    enum.to_a.should == [:bar]
+  end
+
+  ruby_version_is ''...'1.9' do
+    it "requires an argument" do
+      lambda {enumerator_class.new}.should raise_error(ArgumentError)
+    end
+  end
+  ruby_version_is '1.9' do
+    it "accepts a block" do
+      enum = enumerator_class.new do |yielder|
+        yielder.yield 3
+        yielder.yield 2
+        yielder.yield 1
+      end
+      enum.should be_kind_of(enumerator_class)
+      enum.to_a.should == [3,2,1]
+    end
+
+    it "ignores block if arg given" do
+      enum = enumerator_class.new([1,2,3]){|y| y.yield 4}
+      enum.to_a.should == [1,2,3]
+    end
+  end    
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/enumerator/shared/enum_for.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/enumerator/shared/enum_for.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/enumerator/shared/enum_for.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -6,11 +6,11 @@
   end
 
   it "returns a new enumerator" do
-    "abc".send(@method).should be_kind_of(Enumerable::Enumerator)
+    "abc".send(@method).should be_kind_of(enumerator_class)
   end
 
-   it "defaults the first argument to :each" do
-    enum = [1,2].send(@method, :each)
+  it "defaults the first argument to :each" do
+    enum = [1,2].send(@method)
     enum.map { |v| v }.should == [1,2].each { |v| v }
   end
 end

Deleted: MacRuby/branches/experimental/spec/frozen/library/matrix/Fail_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/Fail_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/Fail_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,6 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'matrix'
-
-describe "Matrix#Fail" do
-  it "needs to be reviewed for spec completeness"
-end

Deleted: MacRuby/branches/experimental/spec/frozen/library/matrix/Raise_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/Raise_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/Raise_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,6 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'matrix'
-
-describe "Matrix#Raise" do
-  it "needs to be reviewed for spec completeness"
-end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/column_size_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/column_size_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/column_size_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,9 +2,9 @@
 require 'matrix'
 
 describe "Matrix#column_size" do
-  it "returns the number of elements in a column" do
-    data =  [[1,2]]
-    Matrix[ *data ].column_size.should == 2
+  it "returns the number of elements in the first column" do
+    Matrix[ [1,2] ].column_size.should == 2
+    Matrix[ [1,2,3],[1,2] ].column_size.should == 3
   end
 
   it "raises an exception on an empty Matrix" do
@@ -14,4 +14,3 @@
     lambda{ Matrix[].column_size }.should raise_error
   end
 end
-

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/column_vector_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/column_vector_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/column_vector_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,5 +2,29 @@
 require 'matrix'
 
 describe "Matrix.column_vector" do
-  it "needs to be reviewed for spec completeness"
+
+  it "returns a single column Matrix when called with an Array" do
+    m = Matrix.column_vector([4,5,6])
+    m.should be_an_instance_of(Matrix)
+    m.should == Matrix[ [4],[5],[6] ]
+  end
+
+  it "returns an empty Matrix when called with an empty Array" do
+    m = Matrix.column_vector([])
+    m.should be_an_instance_of(Matrix)
+    m.should == Matrix[]
+  end
+
+  it "returns a single column Matrix when called with a Fixnum" do
+    m = Matrix.column_vector(4)
+    m.should be_an_instance_of(Matrix)
+    m.should == Matrix[ [4] ]
+  end
+  
+  it "returns a single column Matrix when called with a Float" do  
+    m = Matrix.column_vector(0.98887)
+    m.should be_an_instance_of(Matrix)
+    m.should == Matrix[ [0.98887] ]
+  end
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/column_vectors_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/column_vectors_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/column_vectors_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,5 +2,25 @@
 require 'matrix'
 
 describe "Matrix#column_vectors" do
-  it "needs to be reviewed for spec completeness"
+
+  before(:each) do
+    @vectors = Matrix[ [1,2], [3,4] ].column_vectors
+  end
+
+  it "returns an Array" do
+    Matrix[ [1,2], [3,4] ].column_vectors.should be_an_instance_of(Array)
+  end
+
+  it "returns an Array of Vectors" do
+    @vectors.all? {|v| v.should be_an_instance_of(Vector)}
+  end  
+
+  it "returns each column as a Vector" do
+    @vectors.should == [Vector[1,3], Vector[2,4]]
+  end
+
+  it "returns an empty Array for empty matrices" do
+    Matrix[ [] ].column_vectors.should == []
+  end
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/columns_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/columns_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/columns_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -8,8 +8,16 @@
     @m = Matrix.columns([@a, @b])
   end
   
-  it "creates a matrix from argument columns" do
+  it "creates a Matrix from argument columns" do
+    @m.should be_an_instance_of(Matrix)
     @m.column(0).to_a.should == @a
     @m.column(1).to_a.should == @b
   end
+
+  it "raises an exception on an empty Matrix" do
+    # Note that MRI raises NoMethodError because #size is called
+    # on nil. This appears to be more of an "oops" rather than
+    # an aspect of the interface. We don't spec the exception class.
+    lambda{ Matrix.columns([]) }.should raise_error
+  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/compare_by_row_vectors_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/compare_by_row_vectors_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/compare_by_row_vectors_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,5 +2,18 @@
 require 'matrix'
 
 describe "Matrix#compare_by_row_vectors" do
-  it "needs to be reviewed for spec completeness"
+
+  before(:all) do
+    @elements = [ [1,2], [3,4] ]
+    @m = Matrix[ *@elements ]
+   end
+
+  it "returns true if the two matrices contain equal elements" do
+    @m.compare_by_row_vectors(@elements).should be_true
+  end
+
+  it "returns false if the two matrices don't contain equal elements" do
+    @m.compare_by_row_vectors(@elements.reverse).should be_false
+  end
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/det_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/det_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/det_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,6 +1,7 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/determinant'
 require 'matrix'
 
 describe "Matrix#det" do
-  it "needs to be reviewed for spec completeness"
+  it_behaves_like(:determinant, :det)
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/determinant_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/determinant_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/determinant_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,6 +1,7 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/determinant'
 require 'matrix'
 
 describe "Matrix#determinant" do
-  it "needs to be reviewed for spec completeness"
+  it_behaves_like(:determinant, :determinant)
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/element_reference_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/element_reference_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/element_reference_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -23,12 +23,27 @@
 end
 
 describe "Matrix#[]" do
+
+  before(:all) do
+    @m = Matrix[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]]
+  end
+
   it "returns element at (i, j)" do
-    m = Matrix[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]]
     (0..3).each do |i|
       (0..2).each do |j|
-        m[i, j].should == (i * 3) + j
+        @m[i, j].should == (i * 3) + j
       end
     end
   end
+
+  # FIXME: Update this guard when the bug is fixed.
+  ruby_bug "#1518", "1.9.1.129" do
+    # A NoMethodError is raised when the _first_ index is out of bounds,
+    # (http://redmine.ruby-lang.org/issues/show/1518); otherwise nil is
+    # returned.
+    it "returns nil for an invalid index pair" do
+      @m[8,1].should be_nil
+      @m[1,8].should be_nil
+    end
+  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/eql_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/eql_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/eql_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,26 +1,7 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/equal_value'
 require 'matrix'
-require File.dirname(__FILE__) + '/../../fixtures/matrix'
 
 describe "Matrix#eql?" do
-  before do
-    @matrix = Matrix[ [1, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]
-  end
-
-  it "returns true for self" do
-    @matrix.eql?(@matrix).should be_true
-  end
-
-  ruby_bug("[ruby-dev:36298]", "1.8.7") do
-    it "returns true when the each corresponding elements are equal in the sense of Object#eql?" do
-      @matrix.eql?(Matrix[ [1, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]).should be_true
-
-      num1, num2 = TrivialField.new, TrivialField.new
-      Matrix[[num1]].eql?(Matrix[[num2]]).should be_true
-    end
-
-    it "returns false when there are a pair corresponding elements which are not equal in the sense of Object#eql?" do
-      @matrix.eql?(Matrix[ [1, 2, 3, 4, 5.0], [2, 3, 4, 5, 6] ]).should be_false
-    end
-  end
+  it_behaves_like(:equal, :eql)
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/equal_value_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/equal_value_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/equal_value_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,6 +1,7 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/equal_value'
 require 'matrix'
 
 describe "Matrix#==" do
-  it "needs to be reviewed for spec completeness"
+  it_behaves_like(:equal, :equal_value)
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/exponent_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/exponent_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/exponent_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,5 +2,14 @@
 require 'matrix'
 
 describe "Matrix#**" do
-  it "needs to be reviewed for spec completeness"
+
+  it "multiples the Matrix by itself _n_ times" do
+    (Matrix[ [7,6], [3,9] ] ** 2).should == Matrix[ [67, 96], [48,99] ]
+  end
+  
+  it "raises a ErrOperationNotDefined exception for powers that aren't Integers" do
+    lambda {Matrix[ [1,2], [8,2] ] ** 2.5}.should 
+      raise_error(Matrix::ErrOperationNotDefined)
+  end  
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/hash_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/hash_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/hash_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,6 +1,19 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require 'matrix'
 
+# Note: Matrix just computes a bitwise OR of the element's .hash values, so
+# their position in the matrix isn't taken into account. This means that
+# matrices with the same elements in different positions will generate the
+# same .hash code...
 describe "Matrix#hash" do
-  it "needs to be reviewed for spec completeness"
+  
+  it "returns a Fixnum" do
+    Matrix[ [1,2] ].hash.should be_an_instance_of(Fixnum)
+  end  
+
+  it "returns the same value for the same matrix" do
+    data = [ [40,5], [2,7] ]
+    Matrix[ *data ].hash.should == Matrix[ *data ].hash
+  end
+
 end

Deleted: MacRuby/branches/experimental/spec/frozen/library/matrix/included_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/included_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/included_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,6 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'matrix'
-
-describe "Matrix.included" do
-  it "needs to be reviewed for spec completeness"
-end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/inspect_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/inspect_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/inspect_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,5 +2,9 @@
 require 'matrix'
 
 describe "Matrix#inspect" do
-  it "needs to be reviewed for spec completeness"
+  
+  it "returns a stringified representation of the Matrix" do
+    Matrix[ [1,2], [2,1] ].inspect.should == "Matrix[[1, 2], [2, 1]]"
+  end
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/inv_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/inv_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/inv_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,6 +1,7 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/inverse'
 require 'matrix'
 
 describe "Matrix#inv" do
-  it "needs to be reviewed for spec completeness"
+  it_behaves_like(:inverse, :inv)
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/inverse_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/inverse_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/inverse_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,6 +1,7 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/inverse'
 require 'matrix'
 
 describe "Matrix#inverse" do
-  it "needs to be reviewed for spec completeness"
+  it_behaves_like(:inverse, :inverse)
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/minor_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/minor_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/minor_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,6 +1,49 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require 'matrix'
 
-describe "Matrix#minor" do
-  it "needs to be reviewed for spec completeness"
+describe "Matrix#minor with start_row, nrows, start_col, ncols" do
+  
+  before(:each) do
+    @matrix = Matrix[ [1,2], [3,4], [5,6] ]
+  end  
+  
+  it "returns the given portion of the Matrix" do
+    @matrix.minor(0,1,0,2).should == Matrix[ [1, 2] ]
+    @matrix.minor(1,2,1,1).should == Matrix[ [4], [6] ]
+  end
+ 
+  it "returns an empty Matrix unless nrows and ncols are greater than 0" do
+    @matrix.minor(0,0,0,0).should == Matrix[]
+    @matrix.minor(1,0,1,0).should == Matrix[]
+    @matrix.minor(1,0,1,1).should == Matrix[]
+    @matrix.minor(1,1,1,0).should == Matrix[[]] # FIXME: Inconsistent
+  end
+
+  # This actually raises a NoMethodError: "(undefined method `call' for
+  #  Matrix[]:Matrix)", but we don't spec for this as it is yet another 
+  #  bug in Matrix.
+  it "raises for out-of-bounds arguments" do
+    @matrix.minor(3,0,0,0).should raise_error
+    @matrix.minor(0,0,0,9).should raise_error
+    lambda{@matrix.minor(9,9,9,9)}.should raise_error
+  end  
+
 end
+
+describe "Matrix#minor with col_range, row_range" do
+  
+  before(:each) do
+    @matrix = Matrix[ [1,2], [3,4], [5,6] ]
+  end  
+  
+  it "returns the given portion of the Matrix" do
+    @matrix.minor(0..0,0..1).should == Matrix[ [1, 2] ]
+    @matrix.minor(1..2,1..2).should == Matrix[ [4], [6] ]
+    @matrix.minor(0...3,0...3).should == @matrix
+  end
+ 
+  it "returns an empty Matrix if col_range or row_range don't select any elements" do
+    @matrix.minor(3..6,3..6).should == Matrix[]
+  end
+
+end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/rank_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/rank_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/rank_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,5 +2,18 @@
 require 'matrix'
 
 describe "Matrix#rank" do
-  it "needs to be reviewed for spec completeness"
+  it "returns the rank of the Matrix" do
+    Matrix[ [7,6], [3,9] ].rank.should == 2
+  end
+
+  # The examples below seems to indicate a regression in MRI 1.9.1, as it works
+  # in 1.8.7. On 1.9.1 it just hangs.
+  ruby_bug "#1020", "1.9.1.500" do
+    it "doesn't loop forever" do
+      Matrix[ [1,2,3], [4,5,6], [7,8,9] ].rank.should == 2
+      Matrix[ [1, 2, 0, 3], [1, -2, 3, 0], [0, 0, 4, 8], [2, 4, 0, 6] ].rank.
+      should == 3          
+    end
+  end
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/regular_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/regular_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/regular_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,5 +2,36 @@
 require 'matrix'
 
 describe "Matrix#regular?" do
+
+  # Bug #1020 and an unfamiliarity with properties of matrices stopped me
+  # from writing a complete specification here. 
   it "needs to be reviewed for spec completeness"
+
+  it "returns false if the Matrix is ragged" do
+    Matrix[ [1,2], [3], [2,1] ].regular?.should be_false
+  end
+
+  # On Ruby 1.9.1 the below tests cause hangs, presumably due to bug #1020.
+  # They pass in 1.8.7. When #1020 is fixed, we can determine whether it was
+  # the cause of this failure...
+  ruby_bug "#1020", "1.9.1.129" do
+    it "returns false unless rank(A) != n" do
+      m = Matrix[ [1,2,3], [3,4,3], [0,0,0] ]
+      m.square?.should be_true
+      m.rank.should_not == m.column_size
+      m.regular?.should be_false
+    end 
+
+    it "returns false if the determinant is 0" do
+      m = Matrix[ [1,2,9], [3,4,9], [1,2,9] ]
+      m.det.should == 0
+      m.square?.should be_true
+      m.regular?.should be_false
+    end
+
+    it "returns true if the Matrix is regular" do
+      Matrix[ [0,1], [1,0] ].regular?.should be_true
+    end  
+  end    
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/row_vector_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/row_vector_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/row_vector_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,5 +2,21 @@
 require 'matrix'
 
 describe "Matrix.row_vector" do
-  it "needs to be reviewed for spec completeness"
+  
+  it "returns a Matrix" do
+    Matrix.row_vector([]).should be_an_instance_of(Matrix)
+  end
+
+  it "returns a single-row Matrix with the specified values" do
+    Matrix.row_vector([1,2]).should == Matrix[ [1,2] ]
+  end  
+ 
+  it "returns an empty Matrix when called with an empty Array" do
+    Matrix.row_vector([]).should == Matrix[ [] ]
+  end
+
+  it "returns a single-element Matrix when called with a Fixnum" do
+    Matrix.row_vector(1).should == Matrix[[1]]
+  end  
+   
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/row_vectors_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/row_vectors_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/row_vectors_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,5 +2,28 @@
 require 'matrix'
 
 describe "Matrix#row_vectors" do
-  it "needs to be reviewed for spec completeness"
+
+  before(:each) do
+    @vectors = Matrix[ [1,2], [3,4] ].row_vectors
+  end
+
+  it "returns an Array" do
+    Matrix[ [1,2], [3,4] ].row_vectors.should be_an_instance_of(Array)
+  end
+
+  it "returns an Array of Vectors" do
+    @vectors.all? {|v| v.should be_an_instance_of(Vector)}
+  end  
+
+  it "returns each row as a Vector" do
+    @vectors.should == [Vector[1,2], Vector[3,4]]
+  end
+
+  # Matrix[[]].row_vectors == [], Matrix[[]].column_vectors == [Vector[]].
+  # Whatever the correct output, they should at least be consistent.
+  ruby_bug "#1526", "1.9.1.129" do
+    it "returns an empty Array for empty matrices" do
+      Matrix[ [] ].row_vectors.should == []
+    end
+  end
 end

Added: MacRuby/branches/experimental/spec/frozen/library/matrix/shared/determinant.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/shared/determinant.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/shared/determinant.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,46 @@
+require 'matrix'
+
+describe :determinant, :shared => true do
+  # Ruby versions less than 1.9.0, AFAICT, return the wrong determinant in
+  # most non-trivial cases. As the rdoc for Matrix suggests, "require 'mathn'"
+  # seems to fix this, but as Matrix doesn't require that library itself, the
+  # bug remains. I've reported http://redmine.ruby-lang.org/issues/show/1516 ,
+  # which is ostensibly about the documentation for #determinant not
+  # reflecting this bug, but raises the question of why 1.8.7 doesn't handle
+  # this properly.
+  ruby_bug "#1516", "1.8.7" do
+    it "returns the determinant of a square Matrix" do
+      m = Matrix[ [7,6], [3,9] ]
+      m.send(@method).should == 45 
+
+      m = Matrix[ [9, 8], [6,5] ]
+      m.send(@method).should == -3
+
+      m = Matrix[ [9,8,3], [4,20,5], [1,1,1] ]
+      m.send(@method).should == 95
+    end
+  end  
+  
+  it "returns the determinant of a single-element Matrix" do  
+    m = Matrix[ [2] ]
+    m.send(@method).should == 2
+  end
+
+  it "returns 0 for an empty Matrix" do
+    m = Matrix[ [] ]
+    m.send(@method).should == 0
+  end
+
+  # Matrix#square? returns true if the first row of the matrix has the same
+  # number of columns as the matrix has rows. This causes the .determinant
+  # method to raise a NoMethodError for '-'. I've reported it as 
+  # http://redmine.ruby-lang.org/issues/show/1515 , and will guard for this bug
+  # in the #square? test. The examples below deliberately avoid this condition. 
+  it "returns 0 when the Matrix is not square" do 
+    m = Matrix[ [1], [2,3] ] 
+    m.send(@method).should == 0
+
+    m = Matrix[ [1,2,3], [4,2] ]
+    m.send(@method).should == 0
+  end  
+end

Added: MacRuby/branches/experimental/spec/frozen/library/matrix/shared/equal_value.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/shared/equal_value.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/shared/equal_value.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,25 @@
+require 'matrix'
+require File.dirname(__FILE__) + '/../../../fixtures/matrix'
+
+describe :equal, :shared => true do
+  before do
+    @matrix = Matrix[ [1, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]
+  end
+
+  it "returns true for self" do
+    @matrix.eql?(@matrix).should be_true
+  end
+
+  ruby_bug("[ruby-dev:36298]", "1.8.7") do
+    it "returns true when the each corresponding elements are equal in the sense of Object#eql?" do
+      @matrix.eql?(Matrix[ [1, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]).should be_true
+
+      num1, num2 = TrivialField.new, TrivialField.new
+      Matrix[[num1]].eql?(Matrix[[num2]]).should be_true
+    end
+
+    it "returns false when there are a pair corresponding elements which are not equal in the sense of Object#eql?" do
+      @matrix.eql?(Matrix[ [1, 2, 3, 4, 5.0], [2, 3, 4, 5, 6] ]).should be_false
+    end
+  end
+end

Added: MacRuby/branches/experimental/spec/frozen/library/matrix/shared/inverse.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/shared/inverse.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/shared/inverse.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,32 @@
+require 'matrix'
+
+describe :inverse, :shared => true do
+ 
+  it "returns a Matrix" do
+    Matrix[ [1,2], [2,1] ].send(@method).should be_an_instance_of(Matrix)
+  end
+
+  it "returns the inverse of the Matrix" do
+    Matrix[ 
+      [1, 3, 3],     [1, 4, 3],  [1, 3, 4] 
+    ].send(@method).should == 
+    Matrix[
+      [7, -3, -3],   [-1, 1, 0], [-1, 0, 1]
+    ]
+
+    # FIXME: This example fails on 1.8.7 without 'mathn' being required.
+    # Embarrassingly, it works on JRuby. Ask brixen what to do here
+    Matrix[ 
+      [1, 2, 3],    [0, 1, 4],     [5, 6, 0] 
+    ].send(@method).should == 
+    Matrix[
+      [-24, 18, 5], [20, -15, -4], [-5, 4, 1]
+    ]
+  end 
+
+  it "raises a ErrDimensionMismatch if the Matrix is not square" do
+    lambda{ Matrix[ [1,2], [1] ].send(@method) }.should 
+      raise_error(Matrix::ErrDimensionMismatch)
+  end  
+
+end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/shared/transpose.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/shared/transpose.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/shared/transpose.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,6 +2,6 @@
 
 describe :matrix_transpose, :shared => true do
   it "returns a transposed matrix" do
-    Matrix[[1, 2], [3, 4], [5, 6]].transpose.should == Matrix[[1, 3, 5], [2, 4, 6]]
+    Matrix[[1, 2], [3, 4], [5, 6]].send(@method).should == Matrix[[1, 3, 5], [2, 4, 6]]
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/square_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/square_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/square_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -2,5 +2,28 @@
 require 'matrix'
 
 describe "Matrix#square?" do
-  it "needs to be reviewed for spec completeness"
-end
+  
+  it "returns true when the Matrix is square" do
+    Matrix[ [1,2], [2,4] ].square?.should be_true
+    Matrix[ [100,3,5], [9.5, 4.9, 8], [2,0,77] ].square?.should be_true
+  end
+
+  # .square? should return false if the Matrix is non square. However, there
+  # is a bug whereby .square? will return true as long as the first row has
+  # the same number of columns as the Matrix has rows. Hence the awkward
+  # examples.
+  it "returns false when the Matrix is not square and the first row has a
+  different number of columns than the Matrix has rows" do
+    Matrix[ [1, 2] ].square?.should be_false
+    Matrix[ [1], [9,7], [2] ].square?.should be_false
+  end
+
+  # FIXME: Remove guard when bug is fixed.
+  ruby_bug "#1515", "1.9.1.192" do 
+    it "returns false when the Matrix is not square
+    and the first row has the same number of columns as the matrix has rows." do
+      Matrix[ [1,2,3], [4,5], [6] ].square?.should be_false 
+    end
+  end  
+
+end  

Modified: MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/each_capitalized_name_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/each_capitalized_name_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/each_capitalized_name_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -29,9 +29,9 @@
 
     ruby_version_is "1.8.7" do
       ruby_bug "http://redmine.ruby-lang.org/issues/show/447", "1.8.7" do
-        it "returns an Enumerable::Enumerator" do
+        it "returns an Enumerator" do
           enumerator = @headers.each_capitalized_name
-          enumerator.should be_kind_of(Enumerable::Enumerator)
+          enumerator.should be_kind_of(enumerator_class)
       
           res = []
           enumerator.each do |key|

Modified: MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/each_value_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/each_value_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/each_value_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -30,9 +30,9 @@
     # TODO: This should return an Enumerator and not raise an Error
     ruby_version_is "1.8.7" do
       ruby_bug "http://redmine.ruby-lang.org/issues/show/447", "1.8.7" do
-        it "returns an Enumerable::Enumerator" do
+        it "returns an Enumerator" do
           enumerator = @headers.each_value
-          enumerator.should be_kind_of(Enumerable::Enumerator)
+          enumerator.should be_kind_of(enumerator_class)
       
           res = []
           enumerator.each do |key|

Modified: MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/shared/each_capitalized.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/shared/each_capitalized.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/shared/each_capitalized.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -26,9 +26,9 @@
     # TODO: This should return an Enumerator and not raise an Error
     ruby_version_is "1.8.7" do
       ruby_bug "http://redmine.ruby-lang.org/issues/show/447", "1.8.7" do
-        it "returns an Enumerable::Enumerator" do
+        it "returns an Enumerator" do
           enumerator = @headers.send(@method)
-          enumerator.should be_kind_of(Enumerable::Enumerator)
+          enumerator.should be_kind_of(enumerator_class)
     
           res = []
           enumerator.each do |key|

Modified: MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/shared/each_header.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/shared/each_header.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/shared/each_header.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -26,9 +26,9 @@
     # TODO: This should return an Enumerator and not raise an Error
     ruby_version_is "1.8.7" do
       ruby_bug "http://redmine.ruby-lang.org/issues/show/447", "1.8.7" do
-        it "returns an Enumerable::Enumerator" do
+        it "returns an Enumerator" do
           enumerator = @headers.send(@method)
-          enumerator.should be_kind_of(Enumerable::Enumerator)
+          enumerator.should be_kind_of(enumerator_class)
       
           res = []
           enumerator.each do |key|

Modified: MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/shared/each_name.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/shared/each_name.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/net/http/httpheader/shared/each_name.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -24,9 +24,9 @@
     end
 
     ruby_version_is "1.8.7" do
-      it "returns an Enumerable::Enumerator" do
+      it "returns an Enumerator" do
         enumerator = @headers.send(@method)
-        enumerator.should be_kind_of(Enumerable::Enumerator)
+        enumerator.should be_kind_of(enumerator_class)
       
         res = []
         enumerator.each do |key|

Modified: MacRuby/branches/experimental/spec/frozen/library/observer/count_observers_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/observer/count_observers_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/observer/count_observers_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -4,15 +4,30 @@
 describe "Observer#count_observers" do
   before(:each) do
     @observable = ObservableSpecs.new
-    @observer = ObserverCallbackSpecs.new
+    @observer   = ObserverCallbackSpecs.new
+    @observer2  = ObserverCallbackSpecs.new
   end
 
-  it "counts the observers" do
+  it "returns the number of observers" do
     @observable.count_observers.should == 0
     @observable.add_observer(@observer)
     @observable.count_observers.should == 1
-    @observable.add_observer(@observer)
+    @observable.add_observer(@observer2)
     @observable.count_observers.should == 2
   end
 
+  ruby_version_is "" ... "1.9" do
+    it "returns the number observers including duplicates" do
+      2.times { @observable.add_observer(@observer) }
+      @observable.count_observers.should == 2
+    end
+  end
+
+  ruby_version_is "1.9" do
+    it "returns the number of unique observers" do
+      2.times { @observable.add_observer(@observer) }
+      @observable.count_observers.should == 1
+    end
+  end
+
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/queue/num_waiting_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/queue/num_waiting_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/queue/num_waiting_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -8,7 +8,9 @@
 
     5.times do |i|
       q.num_waiting.should == i
-      threads << Thread.new { q.deq }
+      t = Thread.new { q.deq }
+      Thread.pass until t.status == 'sleep'
+      threads << t
     end
 
     threads.each { q.enq Object.new }

Modified: MacRuby/branches/experimental/spec/frozen/library/rexml/attributes/prefixes_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rexml/attributes/prefixes_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/rexml/attributes/prefixes_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -15,7 +15,7 @@
   end
 
   it "returns an array with the prefixes of each attribute" do
-    @e.attributes.prefixes.should == ["a", "b", "c"]
+    @e.attributes.prefixes.sort.should == ["a", "b", "c"]
   end
 
   it "does not include the default namespace" do

Modified: MacRuby/branches/experimental/spec/frozen/library/securerandom/base64_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/securerandom/base64_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/securerandom/base64_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -9,6 +9,7 @@
         base64 = SecureRandom.base64(idx)
         base64.class.should == String
         base64.length.should < 2 * idx
+        base64.should =~ /^[A-Za-z0-9\+\/]+={0,2}$/
       end
       
       base64 = SecureRandom.base64(16.5)

Modified: MacRuby/branches/experimental/spec/frozen/library/set/classify_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/set/classify_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/set/classify_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -21,7 +21,7 @@
   ruby_version_is "1.8.8" do
     it "returns an Enumerator when passed no block" do
       enum = @set.classify
-      enum.should be_kind_of(Enumerable::Enumerator)
+      enum.should be_kind_of(enumerator_class)
       
       classified = enum.each { |x| x.length }
       classified.should == { 3 => Set["one", "two"], 4 => Set["four"], 5 => Set["three"] }

Modified: MacRuby/branches/experimental/spec/frozen/library/set/delete_if_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/set/delete_if_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/set/delete_if_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -34,7 +34,7 @@
   ruby_version_is "1.8.8" do
     it "returns an Enumerator when passed no block" do
       enum = @set.delete_if
-      enum.should be_kind_of(Enumerable::Enumerator)
+      enum.should be_kind_of(enumerator_class)
       
       enum.each { |x| x.size == 3 }
       

Modified: MacRuby/branches/experimental/spec/frozen/library/set/flatten_merge_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/set/flatten_merge_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/set/flatten_merge_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -3,21 +3,21 @@
 
 describe "Set#flatten_merge" do
   it "is protected" do
-    Set[].protected_methods.should include("flatten_merge")
+    Set.should have_protected_instance_method("flatten_merge")
   end
-  
+
   it "flattens the passed Set and merges it into self" do
     set1 = Set[1, 2]
     set2 = Set[3, 4, Set[5, 6]]
-    
+
     set1.send(:flatten_merge, set2).should == Set[1, 2, 3, 4, 5, 6]
   end
-  
+
   it "raises an ArgumentError when trying to flatten a recursive Set" do
     set1 = Set[1, 2, 3]
     set2 = Set[5, 6, 7]
     set2 << set2
-    
+
     lambda { set1.send(:flatten_merge, set2) }.should raise_error(ArgumentError)
   end
-end
\ No newline at end of file
+end

Modified: MacRuby/branches/experimental/spec/frozen/library/set/reject_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/set/reject_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/set/reject_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -38,7 +38,7 @@
   ruby_version_is "1.8.8" do
     it "returns an Enumerator when passed no block" do
       enum = @set.reject!
-      enum.should be_kind_of(Enumerable::Enumerator)
+      enum.should be_kind_of(enumerator_class)
       
       enum.each { |x| x.size == 3 }
       

Modified: MacRuby/branches/experimental/spec/frozen/library/set/sortedset/add_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/set/sortedset/add_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/set/sortedset/add_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -5,9 +5,14 @@
 describe "SortedSet#add" do
   it_behaves_like :sorted_set_add, :add
 
-  ruby_bug "redmine #118", "1.9" do
-    it "takes only comparable values" do
-      lambda { SortedSet[3, 4].add(SortedSet[5, 6]) }.should raise_error(ArgumentError)
+  ruby_bug "redmine #118", "1.9.1" do
+    it "takes only values which responds <=>" do
+      lambda { SortedSet[Object.new].add(Object.new) }.should raise_error(ArgumentError)
+
+      obj = mock('x')
+      lambda { SortedSet[obj].add(:aaa) }.should raise_error(ArgumentError)
+      def obj.<=>(o) 1 end
+      lambda { SortedSet[obj].add(:aaa) }.should_not raise_error(ArgumentError)
     end
   end
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/set/sortedset/classify_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/set/sortedset/classify_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/set/sortedset/classify_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -21,7 +21,7 @@
   ruby_version_is "1.8.8" do
     it "returns an Enumerator when passed no block" do
       enum = @set.classify
-      enum.should be_kind_of(Enumerable::Enumerator)
+      enum.should be_kind_of(enumerator_class)
       
       classified = enum.each { |x| x.length }
       classified.should == { 3 => SortedSet["one", "two"], 4 => SortedSet["four"], 5 => SortedSet["three"] }

Modified: MacRuby/branches/experimental/spec/frozen/library/set/sortedset/delete_if_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/set/sortedset/delete_if_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/set/sortedset/delete_if_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -36,7 +36,7 @@
   ruby_version_is "1.8.8" do
     it "returns an Enumerator when passed no block" do
       enum = @set.delete_if
-      enum.should be_kind_of(Enumerable::Enumerator)
+      enum.should be_kind_of(enumerator_class)
       
       enum.each { |x| x.size == 3 }
       

Modified: MacRuby/branches/experimental/spec/frozen/library/set/sortedset/flatten_merge_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/set/sortedset/flatten_merge_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/set/sortedset/flatten_merge_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -5,21 +5,4 @@
   it "is protected" do
     SortedSet.should have_protected_instance_method("flatten_merge")
   end
-  
-  ruby_bug "http://redmine.ruby-lang.org/projects/ruby-18/issues/show?id=117", "1.8.7" do
-    it "flattens the passed SortedSet and merges it into self" do
-      set1 = SortedSet[1, 2]
-      set2 = SortedSet[3, 4, SortedSet[5, 6]]
-    
-      set1.send(:flatten_merge, set2).should == SortedSet[1, 2, 3, 4, 5, 6]
-    end
-  
-    it "raises an ArgumentError when trying to flatten a recursive SortedSet" do
-      set1 = SortedSet[1, 2, 3]
-      set2 = SortedSet[5, 6, 7]
-      set2 << set2
-    
-      lambda { set1.send(:flatten_merge, set2) }.should raise_error(ArgumentError)
-    end
-  end
 end

Modified: MacRuby/branches/experimental/spec/frozen/library/set/sortedset/reject_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/set/sortedset/reject_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/set/sortedset/reject_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -40,7 +40,7 @@
   ruby_version_is "1.8.8" do
     it "returns an Enumerator when passed no block" do
       enum = @set.reject!
-      enum.should be_kind_of(Enumerable::Enumerator)
+      enum.should be_kind_of(enumerator_class)
       
       enum.each { |x| x.size == 3 }
       

Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/puts_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/puts_spec.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/puts_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,3 +1,5 @@
+# -*- encoding: utf-8 -*-
+
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
 
@@ -149,4 +151,4 @@
 
     io.string.should == "\x00\x01\x02\næåø\n"
   end
-end
\ No newline at end of file
+end

Added: MacRuby/branches/experimental/spec/frozen/library/stringio/readpartial_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/readpartial_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/readpartial_spec.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -0,0 +1,79 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+ruby_version_is "1.9" do
+  describe "StringIO#readpartial" do
+    before :each do
+      @string = StringIO.new('Stop, look, listen')
+    end
+
+    after :each do
+      @string.close unless @string.closed?
+    end
+
+    it "raises IOError on closed stream" do
+      @string.close
+      lambda { @string.readpartial(10) }.should raise_error(IOError)
+    end
+
+    it "reads at most the specified number of bytes" do
+
+      # buffered read
+      @string.read(1).should == 'S'
+      # return only specified number, not the whole buffer
+      @string.readpartial(1).should == "t"
+    end
+
+    it "reads after ungetc with data in the buffer" do
+      c = @string.getc
+      @string.ungetc(c)
+      @string.readpartial(4).should == "Stop"
+      @string.readpartial(3).should == ", l"
+    end
+
+  #  it "reads after ungetc without data in the buffer" do
+  #    @string = StringIO.new
+  #    @string.write("f")
+  #    c = @string.getc
+  #    @string.ungetc(c)
+  #    @string.readpartial(2).should == "f"
+  #
+  #    # now, also check that the ungot char is cleared and
+  #    # not returned again
+  #    @string.write("b")
+  #    @string.readpartial(2).should == "b"
+  #  end
+
+    it "discards the existing buffer content upon successful read" do
+      buffer = "existing"
+      @string.readpartial(11, buffer)
+      buffer.should == "Stop, look,"
+    end
+
+    it "raises EOFError on EOF" do
+      @string.readpartial(18).should == 'Stop, look, listen'
+      lambda { @string.readpartial(10) }.should raise_error(EOFError)
+    end
+
+    it "discards the existing buffer content upon error" do
+      buffer = 'hello'
+      @string.readpartial(100)
+      lambda { @string.readpartial(1, buffer) }.should raise_error(EOFError)
+      buffer.should be_empty
+    end
+
+    it "raises IOError if the stream is closed" do
+      @string.close
+      lambda { @string.readpartial(1) }.should raise_error(IOError)
+    end
+
+    it "raises ArgumentError if the negative argument is provided" do
+      lambda { @string.readpartial(-1) }.should raise_error(ArgumentError)
+    end
+
+    it "immediately returns an empty string if the length argument is 0" do
+      @string.readpartial(0).should == ""
+    end
+    
+  end
+end  

Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -92,7 +92,7 @@
   ruby_version_is "1.8.7" do
     it "returns an Enumerator when passed no block" do
       enum = @io.send(@method)
-      enum.instance_of?(Enumerable::Enumerator).should be_true
+      enum.instance_of?(enumerator_class).should be_true
 
       seen = []
       enum.each { |b| seen << b }

Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each_byte.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each_byte.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each_byte.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -39,7 +39,7 @@
 
     it "returns an Enumerator when passed no block" do
       enum = @io.send(@method)
-      enum.instance_of?(Enumerable::Enumerator).should be_true
+      enum.instance_of?(enumerator_class).should be_true
 
       seen = []
       enum.each { |b| seen << b }

Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each_char.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each_char.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/shared/each_char.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -29,7 +29,7 @@
 
     it "returns an Enumerator when passed no block" do
       enum = @io.send(@method)
-      enum.instance_of?(Enumerable::Enumerator).should be_true
+      enum.instance_of?(enumerator_class).should be_true
 
       seen = []
       enum.each { |c| seen << c }

Modified: MacRuby/branches/experimental/spec/frozen/ruby.1.8.mspec
===================================================================
--- MacRuby/branches/experimental/spec/frozen/ruby.1.8.mspec	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/ruby.1.8.mspec	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,3 +1,9 @@
+# Configuration file for Ruby 1.8-compatible Ruby implementations.
+#
+# Unless you passed to --config (or -B) to MSpec, MSpec will automatically
+# use this config file if the Ruby interpreter with which MSpec advertises
+# itself with RUBY_VERSION =~ /1.8/
+
 class MSpecScript
   # Language features specs
   set :language, [ 'language' ]

Modified: MacRuby/branches/experimental/spec/frozen/ruby.1.9.mspec
===================================================================
--- MacRuby/branches/experimental/spec/frozen/ruby.1.9.mspec	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/ruby.1.9.mspec	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1,3 +1,9 @@
+# Configuration file for Ruby 1.9-compatible Ruby implementations.
+#
+# Unless you passed to --config (or -B) to MSpec, MSpec will automatically
+# use this config file if the Ruby interpreter with which MSpec advertises
+# itself with RUBY_VERSION =~ /1.9/
+
 class MSpecScript
   # Language features specs
   set :language, [ 'language' ]

Modified: MacRuby/branches/experimental/spec/frozen/shared/file/symlink.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/file/symlink.rb	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/shared/file/symlink.rb	2009-05-30 15:29:52 UTC (rev 1646)
@@ -8,9 +8,8 @@
   end
 
   after :each do
-    File.unlink(@link) if File.exist?(@link)
+    File.delete(@link) if File.exist?(@link)
     File.delete(@file) if File.exist?(@file)
-    @link = nil
   end
 
   platform_is_not :windows do
@@ -20,3 +19,24 @@
     end
   end
 end
+
+describe :file_symlink_nonexistent, :shared => true do
+  before :each do
+    @file = "test.txt"
+    @link = "test.lnk"
+    File.delete(@link) if File.exist?(@link)
+    File.delete(@file) if File.exist?(@file)
+    File.open(@file,"w+")
+  end
+
+  after :each do
+    File.delete(@link) if File.exist?(@link)
+    File.delete(@file) if File.exist?(@file)
+  end
+
+  platform_is_not :windows do
+    it "returns false if the file does not exist" do
+      @object.send(@method, "non_existent_link").should == false
+    end
+  end
+end

Modified: MacRuby/branches/experimental/spec/frozen/upstream
===================================================================
--- MacRuby/branches/experimental/spec/frozen/upstream	2009-05-30 02:05:55 UTC (rev 1645)
+++ MacRuby/branches/experimental/spec/frozen/upstream	2009-05-30 15:29:52 UTC (rev 1646)
@@ -1 +1 @@
-b339f74be925a4b3ea844063920c6a3d4b435f32
\ No newline at end of file
+ba2b6ee4825a4950f50c43e9da424431ceb7db54
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090530/77f1a636/attachment-0001.html>


More information about the macruby-changes mailing list