[macruby-changes] [1854] MacRuby/branches/experimental/spec/frozen
source_changes at macosforge.org
source_changes at macosforge.org
Sun Jun 14 11:58:26 PDT 2009
Revision: 1854
http://trac.macosforge.org/projects/ruby/changeset/1854
Author: eloy.de.enige at gmail.com
Date: 2009-06-14 11:58:26 -0700 (Sun, 14 Jun 2009)
Log Message:
-----------
Updated RubySpec to 9c5b3ddd2703ce570abad92592764361e065703f. Includes the Ruby-FFI specs! :)
Modified Paths:
--------------
MacRuby/branches/experimental/spec/frozen/core/argf/binmode_spec.rb
MacRuby/branches/experimental/spec/frozen/core/argf/chars_spec.rb
MacRuby/branches/experimental/spec/frozen/core/argf/close_spec.rb
MacRuby/branches/experimental/spec/frozen/core/argf/closed_spec.rb
MacRuby/branches/experimental/spec/frozen/core/argf/file_spec.rb
MacRuby/branches/experimental/spec/frozen/core/argf/getc_spec.rb
MacRuby/branches/experimental/spec/frozen/core/argf/gets_spec.rb
MacRuby/branches/experimental/spec/frozen/core/argf/lineno_spec.rb
MacRuby/branches/experimental/spec/frozen/core/argf/pos_spec.rb
MacRuby/branches/experimental/spec/frozen/core/argf/read_spec.rb
MacRuby/branches/experimental/spec/frozen/core/argf/readchar_spec.rb
MacRuby/branches/experimental/spec/frozen/core/argf/readline_spec.rb
MacRuby/branches/experimental/spec/frozen/core/argf/rewind_spec.rb
MacRuby/branches/experimental/spec/frozen/core/argf/seek_spec.rb
MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_byte.rb
MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_char.rb
MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_line.rb
MacRuby/branches/experimental/spec/frozen/core/argf/shared/eof.rb
MacRuby/branches/experimental/spec/frozen/core/argf/shared/filename.rb
MacRuby/branches/experimental/spec/frozen/core/argf/shared/fileno.rb
MacRuby/branches/experimental/spec/frozen/core/argf/shared/getc.rb
MacRuby/branches/experimental/spec/frozen/core/argf/shared/gets.rb
MacRuby/branches/experimental/spec/frozen/core/argf/shared/pos.rb
MacRuby/branches/experimental/spec/frozen/core/argf/shared/readlines.rb
MacRuby/branches/experimental/spec/frozen/core/argf/skip_spec.rb
MacRuby/branches/experimental/spec/frozen/core/argf/to_io_spec.rb
MacRuby/branches/experimental/spec/frozen/core/argf/to_s_spec.rb
MacRuby/branches/experimental/spec/frozen/core/array/fixtures/classes.rb
MacRuby/branches/experimental/spec/frozen/core/array/sort_spec.rb
MacRuby/branches/experimental/spec/frozen/core/basicobject/basic_object_class_spec.rb
MacRuby/branches/experimental/spec/frozen/core/builtin_constants/builtin_constants_spec.rb
MacRuby/branches/experimental/spec/frozen/core/class/initialize_spec.rb
MacRuby/branches/experimental/spec/frozen/core/continuation/continuation_spec.rb
MacRuby/branches/experimental/spec/frozen/core/dir/pwd_spec.rb
MacRuby/branches/experimental/spec/frozen/core/env/select_spec.rb
MacRuby/branches/experimental/spec/frozen/core/exception/exception_spec.rb
MacRuby/branches/experimental/spec/frozen/core/exception/standard_error_spec.rb
MacRuby/branches/experimental/spec/frozen/core/file/chmod_spec.rb
MacRuby/branches/experimental/spec/frozen/core/file/new_spec.rb
MacRuby/branches/experimental/spec/frozen/core/file/size_spec.rb
MacRuby/branches/experimental/spec/frozen/core/fixnum/id2name_spec.rb
MacRuby/branches/experimental/spec/frozen/core/fixnum/induced_from_spec.rb
MacRuby/branches/experimental/spec/frozen/core/fixnum/to_sym_spec.rb
MacRuby/branches/experimental/spec/frozen/core/float/induced_from_spec.rb
MacRuby/branches/experimental/spec/frozen/core/hash/element_reference_spec.rb
MacRuby/branches/experimental/spec/frozen/core/hash/rehash_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/key.rb
MacRuby/branches/experimental/spec/frozen/core/hash/shared/store.rb
MacRuby/branches/experimental/spec/frozen/core/integer/induced_from_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/Float_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/Integer_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/String_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/callcc_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/catch_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/chomp_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/chop_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/dup_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/extend_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/fixtures/classes.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/getc_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/global_variables_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/gsub_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/local_variables_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/method_missing_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/private_methods_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/public_methods_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/require_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/scan_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/singleton_method_added_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/singleton_method_removed_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/singleton_method_undefined_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/split_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/sub_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/system_spec_disabled.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/throw_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/to_a_spec.rb
MacRuby/branches/experimental/spec/frozen/core/matchdata/select_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/acos_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/acosh_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/asin_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/asinh_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/atan2_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/atan_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/atanh_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/cos_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/cosh_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/erf_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/erfc_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/exp_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/fixtures/classes.rb
MacRuby/branches/experimental/spec/frozen/core/math/frexp_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/hypot_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/ldexp_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/log10_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/log_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/sin_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/sinh_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/sqrt_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/tan_spec.rb
MacRuby/branches/experimental/spec/frozen/core/math/tanh_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/attr_writer_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/autoload_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/class_variable_defined_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/class_variable_get_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/class_variable_set_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/class_variables_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/extended_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/freeze_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/include_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/included_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/instance_method_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/private_method_defined_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/protected_instance_methods_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/protected_method_defined_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/public_method_defined_spec.rb
MacRuby/branches/experimental/spec/frozen/core/object/match_spec.rb
MacRuby/branches/experimental/spec/frozen/core/precision/included_spec.rb
MacRuby/branches/experimental/spec/frozen/core/precision/prec_f_spec.rb
MacRuby/branches/experimental/spec/frozen/core/precision/prec_i_spec.rb
MacRuby/branches/experimental/spec/frozen/core/precision/prec_spec.rb
MacRuby/branches/experimental/spec/frozen/core/proc/to_s_spec.rb
MacRuby/branches/experimental/spec/frozen/core/process/fork_spec.rb
MacRuby/branches/experimental/spec/frozen/core/regexp/kcode_spec.rb
MacRuby/branches/experimental/spec/frozen/core/regexp/shared/new.rb
MacRuby/branches/experimental/spec/frozen/core/struct/members_spec.rb
MacRuby/branches/experimental/spec/frozen/core/struct/new_spec.rb
MacRuby/branches/experimental/spec/frozen/core/symbol/inspect_spec.rb
MacRuby/branches/experimental/spec/frozen/core/thread/critical_spec.rb
MacRuby/branches/experimental/spec/frozen/core/thread/element_reference_spec.rb
MacRuby/branches/experimental/spec/frozen/core/thread/element_set_spec.rb
MacRuby/branches/experimental/spec/frozen/core/thread/exit_spec.rb
MacRuby/branches/experimental/spec/frozen/core/thread/fixtures/classes.rb
MacRuby/branches/experimental/spec/frozen/core/thread/key_spec.rb
MacRuby/branches/experimental/spec/frozen/core/thread/stop_spec.rb
MacRuby/branches/experimental/spec/frozen/core/time/strftime_spec.rb
MacRuby/branches/experimental/spec/frozen/language/class_spec.rb
MacRuby/branches/experimental/spec/frozen/language/metaclass_spec.rb
MacRuby/branches/experimental/spec/frozen/language/private_spec.rb
MacRuby/branches/experimental/spec/frozen/library/bigdecimal/new_spec.rb
MacRuby/branches/experimental/spec/frozen/library/date/shared/civil.rb
MacRuby/branches/experimental/spec/frozen/library/ftools/catname_spec.rb
MacRuby/branches/experimental/spec/frozen/library/ftools/chmod_spec.rb
MacRuby/branches/experimental/spec/frozen/library/ftools/compare_spec.rb
MacRuby/branches/experimental/spec/frozen/library/ftools/copy_spec.rb
MacRuby/branches/experimental/spec/frozen/library/ftools/install_spec.rb
MacRuby/branches/experimental/spec/frozen/library/ftools/makedirs_spec.rb
MacRuby/branches/experimental/spec/frozen/library/ftools/move_spec.rb
MacRuby/branches/experimental/spec/frozen/library/ftools/safe_unlink_spec.rb
MacRuby/branches/experimental/spec/frozen/library/ftools/syscopy_spec.rb
MacRuby/branches/experimental/spec/frozen/library/generator/each_spec.rb
MacRuby/branches/experimental/spec/frozen/library/generator/new_spec.rb
MacRuby/branches/experimental/spec/frozen/library/generator/next_spec.rb
MacRuby/branches/experimental/spec/frozen/library/generator/rewind_spec.rb
MacRuby/branches/experimental/spec/frozen/library/ping/pingecho_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/Rational_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/equal_value_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/new_spec.rb
MacRuby/branches/experimental/spec/frozen/library/rational/reduce_spec.rb
MacRuby/branches/experimental/spec/frozen/ruby.1.8.mspec
MacRuby/branches/experimental/spec/frozen/ruby.1.9.mspec
MacRuby/branches/experimental/spec/frozen/spec_helper.rb
MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/throw_tags.txt
MacRuby/branches/experimental/spec/frozen/upstream
MacRuby/branches/experimental/spec/frozen/version.rb
Added Paths:
-----------
MacRuby/branches/experimental/spec/frozen/TODO
MacRuby/branches/experimental/spec/frozen/core/array/sort_by_spec.rb
MacRuby/branches/experimental/spec/frozen/core/basicobject/method_missing_spec.rb
MacRuby/branches/experimental/spec/frozen/core/basicobject/singleton_method_added_spec.rb
MacRuby/branches/experimental/spec/frozen/core/basicobject/singleton_method_removed_spec.rb
MacRuby/branches/experimental/spec/frozen/core/basicobject/singleton_method_undefined_spec.rb
MacRuby/branches/experimental/spec/frozen/core/range/cover_spec.rb
MacRuby/branches/experimental/spec/frozen/fixtures/kernel/
MacRuby/branches/experimental/spec/frozen/fixtures/kernel/classes.rb
MacRuby/branches/experimental/spec/frozen/library/parsedate/parsedate_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/
MacRuby/branches/experimental/spec/frozen/optional/ffi/
MacRuby/branches/experimental/spec/frozen/optional/ffi/buffer_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/callback_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/enum_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/errno_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/
MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/Benchmark.c
MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/BufferTest.c
MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/ClosureTest.c
MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/EnumTest.c
MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/GNUmakefile
MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/GlobalVariable.c
MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/LastErrorTest.c
MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/NumberTest.c
MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/PointerTest.c
MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/ReferenceTest.c
MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/StringTest.c
MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/StructTest.c
MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/UnionTest.c
MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/VariadicTest.c
MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/classes.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/library_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/managed_struct_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/number_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/pointer_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/rbx/
MacRuby/branches/experimental/spec/frozen/optional/ffi/rbx/attach_function_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/rbx/memory_pointer_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/rbx/struct_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/spec_helper.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/string_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/struct_callback_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/struct_initialize_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/struct_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/typedef_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/union_spec.rb
MacRuby/branches/experimental/spec/frozen/optional/ffi/variadic_spec.rb
MacRuby/branches/experimental/spec/frozen/shared/kernel/method_missing.rb
MacRuby/branches/experimental/spec/frozen/shared/kernel/singleton_method_added.rb
MacRuby/branches/experimental/spec/frozen/shared/kernel/singleton_method_removed.rb
MacRuby/branches/experimental/spec/frozen/shared/kernel/singleton_method_undefined.rb
Removed Paths:
-------------
MacRuby/branches/experimental/spec/frozen/library/parsedate/parsedate.rb
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/closed_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/each_line_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/each_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/eof_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/file_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/filename_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/fileno_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/getc_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/gets_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/path_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/pos_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/read_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/readchar_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/readline_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/readlines_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/rewind_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/seek_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/tell_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/to_a_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/to_i_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/to_io_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/to_s_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/continuation/continuation_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/dir/delete_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/dir/pwd_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/dir/rmdir_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/dir/unlink_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/delete_if_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/each_key_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/each_pair_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/each_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/each_value_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/reject_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/select_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/exception/standard_error_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/file/new_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/float/induced_from_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/kernel/require_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/matchdata/select_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/acosh_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/asin_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/asinh_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/atan2_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/atan_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/atanh_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/cos_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/cosh_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/erf_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/erfc_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/exp_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/frexp_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/hypot_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/ldexp_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/log10_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/log_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/sin_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/sinh_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/sqrt_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/tan_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/tanh_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/object/match_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/regexp/compile_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/regexp/kcode_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/regexp/new_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/struct/each_pair_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/struct/each_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/struct/members_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/1.9/core/struct/new_tags.txt
Added: MacRuby/branches/experimental/spec/frozen/TODO
===================================================================
--- MacRuby/branches/experimental/spec/frozen/TODO (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/TODO 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,59 @@
+* Decide a way to test methods that are only visible given a specific
+command-line option. For example, Kernel#gsub with -n/-p on 1.9.
+* Decide how to guard bugs that are regressions. IOW, if a bug appears in 1.9
+but not in 1.8, we should be able to guard it from 1.9 while still yielding to
+1.8.
+* Look at automating discovery of guarded bugs which have been fixed. Use
+* mocks for all Math functions that coerce with #to_f; currently a fixture
+is used.
+* Rational and Complex moved from library/ to core/ in 1.9. Where do we locate
+* the tests?
+* Confirm that 1.9 tags can be removed when the corresponding tests pass on
+1.9 trunk.
+* File ticket about ARGF#each_char, ARGF#each_byte, ARGF#chars, and ARGF#bytes
+* returning nil on 1.9.
+* Consider filing ticket about 1.8.6's ARGF#readlines returning nil at the end
+of a stream. 1.8.7+ returns an empty Array, as the rdoc since 1.8.6 implies.
+* File ticket: $ ruby86 -e 'p ARGF.skip'
+-e:1:in `skip': undefined method `close' for false:FalseClass (NoMethodError)
+ from -e:1
+* File ticket: "ruby -e 'p ARGF.read; ARGF.skip'" raises "closed stream
+(IOError)" when two files are given. ARGF#skip should be a no-op when there
+are no more files.
+* Determine correct behaviour of ARGF#skip, file ticket if necessary, then
+update failing tests in core/argf/skip_spec.rb.
+* The failing ARGF#lineno tests are due to a race-ish condition whereby if the
+test is executed in the same run as other ARGF tests the #lineno value isn't
+reset. This can be fixed by explicitly reseting #lineno in the test, but
+that could mask another bug... Figure out who's to blame here.
+* Refactor Kernel.require specification; it's messy and ungainly.
+
+# 1.9
+=========
+* Methods expecting filenames or paths should call #to_path on non-String
+arguments. Tests need adding, and tickets may need filing for non-conforming
+methods.
+* Methods that could modify a frozen receiver should raise RuntimeError, even
+if the method's arguments are such that no modification would occur.
+* The inclusion of 'rational' by default has resulted in ZeroDivisionErrors
+being raised where they previously weren't. What is the rule of thumb in
+determining whether this outcome is intentional?
+
+## Rational
+===========
+
+ (All questions below were posed in:
+<http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/23843>)
+
+* Determine whether Rational::Unify was intentionally removed.
+* Determine whether Rational#new! was intentionally removed. If not, will
+there be a method to construct a Rational object without simplifying its
+arguments?
+* Determine whether Rational#coerce is supposed to call #to_f on non-numeric
+argument. 1.8 does.
+* Determine whether Rational.allocate has intentionally been removed. Presumably
+so because on 1.8 it creates Rational(nil, nil), which is illegal on 1.9.
+* Determine whether Rational.reduce has intentionally been removed. Presumably
+so because Rational() serves the same function.
+* Determine whether Rational#inspect and #to_s are intentionally different on
+1.9
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/binmode_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/binmode_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/binmode_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -8,7 +8,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "returns self" do
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/chars_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/chars_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/chars_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -5,4 +5,4 @@
describe "ARGF.chars" do
it_behaves_like :argf_each_char, :chars
end
-end
\ No newline at end of file
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/close_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/close_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/close_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -7,7 +7,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "closes the current open stream" do
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/closed_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/closed_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/closed_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -7,7 +7,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "returns true if the current stream has been closed" do
@@ -16,6 +16,7 @@
stream.close
ARGF.closed?.should be_true
+ stream.reopen(ARGF.filename, 'r')
end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/file_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/file_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/file_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -7,7 +7,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
# NOTE: this test assumes that fixtures files have two lines each
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/getc_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/getc_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/getc_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -12,7 +12,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "returns nil when end of stream reached" do
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/gets_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/gets_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/gets_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -19,7 +19,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "returns nil when reaching end of files" do
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/lineno_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/lineno_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/lineno_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -7,7 +7,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
# NOTE: this test assumes that fixtures files have two lines each
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/pos_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/pos_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/pos_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -15,7 +15,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
# NOTE: this test assumes that fixtures files have two lines each
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/read_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/read_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/read_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -12,7 +12,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "reads the contents of a file" do
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/readchar_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/readchar_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/readchar_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -12,7 +12,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "raises EOFError when end of stream reached" do
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/readline_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/readline_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/readline_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -16,7 +16,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "raises an EOFError when reaching end of files" do
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/rewind_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/rewind_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/rewind_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -10,7 +10,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
# NOTE: this test assumes that fixtures files have two lines each
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/seek_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/seek_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/seek_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -10,7 +10,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "sets the absolute position relative to beginning of file" do
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_byte.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_byte.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_byte.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -9,7 +9,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "yields each byte of all streams to the passed block" do
@@ -46,4 +46,4 @@
end
end
end
-end
\ No newline at end of file
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_char.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_char.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_char.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -9,7 +9,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "yields each char of all streams to the passed block" do
@@ -36,4 +36,4 @@
chars.should == @chars
end
end
-end
\ No newline at end of file
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_line.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_line.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/shared/each_line.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -8,7 +8,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "reads each line of files" do
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/shared/eof.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/shared/eof.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/shared/eof.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -5,7 +5,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
# NOTE: this test assumes that fixtures files have two lines each
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/shared/filename.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/shared/filename.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/shared/filename.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -5,7 +5,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
# NOTE: this test assumes that fixtures files have two lines each
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/shared/fileno.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/shared/fileno.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/shared/fileno.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -5,7 +5,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
# NOTE: this test assumes that fixtures files have two lines each
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/shared/getc.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/shared/getc.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/shared/getc.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -8,7 +8,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "reads each char of files" do
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/shared/gets.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/shared/gets.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/shared/gets.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -10,7 +10,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "reads one line of a file" do
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/shared/pos.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/shared/pos.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/shared/pos.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -5,7 +5,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "gives the correct position for each read operation" do
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/shared/readlines.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/shared/readlines.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/shared/readlines.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -8,7 +8,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "reads all lines of all files" do
@@ -17,10 +17,21 @@
end
end
- it "returns nil when end of stream reached" do
- argv [@file1, @file2] do
- ARGF.read
- ARGF.send(@method).should == nil
+ ruby_version_is ""..."1.9" do
+ it "returns nil when end of stream reached" do
+ argv [@file1, @file2] do
+ ARGF.read
+ ARGF.send(@method).should == nil
+ end
end
end
+
+ ruby_version_is "1.9" do
+ it "returns an empty Array when end of stream reached" do
+ argv [@file1, @file2] do
+ ARGF.read
+ ARGF.send(@method).should == []
+ end
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/skip_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/skip_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/skip_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -9,7 +9,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "skips the current file" do
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/to_io_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/to_io_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/to_io_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -7,7 +7,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
# NOTE: this test assumes that fixtures files have two lines each
Modified: MacRuby/branches/experimental/spec/frozen/core/argf/to_s_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/argf/to_s_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/argf/to_s_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -7,7 +7,7 @@
end
after :each do
- ARGF.close
+ ARGF.close unless ARGF.closed?
end
it "returns 'ARGF'" do
Modified: MacRuby/branches/experimental/spec/frozen/core/array/fixtures/classes.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/fixtures/classes.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/array/fixtures/classes.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -100,4 +100,42 @@
end
end
+ class SortSame
+ def <=>(other); 0; end
+ def ==(other); true; end
+ end
+
+ class UFOSceptic
+ def <=>(other); raise "N-uh, UFO:s do not exist!"; end
+ end
+
+ class MockForCompared
+ @@count = 0
+ @@compared = false
+ def initialize
+ @@compared = false
+ @order = (@@count += 1)
+ end
+ def <=>(rhs)
+ @@compared = true
+ return rhs.order <=> self.order
+ end
+ def self.compared?
+ @@compared
+ end
+
+ protected
+ attr_accessor :order
+ end
+
+ class ComparableWithFixnum
+ include Comparable
+ def initialize(num)
+ @num = num
+ end
+
+ def <=>(fixnum)
+ @num <=> fixnum
+ end
+ end
end
Added: MacRuby/branches/experimental/spec/frozen/core/array/sort_by_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/sort_by_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/array/sort_by_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,59 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+ruby_version_is "1.9.2" do
+
+ describe "Array#sort_by!" do
+ it "sorts array in place by passing each element to the given block" do
+ a = [1, -2, 3, 9, 1, 5, -5, 1000, -5, 2, -10, 14, 6, 23, 0]
+ a.sort_by!{ |e| e.to_s.size }
+ a.should == [1, 6, 3, 9, 1, 5, 2, 0, -5, -5, 23, -2, 14, -10, 1000]
+ end
+
+ it "returns an Enumerator if not given a block" do
+ (1..10).to_a.sort_by!.should be_kind_of(Enumerator)
+ end
+
+ it "completes when supplied a block that always returns the same result" do
+ a = [2, 3, 5, 1, 4]
+ a.sort_by!{ 1 }
+ a.class.should == Array
+ a.sort_by!{ 0 }
+ a.class.should == Array
+ a.sort_by!{ -1 }
+ a.class.should == Array
+ end
+
+ ruby_version_is '' ... '1.9' do
+ it "raises a TypeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array.sort_by! {} }.should raise_error(TypeError)
+ end
+
+ it "temporarily freezes self and recovers after sorted" do
+ a = [1, 2, 3]
+ a.sort_by! { |x,y| a.frozen?.should == true; x <=> y }
+ a.frozen?.should == false
+ end
+ end
+
+ ruby_version_is '1.9' do
+ it "raises a RuntimeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array.sort_by! {}}.should raise_error(RuntimeError)
+ end
+
+ end
+
+ it "returns the specified value when it would break in the given block" do
+ [1, 2, 3].sort_by!{ break :a }.should == :a
+ end
+
+ it "makes some modification even if finished sorting when it would break in the given block" do
+ partially_sorted = (1..5).map{|i|
+ ary = [5, 4, 3, 2, 1]
+ ary.sort_by!{|x,y| break if x==i; x<=>y}
+ ary
+ }
+ partially_sorted.any?{|ary| ary != [1, 2, 3, 4, 5]}.should be_true
+ end
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/array/sort_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/sort_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/array/sort_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,48 +1,6 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/fixtures/classes'
-module ArraySpecs
- class SortSame
- def <=>(other); 0; end
- def ==(other); true; end
- end
-
- class UFOSceptic
- def <=>(other); raise "N-uh, UFO:s do not exist!"; end
- end
-
- class MockForCompared
- @@count = 0
- @@compared = false
- def initialize
- @@compared = false
- @order = (@@count += 1)
- end
- def <=>(rhs)
- @@compared = true
- return rhs.order <=> self.order
- end
- def self.compared?
- @@compared
- end
-
- protected
- attr_accessor :order
- end
-
- class ComparableWithFixnum
- include Comparable
- def initialize(num)
- @num = num
- end
-
- def <=>(fixnum)
- @num <=> fixnum
- end
- end
-end
-
-
describe "Array#sort" do
it "returns a new array sorted based on comparing elements with <=>" do
a = [1, -2, 3, 9, 1, 5, -5, 1000, -5, 2, -10, 14, 6, 23, 0]
Modified: MacRuby/branches/experimental/spec/frozen/core/basicobject/basic_object_class_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/basicobject/basic_object_class_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/basicobject/basic_object_class_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -8,6 +8,10 @@
it "has no ancestors" do
BasicObject.ancestors.should == [ BasicObject ]
end
+
+ it "has no superclass" do
+ BasicObject.superclass.should be_nil
+ end
it "is a class" do
( Class === BasicObject ).should == true
Added: MacRuby/branches/experimental/spec/frozen/core/basicobject/method_missing_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/basicobject/method_missing_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/basicobject/method_missing_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,15 @@
+require File.dirname(__FILE__) + '/../../shared/kernel/method_missing'
+
+ruby_version_is "1.9" do
+ describe "BasicObject#method_missing" do
+ it_behaves_like(:method_missing, :method_missing, BasicObject)
+ end
+
+ describe "BasicObject#method_missing is undefined" do
+ it_behaves_like(:method_missing_undef, :method_missing, BasicObject)
+ end
+
+ describe "BasicObject.method_missing" do
+ it_behaves_like(:method_missing_class_method, :method_missing, BasicObject)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/basicobject/singleton_method_added_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/basicobject/singleton_method_added_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/basicobject/singleton_method_added_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/../../shared/kernel/singleton_method_added'
+
+ruby_version_is "1.9" do
+ describe "BasicObject#singleton_method_added" do
+ it_behaves_like(:singleton_method_added, :singleton_method_added, BasicObject)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/basicobject/singleton_method_removed_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/basicobject/singleton_method_removed_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/basicobject/singleton_method_removed_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/../../shared/kernel/singleton_method_removed'
+
+ruby_version_is "1.9" do
+ describe "BasicObject#singleton_method_removed" do
+ it_behaves_like(:singleton_method_removed, :singleton_method_removed, BasicObject)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/basicobject/singleton_method_undefined_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/basicobject/singleton_method_undefined_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/basicobject/singleton_method_undefined_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../shared/kernel/singleton_method_undefined'
+
+ruby_version_is "1.9" do
+ describe "BasicObject#singleton_method_undefined" do
+ it_behaves_like(:singleton_method_undefined, :singleton_method_undefined, BasicObject)
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/builtin_constants/builtin_constants_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/builtin_constants/builtin_constants_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/builtin_constants/builtin_constants_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -10,4 +10,48 @@
it "is a Fixnum" do
RUBY_PATCHLEVEL.should be_kind_of(Fixnum)
end
+end
+
+ruby_version_is "1.8.7" do
+ describe "RUBY_COPYRIGHT" do
+ it "is a String" do
+ RUBY_COPYRIGHT.should be_kind_of(String)
+ end
+ end
+end
+
+ruby_version_is "1.8.7" do
+ describe "RUBY_DESCRIPTION" do
+ it "is a String" do
+ RUBY_DESCRIPTION.should be_kind_of(String)
+ end
+ end
+end
+
+ruby_version_is "1.9" do
+ describe "RUBY_ENGINE" do
+ it "is a String" do
+ RUBY_ENGINE.should be_kind_of(String)
+ end
+ end
+end
+
+describe "RUBY_PLATFORM" do
+ it "is a String" do
+ RUBY_PLATFORM.should be_kind_of(String)
+ end
+end
+
+describe "RUBY_RELEASE_DATE" do
+ it "is a String" do
+ RUBY_RELEASE_DATE.should be_kind_of(String)
+ end
+end
+
+ruby_version_is "1.9" do
+ describe "RUBY_REVISION" do
+ it "is a Fixnum" do
+ RUBY_REVISION.should be_kind_of(Fixnum)
+ end
+ end
end
\ No newline at end of file
Modified: MacRuby/branches/experimental/spec/frozen/core/class/initialize_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/class/initialize_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/class/initialize_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -5,24 +5,34 @@
klass = Class.new
klass.new.is_a?(klass).should == true
end
-
+
it "invokes #initialize on the new instance with the given args" do
klass = Class.new do
def initialize(*args)
@initialized = true
@args = args
end
-
+
def args
@args
end
-
+
def initialized?
@initialized || false
end
end
-
+
klass.new.initialized?.should == true
klass.new(1, 2, 3).args.should == [1, 2, 3]
end
-end
\ No newline at end of file
+
+ it "passes the block to #initialize" do
+ klass = Class.new do
+ def initialize
+ yield
+ end
+ end
+
+ klass.new { break 42 }.should == 42
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/continuation/continuation_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/continuation/continuation_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/continuation/continuation_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -4,6 +4,10 @@
#
require File.dirname(__FILE__) + '/../../spec_helper'
+ruby_version_is "1.9" do
+ require 'continuation'
+end
+
# Class methods
# -
#
Modified: MacRuby/branches/experimental/spec/frozen/core/dir/pwd_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/dir/pwd_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/dir/pwd_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -5,20 +5,39 @@
describe "Dir.pwd" do
it_behaves_like :dir_pwd, :pwd
- it "correctly displays dirs with unicode characters in them" do
- DirSpecs.clear_dirs
+ ruby_version_is ""..."1.9" do
+ it "correctly displays dirs with unicode characters in them" do
+ DirSpecs.clear_dirs
- begin
- old_kcode, $KCODE=$KCODE,'u'
- str = [0xe9].pack 'U' #Unicode \xE9
- Dir.mkdir str
- File.exist?(str).should == true
+ begin
+ old_kcode, $KCODE=$KCODE,'u'
+ str = [0xe9].pack 'U' #Unicode \xE9
+ Dir.mkdir str
+ File.exist?(str).should == true
- old_pwd = Dir.pwd
- Dir.chdir(str) { Dir.pwd.should == File.join(old_pwd, str) }
- ensure
+ old_pwd = Dir.pwd
+ Dir.chdir(str) { Dir.pwd.should == File.join(old_pwd, str) }
+ ensure
+ DirSpecs.clear_dirs
+ $KCODE=old_kcode
+ end
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "correctly displays dirs with unicode characters in them" do
DirSpecs.clear_dirs
- $KCODE=old_kcode
+
+ begin
+ str = [0xe9].pack 'U' #Unicode \xE9
+ Dir.mkdir str
+ File.exist?(str).should == true
+
+ old_pwd = Dir.pwd
+ Dir.chdir(str) { Dir.pwd.force_encoding('UTF-8').should == File.join(old_pwd, str) }
+ ensure
+ DirSpecs.clear_dirs
+ end
end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/env/select_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/env/select_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/env/select_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -2,12 +2,22 @@
describe "ENV.select" do
- it "returns the Hash for which block return true" do
- ENV["foo"] = "bar"
- ENV.select { |k, v| k == "foo" }.should == [["foo", "bar"]]
- ENV.delete "foo"
+ ruby_version_is ""..."1.9" do
+ it "returns the Hash for which block return true" do
+ ENV["foo"] = "bar"
+ ENV.select { |k, v| k == "foo" }.should == [["foo", "bar"]]
+ ENV.delete "foo"
+ end
end
+ ruby_version_is "1.9" do
+ it "returns the Hash for which block return true" do
+ ENV["foo"] = "bar"
+ ENV.select { |k, v| k == "foo" }.should == {"foo" => "bar"}
+ ENV.delete "foo"
+ end
+ end
+
ruby_version_is "" ... "1.8.7" do
it "raises when no block is given" do
lambda { ENV.select }.should raise_error(LocalJumpError)
Modified: MacRuby/branches/experimental/spec/frozen/core/exception/exception_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/exception/exception_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/exception/exception_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -37,4 +37,10 @@
it "is a superclass of SystemStackError" do
Exception.should be_ancestor_of(SystemStackError)
end
+
+ ruby_version_is "1.9" do
+ it "is a superclass of SecurityError" do
+ Exception.should be_ancestor_of(SecurityError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/exception/standard_error_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/exception/standard_error_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/exception/standard_error_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -33,8 +33,10 @@
StandardError.should be_ancestor_of(RuntimeError)
end
- it "is a superclass of SecurityError" do
- StandardError.should be_ancestor_of(SecurityError)
+ ruby_version_is ""..."1.9" do
+ it "is a superclass of SecurityError" do
+ StandardError.should be_ancestor_of(SecurityError)
+ end
end
it "is a superclass of SystemCallError" do
Modified: MacRuby/branches/experimental/spec/frozen/core/file/chmod_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/file/chmod_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/file/chmod_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -132,7 +132,7 @@
end
it "throws a TypeError if the given path is not coercable into a string" do
- lambda { File.chmod(0, @file.to_sym) }.should raise_error(TypeError)
+ lambda { File.chmod(0, []) }.should raise_error(TypeError)
end
it "invokes to_int on non-integer argument" do
Modified: MacRuby/branches/experimental/spec/frozen/core/file/new_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/file/new_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/file/new_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -97,12 +97,16 @@
File.exists?(@file).should == true
end
- it "raises an Errno::EINVAL error with File::APPEND" do
- lambda { @fh = File.new(@file, File::APPEND) }.should raise_error(Errno::EINVAL)
+ ruby_bug "#1582", "1.9.2" do
+ it "raises an Errno::EINVAL error with File::APPEND" do
+ lambda { @fh = File.new(@file, File::APPEND) }.should raise_error(Errno::EINVAL)
+ end
end
- it "raises an Errno::EINVAL error with File::RDONLY|File::APPEND" do
- lambda { @fh = File.new(@file, File::RDONLY|File::APPEND) }.should raise_error(Errno::EINVAL)
+ ruby_bug "#1582", "1.9.2" do
+ it "raises an Errno::EINVAL error with File::RDONLY|File::APPEND" do
+ lambda { @fh = File.new(@file, File::RDONLY|File::APPEND) }.should raise_error(Errno::EINVAL)
+ end
end
it "raises an Errno::EINVAL error with File::RDONLY|File::WRONLY" do
@@ -125,6 +129,15 @@
File.exists?(@file).should == true
end
+ ruby_version_is "1.9" do
+ it "coerces filename using #to_path" do
+ name = mock("file")
+ name.should_receive(:to_path).and_return(@file)
+ File.new(name, "w") { }
+ File.exists?(@file).should == true
+ end
+ end
+
specify "expected errors " do
lambda { File.new(true) }.should raise_error(TypeError)
lambda { File.new(false) }.should raise_error(TypeError)
@@ -133,10 +146,12 @@
lambda { File.new(@file, File::CREAT, 0755, 'test') }.should raise_error(ArgumentError)
end
- # You can't alter mode or permissions when opening a file descriptor
- #
- it "can't alter mode or permissions when opening a file" do
- @fh = File.new(@file)
- lambda { File.new(@fh.fileno, @flags) }.should raise_error(Errno::EINVAL)
+ ruby_bug "#1582", "1.9.2" do
+ # You can't alter mode or permissions when opening a file descriptor
+ #
+ it "can't alter mode or permissions when opening a file" do
+ @fh = File.new(@file)
+ lambda { File.new(@fh.fileno, @flags) }.should raise_error(Errno::EINVAL)
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/file/size_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/file/size_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/file/size_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -31,3 +31,55 @@
it_behaves_like :file_size, :size?, File
it_behaves_like :file_size_missing, :size?, File
end
+
+ruby_version_is "1.9" do
+ describe "File#size" do
+
+ before :each do
+ @file = tmp('i_exist')
+ File.open(@file,'w'){|f| f.write 'rubinius'}
+ @file = File.new @file
+ end
+
+ after :each do
+ File.delete(@file.path) if File.exist?(@file.path)
+ end
+
+ it "is an instance method" do
+ @file.respond_to?(:size).should be_true
+ end
+
+ it "returns the file's size as a Fixnum" do
+ @file.size.should be_an_instance_of(Fixnum)
+ end
+
+ it "returns the file's size in bytes" do
+ @file.size.should == 8
+ end
+
+ it "returns the cached size of the file if subsequently deleted" do
+ File.delete(@file)
+ @file.size.should == 8
+ end
+
+ it "returns the file's current size even if modified" do
+ File.open(@file,'a') {|f| f.write '!'}
+ @file.size.should == 9
+ end
+
+ it "returns 0 for an empty file" do
+ @file = File.open(@file.path, 'w')
+ @file.truncate(0)
+ @file.size.should == 0
+ end
+
+ platform_is_not :windows do
+ it "follows symlinks if necessary" do
+ ln_file = tmp('i_exist_ln')
+ File.delete(ln_file) if File.exists?(ln_file)
+ File.symlink(@file.path, ln_file).should == 0
+ File.new(ln_file).size.should == 8
+ end
+ end
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/fixnum/id2name_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/fixnum/id2name_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/fixnum/id2name_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,19 +1,21 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-describe "Fixnum#id2name" do
+ruby_version_is ""..."1.9.1" do
+ describe "Fixnum#id2name" do
- not_compliant_on :rubinius do
- it "returns the string name of the object whose symbol ID is self" do
- a = :@sym
- b = :@ruby
- c = :@rubinius
- a.to_i.id2name.should == '@sym'
- b.to_i.id2name.should == '@ruby'
- c.to_i.id2name.should == '@rubinius'
- end
+ not_compliant_on :rubinius do
+ it "returns the string name of the object whose symbol ID is self" do
+ a = :@sym
+ b = :@ruby
+ c = :@rubinius
+ a.to_i.id2name.should == '@sym'
+ b.to_i.id2name.should == '@ruby'
+ c.to_i.id2name.should == '@rubinius'
+ end
- it "returns nil if there is no symbol in the symbol table with this value" do
- 100000000.id2name.should == nil
+ it "returns nil if there is no symbol in the symbol table with this value" do
+ 100000000.id2name.should == nil
+ end
end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/fixnum/induced_from_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/fixnum/induced_from_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/fixnum/induced_from_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,34 +1,36 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-describe "Fixnum.induced_from with [Float]" do
- it "returns a Fixnum when the passed Float is in Fixnum's range" do
- Fixnum.induced_from(2.5).should eql(2)
- Fixnum.induced_from(-3.14).should eql(-3)
- Fixnum.induced_from(10 - TOLERANCE).should eql(9)
- Fixnum.induced_from(TOLERANCE).should eql(0)
+ruby_version_is ""..."1.9" do
+ describe "Fixnum.induced_from with [Float]" do
+ it "returns a Fixnum when the passed Float is in Fixnum's range" do
+ Fixnum.induced_from(2.5).should eql(2)
+ Fixnum.induced_from(-3.14).should eql(-3)
+ Fixnum.induced_from(10 - TOLERANCE).should eql(9)
+ Fixnum.induced_from(TOLERANCE).should eql(0)
+ end
+
+ it "raises a RangeError when the passed Float is out of Fixnum's range" do
+ lambda { Fixnum.induced_from((2**64).to_f) }.should raise_error(RangeError)
+ lambda { Fixnum.induced_from(-(2**64).to_f) }.should raise_error(RangeError)
+ end
end
-
- it "raises a RangeError when the passed Float is out of Fixnum's range" do
- lambda { Fixnum.induced_from((2**64).to_f) }.should raise_error(RangeError)
- lambda { Fixnum.induced_from(-(2**64).to_f) }.should raise_error(RangeError)
- end
-end
-describe "Fixnum.induced_from" do
- it "returns the passed argument when passed a Fixnum" do
- Fixnum.induced_from(3).should eql(3)
- Fixnum.induced_from(-10).should eql(-10)
+ describe "Fixnum.induced_from" do
+ it "returns the passed argument when passed a Fixnum" do
+ Fixnum.induced_from(3).should eql(3)
+ Fixnum.induced_from(-10).should eql(-10)
+ end
+
+ it "tries to convert non-Integers to a Integers using #to_int" do
+ obj = mock("Converted to Integer")
+ obj.should_receive(:to_int).and_return(10)
+ Fixnum.induced_from(obj)
+ end
+
+ it "raises a TypeError when conversion to Integer returns a Bignum" do
+ obj = mock("Not converted to Integer")
+ obj.should_receive(:to_int).and_return(bignum_value)
+ lambda { Fixnum.induced_from(obj) }.should raise_error(RangeError)
+ end
end
-
- it "tries to convert non-Integers to a Integers using #to_int" do
- obj = mock("Converted to Integer")
- obj.should_receive(:to_int).and_return(10)
- Fixnum.induced_from(obj)
- end
-
- it "raises a TypeError when conversion to Integer returns a Bignum" do
- obj = mock("Not converted to Integer")
- obj.should_receive(:to_int).and_return(bignum_value)
- lambda { Fixnum.induced_from(obj) }.should raise_error(RangeError)
- end
-end
\ No newline at end of file
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/fixnum/to_sym_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/fixnum/to_sym_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/fixnum/to_sym_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,20 +1,22 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-describe "Fixnum#to_sym" do
- not_compliant_on :rubinius do
- it "returns the symbol whose integer value is self" do
- a = :@sym
- b = :@ruby
- c = :@rubinius
+ruby_version_is ""..."1.9.1" do
+ describe "Fixnum#to_sym" do
+ not_compliant_on :rubinius do
+ it "returns the symbol whose integer value is self" do
+ a = :@sym
+ b = :@ruby
+ c = :@rubinius
- a.to_i.to_sym.should == :@sym
- b.to_i.to_sym.should == :@ruby
- c.to_i.to_sym.should == :@rubinius
- end
+ a.to_i.to_sym.should == :@sym
+ b.to_i.to_sym.should == :@ruby
+ c.to_i.to_sym.should == :@rubinius
+ end
- it "returns nil if there is no symbol in the symbol table with this value" do
- 100000000.to_sym.should == nil
+ it "returns nil if there is no symbol in the symbol table with this value" do
+ 100000000.to_sym.should == nil
+ end
+
end
-
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/float/induced_from_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/float/induced_from_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/float/induced_from_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,36 +1,38 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-describe "Float.induced_from" do
- it "returns the passed argument when passed a Float" do
- Float.induced_from(5.5).should eql(5.5)
- Float.induced_from(-5.5).should eql(-5.5)
- Float.induced_from(TOLERANCE).should eql(TOLERANCE)
- end
-
- it "converts passed Fixnums or Bignums to Floats (using #to_f)" do
- Float.induced_from(5).should eql(5.0)
- Float.induced_from(-5).should eql(-5.0)
- Float.induced_from(0).should eql(0.0)
+ruby_version_is ""..."1.9" do
+ describe "Float.induced_from" do
+ it "returns the passed argument when passed a Float" do
+ Float.induced_from(5.5).should eql(5.5)
+ Float.induced_from(-5.5).should eql(-5.5)
+ Float.induced_from(TOLERANCE).should eql(TOLERANCE)
+ end
- Float.induced_from(bignum_value).should eql(bignum_value.to_f)
- Float.induced_from(-bignum_value).should eql(-bignum_value.to_f)
- end
+ it "converts passed Fixnums or Bignums to Floats (using #to_f)" do
+ Float.induced_from(5).should eql(5.0)
+ Float.induced_from(-5).should eql(-5.0)
+ Float.induced_from(0).should eql(0.0)
+
+ Float.induced_from(bignum_value).should eql(bignum_value.to_f)
+ Float.induced_from(-bignum_value).should eql(-bignum_value.to_f)
+ end
- it "does not try to convert non-Integers to Integers using #to_int" do
- obj = mock("Not converted to Integer")
- obj.should_not_receive(:to_int)
- lambda { Float.induced_from(obj) }.should raise_error(TypeError)
- end
+ it "does not try to convert non-Integers to Integers using #to_int" do
+ obj = mock("Not converted to Integer")
+ obj.should_not_receive(:to_int)
+ lambda { Float.induced_from(obj) }.should raise_error(TypeError)
+ end
- it "does not try to convert non-Integers to Floats using #to_f" do
- obj = mock("Not converted to Float")
- obj.should_not_receive(:to_f)
- lambda { Float.induced_from(obj) }.should raise_error(TypeError)
+ it "does not try to convert non-Integers to Floats using #to_f" do
+ obj = mock("Not converted to Float")
+ obj.should_not_receive(:to_f)
+ lambda { Float.induced_from(obj) }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when passed a non-Integer" do
+ lambda { Float.induced_from("2") }.should raise_error(TypeError)
+ lambda { Float.induced_from(:symbol) }.should raise_error(TypeError)
+ lambda { Float.induced_from(Object.new) }.should raise_error(TypeError)
+ end
end
-
- it "raises a TypeError when passed a non-Integer" do
- lambda { Float.induced_from("2") }.should raise_error(TypeError)
- lambda { Float.induced_from(:symbol) }.should raise_error(TypeError)
- lambda { Float.induced_from(Object.new) }.should raise_error(TypeError)
- end
-end
+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-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/element_reference_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -72,29 +72,26 @@
end
it "compares key via hash" do
- # Can't use should_receive because it uses hash internally
x = mock('0')
- def x.hash() 0 end
+ x.should_receive(:hash).and_return(0)
new_hash[x].should == nil
end
it "does not compare key with unknown hash codes via eql?" do
- # Can't use should_receive because it uses hash and eql? internally
x = mock('x')
y = mock('y')
def x.eql?(o) raise("Shouldn't receive eql?") end
- def x.hash() 0 end
- def y.hash() 1 end
+ x.should_receive(:hash).and_return(0)
+ y.should_receive(:hash).and_return(1)
new_hash(y => 1)[x].should == nil
end
it "compares key with found hash code via eql?" do
- # Can't use should_receive because it uses hash and eql? internally
y = mock('0')
- def y.hash() 0 end
+ y.should_receive(:hash).twice.and_return(0)
x = mock('0')
def x.hash()
Modified: MacRuby/branches/experimental/spec/frozen/core/hash/rehash_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/rehash_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/rehash_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -22,14 +22,13 @@
v1 = mock('v1')
v2 = mock('v2')
- # Can't use should_receive here because it uses hash() internally
- def v1.hash() raise("values shouldn't be rehashed"); end
- def v2.hash() raise("values shouldn't be rehashed"); end
+ v1.should_not_receive(:hash)
+ v2.should_not_receive(:hash)
h = new_hash(k1 => v1, k2 => v2)
- def k1.hash() 0 end
- def k2.hash() 0 end
+ k1.should_receive(:hash).twice.and_return(0)
+ k2.should_receive(:hash).twice.and_return(0)
h.rehash
h[k1].should == v1
Modified: MacRuby/branches/experimental/spec/frozen/core/hash/shared/eql.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/eql.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/eql.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -18,32 +18,22 @@
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
+ x.should_receive(:hash).any_number_of_times.and_return(0)
y = mock('y')
- def y.hash() 0 end
+ y.should_receive(:hash).any_number_of_times.and_return(0)
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
+ x.should_not_receive(:eql?)
+ y.should_not_receive(:eql?)
- def x.hash() 0 end
- def y.hash() 1 end
+ x.should_receive(:hash).any_number_of_times.and_return(0)
+ y.should_receive(:hash).any_number_of_times.and_return(1)
new_hash(x => 1).send(@method, new_hash(y => 1)).should be_false
end
Modified: MacRuby/branches/experimental/spec/frozen/core/hash/shared/equal.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/equal.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/equal.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -18,30 +18,23 @@
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
+ x.should_receive(:hash).and_return(0)
y = mock('y')
- def y.hash() 0 end
+ y.should_receive(:hash).and_return(0)
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
+ x.should_not_receive(:eql?)
+ y.should_not_receive(:eql?)
+ x.should_receive(:hash).and_return(0)
+ y.should_receive(:hash).and_return(1)
+
def x.hash() 0 end
def y.hash() 1 end
Modified: MacRuby/branches/experimental/spec/frozen/core/hash/shared/key.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/key.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/key.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -23,12 +23,11 @@
end
it "returns false for objects with the same hash" do
- o1 = Object.new
- def o1.hash() 0 end
+ x = mock('x')
+ y = mock('y')
+ x.should_receive(:hash).and_return(0)
+ y.should_receive(:hash).and_return(0)
- o2 = Object.new
- def o2.hash() 0 end
-
- new_hash(o1 => nil).send(@method, o2).should == false
+ new_hash(x => nil).send(@method, y).should == false
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/hash/shared/store.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/store.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/store.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -19,8 +19,8 @@
k1 = ["x"]
k2 = ["y"]
# So they end up in the same bucket
- def k1.hash() 0 end
- def k2.hash() 0 end
+ k1.should_receive(:hash).and_return(0)
+ k2.should_receive(:hash).and_return(0)
h[k1] = 1
h[k2] = 2
Modified: MacRuby/branches/experimental/spec/frozen/core/integer/induced_from_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/integer/induced_from_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/integer/induced_from_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,41 +1,43 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-describe "Integer.induced_from with [Float]" do
- it "returns a Fixnum when the passed Float is in Fixnum's range" do
- Integer.induced_from(2.5).should eql(2)
- Integer.induced_from(-3.14).should eql(-3)
- Integer.induced_from(10 - TOLERANCE).should eql(9)
- Integer.induced_from(TOLERANCE).should eql(0)
+ruby_version_is ""..."1.9" do
+ describe "Integer.induced_from with [Float]" do
+ it "returns a Fixnum when the passed Float is in Fixnum's range" do
+ Integer.induced_from(2.5).should eql(2)
+ Integer.induced_from(-3.14).should eql(-3)
+ Integer.induced_from(10 - TOLERANCE).should eql(9)
+ Integer.induced_from(TOLERANCE).should eql(0)
+ end
+
+ it "returns a Bignum when the passed Float is out of Fixnum's range" do
+ Integer.induced_from(bignum_value.to_f).should eql(bignum_value)
+ Integer.induced_from(-bignum_value.to_f).should eql(-bignum_value)
+ end
end
-
- it "returns a Bignum when the passed Float is out of Fixnum's range" do
- Integer.induced_from(bignum_value.to_f).should eql(bignum_value)
- Integer.induced_from(-bignum_value.to_f).should eql(-bignum_value)
- end
-end
-describe "Integer.induced_from" do
- it "returns the passed argument when passed a Bignum or Fixnum" do
- Integer.induced_from(1).should eql(1)
- Integer.induced_from(-10).should eql(-10)
- Integer.induced_from(bignum_value).should eql(bignum_value)
- end
-
- it "does not try to convert non-Integers to Integers using #to_int" do
- obj = mock("Not converted to Integer")
- obj.should_not_receive(:to_int)
- lambda { Integer.induced_from(obj) }.should raise_error(TypeError)
- end
+ describe "Integer.induced_from" do
+ it "returns the passed argument when passed a Bignum or Fixnum" do
+ Integer.induced_from(1).should eql(1)
+ Integer.induced_from(-10).should eql(-10)
+ Integer.induced_from(bignum_value).should eql(bignum_value)
+ end
+
+ it "does not try to convert non-Integers to Integers using #to_int" do
+ obj = mock("Not converted to Integer")
+ obj.should_not_receive(:to_int)
+ lambda { Integer.induced_from(obj) }.should raise_error(TypeError)
+ end
- it "does not try to convert non-Integers to Integers using #to_i" do
- obj = mock("Not converted to Integer")
- obj.should_not_receive(:to_i)
- lambda { Integer.induced_from(obj) }.should raise_error(TypeError)
+ it "does not try to convert non-Integers to Integers using #to_i" do
+ obj = mock("Not converted to Integer")
+ obj.should_not_receive(:to_i)
+ lambda { Integer.induced_from(obj) }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when passed a non-Integer" do
+ lambda { Integer.induced_from("2") }.should raise_error(TypeError)
+ lambda { Integer.induced_from(:symbol) }.should raise_error(TypeError)
+ lambda { Integer.induced_from(Object.new) }.should raise_error(TypeError)
+ end
end
-
- it "raises a TypeError when passed a non-Integer" do
- lambda { Integer.induced_from("2") }.should raise_error(TypeError)
- lambda { Integer.induced_from(:symbol) }.should raise_error(TypeError)
- lambda { Integer.induced_from(Object.new) }.should raise_error(TypeError)
- end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/Float_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/Float_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/Float_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -236,7 +236,7 @@
end
describe "Kernel#Float" do
- it_behaves_like :kernel_float, :Float, mock("receiver for Float()")
+ it_behaves_like :kernel_float, :Float, Object.new
end
describe "Kernel#Float" do
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/Integer_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/Integer_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/Integer_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -280,7 +280,7 @@
end
describe "Kernel#Integer" do
- it_behaves_like :kernel_integer, :Integer, mock("receiver for Integer()")
+ it_behaves_like :kernel_integer, :Integer, Object.new
it_behaves_like "Integer() given a String", :Integer
it "is a private method" do
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/String_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/String_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/String_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -2,51 +2,67 @@
require File.dirname(__FILE__) + '/fixtures/classes'
describe :kernel_String, :shared => true do
- it "converts the given argument to a String by calling #to_s" do
+ it "converts nil to a String" do
@object.send(@method, nil).should == ""
+ end
+
+ it "converts a Float to a String" do
@object.send(@method, 1.12).should == "1.12"
+ end
+
+ it "converts a boolean to a String" do
@object.send(@method, false).should == "false"
+ @object.send(@method, true).should == "true"
+ end
+
+ it "converts a constant to a String" do
@object.send(@method, Object).should == "Object"
+ end
- (obj = mock('test')).should_receive(:to_s).and_return("test")
+ it "calls #to_s to convert an arbitrary object to a String" do
+ obj = mock('test')
+ obj.should_receive(:to_s).and_return("test")
+
@object.send(@method, obj).should == "test"
end
- it "raises a TypeError if #to_s is not provided" do
- class << (obj = mock('to_s'))
- undef_method :to_s
- end
+ it "raises a TypeError if #to_s does not exist" do
+ obj = mock('to_s')
+ obj.undefine(:to_s)
- lambda { Kernel.String(obj) }.should raise_error(TypeError)
+ lambda { @object.send(@method, obj) }.should raise_error(TypeError)
end
-
- it "raises a TypeError if respond_to? returns false for to_s" do
+
+ it "raises a TypeError if respond_to? returns false for #to_s" do
obj = mock("to_s")
- def obj.respond_to?(meth, *)
- meth.to_s == "to_s" ? false : super
- end
+ obj.does_not_respond_to(:to_s)
- lambda { String(obj) }.should raise_error(TypeError)
+ lambda { @object.send(@method, obj) }.should raise_error(TypeError)
end
- it "tries to call the to_s method if respond_to? returns true for to_s" do
- class << (obj = mock('to_s'))
- undef_method :to_s
- end
+ it "raises a NoMethodError if #to_s is not defined but #respond_to?(:to_s) returns true" do
+ # cannot use a mock because of how RSpec affects #method_missing
+ obj = Object.new
+ obj.undefine(:to_s)
+ obj.responds_to(:to_s)
- def obj.respond_to?(meth, *)
- meth.to_s == "to_s" ? true : super
- end
-
lambda { @object.send(@method, obj) }.should raise_error(NoMethodError)
end
+ it "calls #to_s if #respond_to?(:to_s) returns true" do
+ obj = mock('to_s')
+ obj.undefine(:to_s)
+ obj.fake!(:to_s, "test")
+
+ @object.send(@method, obj).should == "test"
+ end
+
it "raises a TypeError if #to_s does not return a String" do
(obj = mock('123')).should_receive(:to_s).and_return(123)
lambda { @object.send(@method, obj) }.should raise_error(TypeError)
end
- it "returns the same object if it already a String" do
+ it "returns the same object if it is already a String" do
string = "Hello"
string.should_not_receive(:to_s)
string2 = @object.send(@method, string)
@@ -67,7 +83,7 @@
end
describe "Kernel#String" do
- it_behaves_like :kernel_String, :String, mock("receiver for String()")
+ it_behaves_like :kernel_String, :String, Object.new
it "is a private method" do
Kernel.should have_private_instance_method(:String)
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/callcc_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/callcc_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/callcc_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,6 +1,10 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/fixtures/classes'
+ruby_version_is "1.9" do
+ require 'continuation'
+end
+
describe "Kernel#callcc" do
it "is a private method" do
Kernel.should have_private_instance_method(:callcc)
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/catch_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/catch_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/catch_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -60,21 +60,36 @@
[one, two, three].should == [1, 2, 3]
end
- it "raises ArgumentError if the number of arguments is not one" do
+ it "raises ArgumentError if more than one arguments are given" do
lambda {
- catch {}
- }.should raise_error(ArgumentError)
- lambda {
catch(:one, :two) {}
}.should raise_error(ArgumentError)
end
- it "raises TypeError if the argument is not a symbol" do
- lambda {
- catch Object.new {}
- }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises TypeError if the argument is not a symbol" do
+ lambda {
+ catch Object.new {}
+ }.should raise_error(TypeError)
+ end
+
+ it "raises ArgumentError if called without argument" do
+ lambda { catch {} }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "accepts an object as an argument" do
+ lambda {
+ catch Object.new do end
+ }.should_not raise_error
+ end
+
+ it "yields a new, unique object when called without arguments" do
+ catch {|obj| obj.should be_an_instance_of(Object) }
+ end
+ end
+
it "raises LocalJumpError if no block is given" do
lambda { catch :blah }.should raise_error(LocalJumpError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/chomp_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/chomp_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/chomp_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,22 +1,26 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/fixtures/classes'
-describe "Kernel#chomp" do
- it "is a private method" do
- Kernel.should have_private_instance_method(:chomp)
+# FIXME: These methods exist on 1.9 only when the -n or -p option is passed to
+# ruby, but we currently don't have a way of specifying that.
+ruby_version_is ""..."1.9" do
+ describe "Kernel#chomp" do
+ it "is a private method" do
+ Kernel.should have_private_instance_method(:chomp)
+ end
end
-end
-describe "Kernel#chomp!" do
- it "is a private method" do
- Kernel.should have_private_instance_method(:chomp!)
+ describe "Kernel#chomp!" do
+ it "is a private method" do
+ Kernel.should have_private_instance_method(:chomp!)
+ end
end
-end
-describe "Kernel.chomp" do
- it "needs to be reviewed for spec completeness"
-end
+ describe "Kernel.chomp" do
+ it "needs to be reviewed for spec completeness"
+ end
-describe "Kernel.chomp!" do
- it "needs to be reviewed for spec completeness"
+ describe "Kernel.chomp!" do
+ it "needs to be reviewed for spec completeness"
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/chop_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/chop_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/chop_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,22 +1,26 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/fixtures/classes'
-describe "Kernel#chop" do
- it "is a private method" do
- Kernel.should have_private_instance_method(:chop)
+# FIXME: These methods exist on 1.9 only when the -n or -p option is passed to
+# ruby, but we currently don't have a way of specifying that.
+ruby_version_is ""..."1.9" do
+ describe "Kernel#chop" do
+ it "is a private method" do
+ Kernel.should have_private_instance_method(:chop)
+ end
end
-end
-describe "Kernel#chop!" do
- it "is a private method" do
- Kernel.should have_private_instance_method(:chop!)
+ describe "Kernel#chop!" do
+ it "is a private method" do
+ Kernel.should have_private_instance_method(:chop!)
+ end
end
-end
-describe "Kernel.chop" do
- it "needs to be reviewed for spec completeness"
-end
+ describe "Kernel.chop" do
+ it "needs to be reviewed for spec completeness"
+ end
-describe "Kernel.chop!" do
- it "needs to be reviewed for spec completeness"
-end
+ describe "Kernel.chop!" do
+ it "needs to be reviewed for spec completeness"
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/dup_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/dup_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/dup_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -40,8 +40,6 @@
end
dup = @obj.dup
- class << dup
- lambda { CLONE }.should raise_error(NameError)
- end
+ lambda { class << dup; CLONE; end }.should raise_error(NameError)
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/extend_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/extend_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/extend_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -37,12 +37,23 @@
(C.kind_of? KernelSpecs::M).should == true
end
- it "raises a TypeError if self is frozen" do
- module KernelSpecs::Mod; end
- o = mock('o')
- o.freeze
- lambda { o.extend KernelSpecs::Mod }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if self is frozen" do
+ module KernelSpecs::Mod; end
+ o = mock('o')
+ o.freeze
+ lambda { o.extend KernelSpecs::Mod }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError if self is frozen" do
+ module KernelSpecs::Mod; end
+ o = mock('o')
+ o.freeze
+ lambda { o.extend KernelSpecs::Mod }.should raise_error(RuntimeError)
+ end
+ end
end
describe "Kernel#extend" do
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/fixtures/classes.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/fixtures/classes.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/fixtures/classes.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -76,60 +76,7 @@
end
end
- module MethodMissing
- def self.method_missing(*args) :method_missing end
- def self.existing() :existing end
- def self.private_method() :private_method end
- private_class_method :private_method
- end
-
- class MethodMissingC
- def self.method_missing(*args) :method_missing end
- def method_missing(*args) :instance_method_missing end
-
- def self.existing() :existing end
- def existing() :instance_existing end
-
- def self.private_method() :private_method end
- def self.protected_method() :protected_method end
- class << self
- private :private_method
- protected :protected_method
- end
-
- def private_method() :private_instance_method end
- private :private_method
-
- def protected_method() :protected_instance_method end
- protected :protected_method
- end
-
- module NoMethodMissing
- def self.existing() :existing end
-
- def self.private_method() :private_method end
- private_class_method :private_method
- end
-
- class NoMethodMissingC
- def self.existing() :existing end
- def existing() :instance_existing end
-
- def self.private_method() :private_method end
- def self.protected_method() :protected_method end
- class << self
- private :private_method
- protected :protected_method
- end
-
- def private_method() :private_instance_method end
- private :private_method
-
- def protected_method() :protected_instance_method end
- protected :protected_method
- end
-
module BlockGiven
def self.accept_block
block_given?
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/getc_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/getc_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/getc_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,12 +1,14 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/fixtures/classes'
-describe "Kernel#getc" do
- it "is a private method" do
- Kernel.should have_private_instance_method(:getc)
+ruby_version_is ""..."1.9" do
+ describe "Kernel#getc" do
+ it "is a private method" do
+ Kernel.should have_private_instance_method(:getc)
+ end
end
-end
-describe "Kernel.getc" do
- it "needs to be reviewed for spec completeness"
+ describe "Kernel.getc" do
+ it "needs to be reviewed for spec completeness"
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/global_variables_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/global_variables_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/global_variables_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -6,14 +6,27 @@
Kernel.should have_private_instance_method(:global_variables)
end
- it "finds subset starting with std" do
- global_variables.grep(/std/).should include("$stderr", "$stdin", "$stdout")
- a = global_variables.size
- global_variables.include?("$foolish_global_var").should == false
- eval("$foolish_global_var = 1")
- global_variables.size.should == a+1
- global_variables.should include("$foolish_global_var")
+ ruby_version_is ""..."1.9" do
+ it "finds subset starting with std" do
+ global_variables.grep(/std/).should include("$stderr", "$stdin", "$stdout")
+ a = global_variables.size
+ global_variables.include?("$foolish_global_var").should == false
+ eval("$foolish_global_var = 1")
+ global_variables.size.should == a+1
+ global_variables.should include("$foolish_global_var")
+ end
end
+
+ ruby_version_is "1.9" do
+ it "finds subset starting with std" do
+ global_variables.grep(/std/).should include(:$stderr, :$stdin, :$stdout)
+ a = global_variables.size
+ global_variables.include?(:$foolish_global_var).should == false
+ eval("$foolish_global_var = 1")
+ global_variables.size.should == a+1
+ global_variables.should include(:$foolish_global_var)
+ end
+ end
end
describe "Kernel#global_variables" do
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/gsub_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/gsub_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/gsub_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,91 +1,95 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/fixtures/classes'
-describe "Kernel#gsub" do
- it "is a private method" do
- Kernel.should have_private_instance_method(:gsub)
- end
+# FIXME: These methods exist on 1.9 only when the -n or -p option is passed to
+# ruby, but we currently don't have a way of specifying that.
+ruby_version_is ""..."1.9" do
+ describe "Kernel#gsub" do
+ it "is a private method" do
+ Kernel.should have_private_instance_method(:gsub)
+ end
- it "raises a TypeError if $_ is not a String" do
- lambda {
- $_ = 123
- gsub /./, "!"
- }.should raise_error(TypeError)
- end
+ it "raises a TypeError if $_ is not a String" do
+ lambda {
+ $_ = 123
+ gsub /./, "!"
+ }.should raise_error(TypeError)
+ end
- it "when matches sets $_ to a new string, leaving the former value unaltered" do
- orig_value = $_ = "hello"
- gsub "ello", "ola"
- $_.should_not equal(orig_value)
- $_.should == "hola"
- orig_value.should == "hello"
- end
+ it "when matches sets $_ to a new string, leaving the former value unaltered" do
+ orig_value = $_ = "hello"
+ gsub "ello", "ola"
+ $_.should_not equal(orig_value)
+ $_.should == "hola"
+ orig_value.should == "hello"
+ end
- it "returns a string with the same contents as $_ after the operation" do
- $_ = "bye"
- gsub("non-match", "?").should == "bye"
+ it "returns a string with the same contents as $_ after the operation" do
+ $_ = "bye"
+ gsub("non-match", "?").should == "bye"
- orig_value = $_ = "bye"
- gsub(/$/, "!").should == "bye!"
- end
+ orig_value = $_ = "bye"
+ gsub(/$/, "!").should == "bye!"
+ end
- it "accepts Regexps as patterns" do
- $_ = "food"
- gsub /.$/, "l"
- $_.should == "fool"
- end
+ it "accepts Regexps as patterns" do
+ $_ = "food"
+ gsub /.$/, "l"
+ $_.should == "fool"
+ end
- it "accepts Strings as patterns, treated literally" do
- $_ = "hello, world."
- gsub ".", "!"
- $_.should == "hello, world!"
- end
+ it "accepts Strings as patterns, treated literally" do
+ $_ = "hello, world."
+ gsub ".", "!"
+ $_.should == "hello, world!"
+ end
- it "accepts objects which respond to #to_str as patterns and treats them as strings" do
- $_ = "hello, world."
- stringlike = mock(".")
- stringlike.should_receive(:to_str).and_return(".")
- gsub stringlike, "!"
- $_.should == "hello, world!"
+ it "accepts objects which respond to #to_str as patterns and treats them as strings" do
+ $_ = "hello, world."
+ stringlike = mock(".")
+ stringlike.should_receive(:to_str).and_return(".")
+ gsub stringlike, "!"
+ $_.should == "hello, world!"
+ end
end
-end
-describe "Kernel#gsub with a pattern and replacement" do
- it "accepts strings for replacement" do
- $_ = "hello"
- gsub /./, "."
- $_.should == "....."
- end
+ describe "Kernel#gsub with a pattern and replacement" do
+ it "accepts strings for replacement" do
+ $_ = "hello"
+ gsub /./, "."
+ $_.should == "....."
+ end
- it "accepts objects which respond to #to_str for replacement" do
- o = mock("o")
- o.should_receive(:to_str).and_return("o")
- $_ = "ping"
- gsub "i", o
- $_.should == "pong"
+ it "accepts objects which respond to #to_str for replacement" do
+ o = mock("o")
+ o.should_receive(:to_str).and_return("o")
+ $_ = "ping"
+ gsub "i", o
+ $_.should == "pong"
+ end
+
+ it "replaces \\1 sequences with the regexp's corresponding capture" do
+ $_ = "hello!"
+ gsub /(.)(.)/, '\2\1'
+ $_.should == "ehll!o"
+ end
end
- it "replaces \\1 sequences with the regexp's corresponding capture" do
- $_ = "hello!"
- gsub /(.)(.)/, '\2\1'
- $_.should == "ehll!o"
+ describe "Kernel#gsub with pattern and block" do
+ it "acts similarly to using $_.gsub" do
+ $_ = "olleh dlrow"
+ gsub(/(\w+)/){ $1.reverse }
+ $_.should == "hello world"
+ end
end
-end
-describe "Kernel#gsub with pattern and block" do
- it "acts similarly to using $_.gsub" do
- $_ = "olleh dlrow"
- gsub(/(\w+)/){ $1.reverse }
- $_.should == "hello world"
+ describe "Kernel#gsub!" do
+ it "is a private method" do
+ Kernel.should have_private_instance_method(:gsub!)
+ end
end
-end
-describe "Kernel#gsub!" do
- it "is a private method" do
- Kernel.should have_private_instance_method(:gsub!)
+ describe "Kernel.gsub!" do
+ it "needs to be reviewed for spec completeness"
end
end
-
-describe "Kernel.gsub!" do
- it "needs to be reviewed for spec completeness"
-end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/local_variables_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/local_variables_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/local_variables_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -6,21 +6,42 @@
Kernel.should have_private_instance_method(:local_variables)
end
- it "contains locals as they are added" do
- a = 1
- b = 2
- local_variables.should include("a", "b")
+ ruby_version_is ""..."1.9" do
+ it "contains locals as they are added" do
+ a = 1
+ b = 2
+ local_variables.should include("a", "b")
+ end
+
+ it "is accessable from bindings" do
+ def local_var_foo
+ a = 1
+ b = 2
+ binding
+ end
+ foo_binding = local_var_foo()
+ res = eval("local_variables",foo_binding)
+ res.should include("a", "b")
+ end
end
- it "is accessable from bindings" do
- def local_var_foo
+ ruby_version_is "1.9" do
+ it "contains locals as they are added" do
a = 1
b = 2
- binding
+ local_variables.should include(:a, :b)
end
- foo_binding = local_var_foo()
- res = eval("local_variables",foo_binding)
- res.should include("a", "b")
+
+ it "is accessable from bindings" do
+ def local_var_foo
+ a = 1
+ b = 2
+ binding
+ end
+ foo_binding = local_var_foo()
+ res = eval("local_variables",foo_binding)
+ res.should include(:a, :b)
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/method_missing_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/method_missing_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/method_missing_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,60 +1,15 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/../../shared/kernel/method_missing'
-describe "Kernel#method_missing" do
- it "is a private method" do
- Kernel.should have_private_instance_method(:method_missing)
- end
-
- it "is not called when a defined method is called" do
- KernelSpecs::MethodMissing.should_not_receive(:method_missing)
- KernelSpecs::MethodMissingC.should_not_receive(:method_missing)
- obj = KernelSpecs::MethodMissingC.new
- obj.should_not_receive(:method_missing)
-
- KernelSpecs::MethodMissing.existing.should == :existing
- KernelSpecs::MethodMissingC.existing.should == :existing
- obj.existing.should == :instance_existing
- end
-
- it "is called when an undefined method is called" do
- KernelSpecs::MethodMissing.nonexistent.should == :method_missing
- KernelSpecs::MethodMissingC.nonexistent.should == :method_missing
- KernelSpecs::MethodMissingC.new.nonexistent.should == :instance_method_missing
- end
-
- it "is called when a private method is called" do
- KernelSpecs::MethodMissing.private_method.should == :method_missing
- KernelSpecs::MethodMissingC.private_method.should == :method_missing
- KernelSpecs::MethodMissingC.new.private_method.should == :instance_method_missing
- end
-
- it "is called when a protected method is called" do
- KernelSpecs::MethodMissingC.protected_method.should == :method_missing
- KernelSpecs::MethodMissingC.new.protected_method.should == :instance_method_missing
- end
-end
+ruby_version_is ""..."1.9" do
+ describe "Kernel#method_missing" do
+ it_behaves_like(:method_missing, :method_missing, Kernel)
+ end
-describe "When Kernel#method_missing is undefined" do
- it "a NoMethodError is raised when an undefined method is called" do
- lambda { KernelSpecs::NoMethodMissing.nonexistent }.should raise_error(NoMethodError)
- lambda { KernelSpecs::NoMethodMissingC.nonexistent }.should raise_error(NoMethodError)
- lambda { KernelSpecs::NoMethodMissingC.new.nonexistent }.should raise_error(NoMethodError)
- end
-
- it "a NoMethodError is raised when a private method is called" do
- lambda { KernelSpecs::NoMethodMissing.nonexistent }.should raise_error(NoMethodError)
- lambda { KernelSpecs::NoMethodMissingC.nonexistent }.should raise_error(NoMethodError)
- lambda { KernelSpecs::NoMethodMissingC.new.nonexistent }.should raise_error(NoMethodError)
- end
-
- it "a NoMethodError is raised when a protected method is called" do
- lambda { KernelSpecs::NoMethodMissing.nonexistent }.should raise_error(NoMethodError)
- lambda { KernelSpecs::NoMethodMissingC.nonexistent }.should raise_error(NoMethodError)
- lambda { KernelSpecs::NoMethodMissingC.new.nonexistent }.should raise_error(NoMethodError)
- end
-end
+ describe "Kernel#method_missing is undefined" do
+ it_behaves_like(:method_missing_undef, :method_missing, Kernel)
+ end
-describe "Kernel.method_missing" do
- it "needs to be reviewed for spec completeness"
+ describe "Kernel.method_missing" do
+ it_behaves_like(:method_missing_class_method, :method_missing, Kernel)
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/private_methods_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/private_methods_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/private_methods_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -2,18 +2,37 @@
require File.dirname(__FILE__) + '/fixtures/classes'
describe "Kernel#private_methods" do
- it "returns a list of the names of privately accessible methods in the object" do
- m = KernelSpecs::Methods.private_methods(false)
- m.should include("shichi")
- m = KernelSpecs::Methods.new.private_methods(false)
- m.should include("juu_shi")
+ ruby_version_is ""..."1.9" do
+ it "returns a list of the names of privately accessible methods in the object" do
+ m = KernelSpecs::Methods.private_methods(false)
+ m.should include("shichi")
+ m = KernelSpecs::Methods.new.private_methods(false)
+ m.should include("juu_shi")
+ end
+
+ it "returns a list of the names of privately accessible methods in the object and its ancestors and mixed-in modules" do
+ m = (KernelSpecs::Methods.private_methods(false) & KernelSpecs::Methods.private_methods)
+
+ m.should include("shichi")
+ m = KernelSpecs::Methods.new.private_methods
+ m.should include('juu_shi')
+ end
end
-
- it "returns a list of the names of privately accessible methods in the object and its ancestors and mixed-in modules" do
- m = (KernelSpecs::Methods.private_methods(false) & KernelSpecs::Methods.private_methods)
+
+ ruby_version_is "1.9" do
+ it "returns a list of the names of privately accessible methods in the object" do
+ m = KernelSpecs::Methods.private_methods(false)
+ m.should include(:shichi)
+ m = KernelSpecs::Methods.new.private_methods(false)
+ m.should include(:juu_shi)
+ end
- m.should include("shichi")
- m = KernelSpecs::Methods.new.private_methods
- m.should include('juu_shi')
+ it "returns a list of the names of privately accessible methods in the object and its ancestors and mixed-in modules" do
+ m = (KernelSpecs::Methods.private_methods(false) & KernelSpecs::Methods.private_methods)
+
+ m.should include(:shichi)
+ m = KernelSpecs::Methods.new.private_methods
+ m.should include(:juu_shi)
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/public_methods_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/public_methods_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/public_methods_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -2,16 +2,33 @@
require File.dirname(__FILE__) + '/fixtures/classes'
describe "Kernel#public_methods" do
- it "returns a list of the names of publicly accessible methods in the object" do
- KernelSpecs::Methods.public_methods(false).sort.should include("allocate", "hachi",
- "ichi", "juu", "juu_ni", "new", "roku", "san", "shi", "superclass")
- KernelSpecs::Methods.new.public_methods(false).sort.should include("juu_san", "ni")
+ ruby_version_is ""..."1.9" do
+ it "returns a list of the names of publicly accessible methods in the object" do
+ KernelSpecs::Methods.public_methods(false).sort.should include("allocate", "hachi",
+ "ichi", "juu", "juu_ni", "new", "roku", "san", "shi", "superclass")
+ KernelSpecs::Methods.new.public_methods(false).sort.should include("juu_san", "ni")
+ end
+
+ it "returns a list of the names of publicly accessible methods in the object and its ancestors and mixed-in modules" do
+ (KernelSpecs::Methods.public_methods(false) & KernelSpecs::Methods.public_methods).sort.should include(
+ "allocate", "hachi", "ichi", "juu", "juu_ni", "new", "roku", "san", "shi", "superclass")
+ m = KernelSpecs::Methods.new.public_methods
+ m.should include('ni', 'juu_san')
+ end
end
-
- it "returns a list of the names of publicly accessible methods in the object and its ancestors and mixed-in modules" do
- (KernelSpecs::Methods.public_methods(false) & KernelSpecs::Methods.public_methods).sort.should include(
- "allocate", "hachi", "ichi", "juu", "juu_ni", "new", "roku", "san", "shi", "superclass")
- m = KernelSpecs::Methods.new.public_methods
- m.should include('ni', 'juu_san')
+
+ ruby_version_is "1.9" do
+ it "returns a list of the names of publicly accessible methods in the object" do
+ KernelSpecs::Methods.public_methods(false).sort.should include(:allocate, :hachi,
+ :ichi, :juu, :juu_ni, :new, :roku, :san, :shi, :superclass)
+ KernelSpecs::Methods.new.public_methods(false).sort.should include(:juu_san, :ni)
+ end
+
+ it "returns a list of the names of publicly accessible methods in the object and its ancestors and mixed-in modules" do
+ (KernelSpecs::Methods.public_methods(false) & KernelSpecs::Methods.public_methods).sort.should include(
+ :allocate, :hachi, :ichi, :juu, :juu_ni, :new, :roku, :san, :shi, :superclass)
+ m = KernelSpecs::Methods.new.public_methods
+ m.should include(:ni, :juu_san)
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/require_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/require_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/require_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -61,18 +61,81 @@
$require_spec_1.nil?.should == false
end
- it "loads a .rb from a relative path and returns true" do
- Dir.chdir($require_fixture_dir) do |dir|
- $require_spec_1 = nil
- require('../../fixtures/require/require_spec_1.rb').should == true
- $require_spec_1.nil?.should == false
+ ruby_version_is ""..."1.9" do
+ it "loads a .rb from a relative path and returns true" do
+ Dir.chdir($require_fixture_dir) do |dir|
+ $require_spec_1 = nil
+ require('../../fixtures/require/require_spec_1.rb').should == true
+ $require_spec_1.nil?.should == false
- $require_spec_1 = nil
- require('./../require/require_spec_1.rb').should == true
- $require_spec_1.nil?.should == false
+ $require_spec_1 = nil
+ require('./../require/require_spec_1.rb').should == true
+ $require_spec_1.nil?.should == false
+ end
end
end
+ ruby_version_is "1.9" do
+ it "can load .rb files from relative paths" do
+ Dir.chdir($require_fixture_dir) do |dir|
+ abs_path = File.expand_path('./../require/require_spec_1.rb')
+ $LOADED_FEATURES.delete abs_path
+ $require_spec_1 = nil
+ require('../../fixtures/require/require_spec_1.rb').should be_true
+ $require_spec_1.should_not be_nil
+ $LOADED_FEATURES.grep(/require_spec_1\.rb/).should == [abs_path]
+ end
+ end
+
+ it "collapses consecutive path separators" do
+ Dir.chdir($require_fixture_dir) do |dir|
+ abs_path = File.expand_path('./../require/require_spec_1.rb')
+ $LOADED_FEATURES.delete_if {|p| p =~ /require_spec_1\.rb$/ }
+ # Put the absolute path into $LOADED_FEATURES
+ require(abs_path).should be_true
+ path_parts = File.split(abs_path)
+ # Mangle the absolute path so it contains multiple consecutive separator
+ # characters, then require it. We've already require'd the canonical
+ # form of this path, so this should return false
+ require([
+ path_parts[0], File::Separator, path_parts[1]
+ ].join(File::Separator)).should be_false
+
+ # $LOADED_FEATURES should only contain the absolute path
+ $LOADED_FEATURES.grep(/require_spec_1\.rb/).should == [abs_path]
+ end
+ end
+
+ it "collapses '../' inside an absolute path" do
+ Dir.chdir($require_fixture_dir) do |dir|
+ abs_path = File.expand_path('./../require/require_spec_1.rb')
+ $LOADED_FEATURES.delete_if {|p| p =~ /require_spec_1\.rb$/ }
+ # Put the absolute path into $LOADED_FEATURES
+ require(abs_path).should be_true
+ # Create an absolute path (beginning at the filesystem root), containing
+ # '../', then the real absolute path.
+ #FIXME: Fix to work on Windows. :-(
+ require("/tmp/../#{abs_path}").should be_false
+
+ # $LOADED_FEATURES should only contain the absolute path
+ $LOADED_FEATURES.grep(/require_spec_1\.rb/).should == [abs_path]
+ end
+ end
+
+ it "canonicalizes relative paths" do
+ Dir.chdir($require_fixture_dir) do |dir|
+ abs_path = File.expand_path('../require/require_spec_1.rb')
+ $LOADED_FEATURES.delete_if {|p| p =~ /require_spec_1\.rb$/ }
+ # Put the absolute path into $LOADED_FEATURES
+ require(abs_path).should be_true
+ require("../require/require_spec_1.rb").should be_false
+
+ # $LOADED_FEATURES should only contain the absolute path
+ $LOADED_FEATURES.grep(/require_spec_1\.rb/).should == [abs_path]
+ end
+ end
+ end
+
it "loads an unqualified .rb by looking in $LOAD_PATH and returns true" do
require('require_spec_2.rb').should == true
$require_spec_2.nil?.should == false
@@ -91,17 +154,35 @@
$LOADED_FEATURES.size.should == num_features
end
- it "allows unqualified files to contain path information (just not in the beginning)" do
- name = (File.dirname(__FILE__) + '/../../fixtures')
- $LOAD_PATH << name
+ ruby_version_is ""..."1.9" do
+ it "allows unqualified files to contain path information (just not in the beginning)" do
+ name = (File.dirname(__FILE__) + '/../../fixtures')
+ $LOAD_PATH << name
- $require_spec2 = nil
- require('require/../require/require_spec_2.rb').should == true
- $require_spec_2.nil?.should == false
-
- $LOAD_PATH.delete name
+ $require_spec2 = nil
+ require('require/../require/require_spec_2.rb').should == true
+ $require_spec_2.nil?.should == false
+
+ $LOAD_PATH.delete name
+ end
end
+ ruby_version_is "1.9" do
+ it "allows unqualified files to contain path information (just not in the beginning)" do
+ # Forget that we've already loaded this file
+ $LOADED_FEATURES.delete File.expand_path(
+ File.join($require_fixture_dir, 'require_spec_2.rb'))
+ name = (File.dirname(__FILE__) + '/../../fixtures')
+ # Append fixtures directory to $LOAD_PATH
+ $LOAD_PATH << name
+ $require_spec2 = nil
+ # Require fixtures file using path relative to $LOAD_PATH
+ require('require/../require/require_spec_2.rb').should be_true
+ $require_spec_2.should_not be_nil
+ $LOAD_PATH.delete File.expand_path(name)
+ end
+ end
+
it "loads a file with ./filename even if . is not in path" do
Dir.chdir($require_fixture_dir) do |dir|
path_backup = $LOAD_PATH.clone
@@ -124,16 +205,33 @@
$require_spec = nil
+ # 1.9 won't re-require 'require_spec.rb' because it already appears in
+ # $LOADED_FEATURES, so we delete it first. On 1.8 this has no effect.
+ $LOADED_FEATURES.delete File.expand_path(
+ File.join($require_fixture_dir, 'require_spec.rb'))
require('require_spec')
$require_spec.should == :rb
end
- it "prefers to use .rb over .<ext> if given non-extensioned file and both exist" do
- require('require_spec_dummy').should == true
- $LOADED_FEATURES.include?('require_spec_dummy.rb').should == true
- $LOADED_FEATURES.include?("require_spec_dummy.#{Config::CONFIG['DLEXT']}").should == false
+ ruby_version_is ""..."1.9" do
+ it "prefers to use .rb over .<ext> if given non-extensioned file and both exist" do
+ require('require_spec_dummy').should == true
+ $LOADED_FEATURES.include?('require_spec_dummy.rb').should == true
+ $LOADED_FEATURES.include?("require_spec_dummy.#{Config::CONFIG['DLEXT']}").should == false
+ end
end
+ ruby_version_is "1.9" do
+ it "prefers to use .rb over .<ext> if given non-extensioned file and both exist" do
+ rb_abs_path = File.expand_path(
+ File.join($require_tmp_dir, 'require_spec_dummy.rb'))
+ ext_abs_path = rb_abs_path.sub(/\.rb$/, '.' + Config::CONFIG['DLEXT'])
+ require('require_spec_dummy').should be_true
+ $LOADED_FEATURES.include?(rb_abs_path).should be_true
+ $LOADED_FEATURES.include?(ext_abs_path).should be_false
+ end
+ end
+
runner_is_not :rspec do
it "will not add a bad load to LOADED_FEATURES" do
lambda { require('require_spec_raises') }.should raise_error(RuntimeError)
@@ -142,12 +240,24 @@
end
end
- it "will load file.rb when given 'file' if it exists even if file.<ext> is loaded" do
- $LOADED_FEATURES << "require_spec_3.#{Config::CONFIG['DLEXT']}"
- require('require_spec_3.rb').should == true
- $LOADED_FEATURES.include?('require_spec_3.rb').should == true
+ ruby_version_is ""..."1.9" do
+ it "will load file.rb when given 'file' if it exists even if file.<ext> is loaded" do
+ $LOADED_FEATURES << "require_spec_3.#{Config::CONFIG['DLEXT']}"
+ require('require_spec_3.rb').should == true
+ $LOADED_FEATURES.include?('require_spec_3.rb').should == true
+ end
end
+ ruby_version_is "1.9" do
+ it "will load file.rb when given 'file' if it exists even if file.<ext> is loaded" do
+ $LOADED_FEATURES << File.expand_path(
+ File.join($require_fixture_dir, "require_spec_3.#{Config::CONFIG['DLEXT']}"))
+ require('require_spec_3.rb').should be_true
+ $LOADED_FEATURES.include?(File.expand_path(
+ File.join($require_fixture_dir, 'require_spec_3.rb'))).should be_true
+ end
+ end
+
it "will not load file.<ext> when given 'file' if file.rb already loaded" do
unless $LOADED_FEATURES.include?('require_spec_dummy.rb')
require('require_spec_dummy.rb')
@@ -172,99 +282,232 @@
$require_spec_rooby.should == :rb
end
- it "produces __FILE__ as the given filename and __LINE__ as the source line number" do
- Dir.chdir($require_fixture_dir) do |dir|
- require('require_spec_4').should == true
- $require_spec_4.should == [['./require_spec_4.rb', 1], ['./require_spec_4.rb', 10]]
+ ruby_version_is ""..."1.9" do
+ it "produces __FILE__ as the given filename and __LINE__ as the source line number" do
+ Dir.chdir($require_fixture_dir) do |dir|
+ require('require_spec_4').should == true
+ $require_spec_4.should == [['./require_spec_4.rb', 1], ['./require_spec_4.rb', 10]]
- extended_on :rubinius do
- `rm require_spec_4.rbc`
+ extended_on :rubinius do
+ `rm require_spec_4.rbc`
+ end
end
+
+ $require_spec_4 = nil
+
+ require("#{$require_fixture_dir}/require_spec_4").should == true
+ $require_spec_4[0][0].should =~ %r[^.*/fixtures/require/require_spec_4.rb]
+ $require_spec_4[0][1].should == 1
+ $require_spec_4[1][0].should =~ %r[^.*/fixtures/require/require_spec_4.rb]
+ $require_spec_4[1][1].should == 10
end
+ end
- $require_spec_4 = nil
+ ruby_version_is "1.9" do
+ it "produces __FILE__ as the given filename and __LINE__ as the source line number" do
+ abs_path = File.expand_path(
+ File.join($require_fixture_dir, 'require_spec_4.rb'))
+ Dir.chdir($require_fixture_dir) do |dir|
+ require('require_spec_4').should be_true
+ $require_spec_4.should == [[abs_path, 1], [abs_path, 10]]
- require("#{$require_fixture_dir}/require_spec_4").should == true
- $require_spec_4[0][0].should =~ %r[^.*/fixtures/require/require_spec_4.rb]
- $require_spec_4[0][1].should == 1
- $require_spec_4[1][0].should =~ %r[^.*/fixtures/require/require_spec_4.rb]
- $require_spec_4[1][1].should == 10
+ extended_on :rubinius do
+ `rm require_spec_4.rbc`
+ end
+ end
+
+ $require_spec_4 = nil
+ $LOADED_FEATURES.delete abs_path
+ require('require_spec_4').should be_true
+ $require_spec_4[0][0].should =~ %r[^.*/fixtures/require/require_spec_4.rb]
+ $require_spec_4[0][1].should == 1
+ $require_spec_4[1][0].should =~ %r[^.*/fixtures/require/require_spec_4.rb]
+ $require_spec_4[1][1].should == 10
+ end
end
- it "stores the loaded file in $LOADED_FEATURES" do
- $LOADED_FEATURES.include?('require_spec_6.rb').should == false
- require('require_spec_6.rb').should == true
- $LOADED_FEATURES.include?('require_spec_6.rb').should == true
+ ruby_version_is ""..."1.9" do
+ it "stores the loaded file in $LOADED_FEATURES" do
+ $LOADED_FEATURES.include?('require_spec_6.rb').should == false
+ require('require_spec_6.rb').should == true
+ $LOADED_FEATURES.include?('require_spec_6.rb').should == true
+ end
end
- it "stores a non-extensioned file with its located suffix" do
- $LOADED_FEATURES.delete 'require_spec_6.rb'
+ ruby_version_is "1.9" do
+ it "stores the loaded file in $LOADED_FEATURES" do
+ abs_path = File.expand_path(
+ File.join($require_fixture_dir, 'require_spec_6.rb'))
+ $LOADED_FEATURES.include?(abs_path).should be_false
+ require('require_spec_6.rb').should be_true
+ $LOADED_FEATURES.include?(abs_path).should be_true
+ end
+ end
- require('require_spec_6').should == true
+ ruby_version_is ""..."1.9" do
+ it "stores a non-extensioned file with its located suffix" do
+ $LOADED_FEATURES.delete 'require_spec_6.rb'
- $LOADED_FEATURES.include?('require_spec_6.rb').should == true
+ require('require_spec_6').should == true
+
+ $LOADED_FEATURES.include?('require_spec_6.rb').should == true
+ end
end
- it "bases the filename in $LOADED_FEATURES on the path given, not just basename" do
- $LOADED_FEATURES.include?('require_spec_6.rb').should == true
+ ruby_version_is "1.9" do
+ it "stores a non-extensioned file with its located suffix" do
+ abs_path = File.expand_path(
+ File.join($require_fixture_dir, 'require_spec_6.rb'))
+ $LOADED_FEATURES.delete abs_path
- Dir.chdir($require_fixture_dir) do |dir|
- require('../../fixtures/require/require_spec_6.rb').should == true
+ require('require_spec_6').should be_true
+
+ $LOADED_FEATURES.include?(abs_path).should be_true
end
+ end
- $LOADED_FEATURES.include?('require_spec_6.rb').should == true
- $LOADED_FEATURES.include?('../../fixtures/require/require_spec_6.rb').should == true
+ # The 1.9 version of this test is described in it "normalises .rb paths
+ # before storing them in $LOADED_FEATURES"
+ ruby_version_is ""..."1.9" do
+ it "bases the filename in $LOADED_FEATURES on the path given, not just basename" do
+ $LOADED_FEATURES.include?('require_spec_6.rb').should == true
+
+ Dir.chdir($require_fixture_dir) do |dir|
+ require('../../fixtures/require/require_spec_6.rb').should == true
+ end
+
+ $LOADED_FEATURES.include?('require_spec_6.rb').should == true
+ $LOADED_FEATURES.include?('../../fixtures/require/require_spec_6.rb').should == true
+ end
end
- it "will not load the same file twice, returns false instead" do
- $LOADED_FEATURES.include?('require_spec_7.rb').should == false
+ ruby_version_is ""..."1.9" do
+ it "will not load the same file twice, returns false instead" do
+ $LOADED_FEATURES.include?('require_spec_7.rb').should == false
- require('require_spec_7.rb').should == true
- a = $require_spec_7
- a.nil?.should == false
-
- $LOADED_FEATURES.include?('require_spec_7.rb').should == true
+ require('require_spec_7.rb').should == true
+ a = $require_spec_7
+ a.nil?.should == false
+
+ $LOADED_FEATURES.include?('require_spec_7.rb').should == true
- require('require_spec_7.rb').should == false
- b = $require_spec_7
- b.nil?.should == false
+ require('require_spec_7.rb').should == false
+ b = $require_spec_7
+ b.nil?.should == false
- # Timestamps should not differ
- a.should eql(b)
+ # Timestamps should not differ
+ a.should eql(b)
- $LOADED_FEATURES.include?('require_spec_7.rb').should == true
+ $LOADED_FEATURES.include?('require_spec_7.rb').should == true
+ end
end
- it "checks $LOADED_FEATURES to see whether file is already loaded" do
- $LOADED_FEATURES.include?('require_spec_7.rb').should == true
- require('require_spec_7.rb').should == false
+ ruby_version_is "1.9" do
+ it "will not load the same file twice, returns false instead" do
+ abs_path = File.expand_path(
+ File.join($require_fixture_dir, 'require_spec_7.rb'))
+ $LOADED_FEATURES.include?(abs_path).should be_false
- $LOADED_FEATURES.delete 'require_spec_7.rb'
- require('require_spec_7.rb').should == true
- require('require_spec_7.rb').should == false
+ require('require_spec_7.rb').should be_true
+ a = $require_spec_7
+ a.should_not be_nil
+
+ $LOADED_FEATURES.include?(abs_path).should be_true
- $LOADED_FEATURES.include?('require_spec_7.rb').should == true
+ require('require_spec_7.rb').should be_false
+ b = $require_spec_7
+ b.should_not be_nil
+
+ # Timestamps should not differ
+ a.should eql(b)
+
+ $LOADED_FEATURES.include?(abs_path).should be_true
+ end
end
+
+ ruby_version_is ""..."1.9" do
+ it "checks $LOADED_FEATURES to see whether file is already loaded" do
+ $LOADED_FEATURES.include?('require_spec_7.rb').should == true
+ require('require_spec_7.rb').should == false
+
+ $LOADED_FEATURES.delete 'require_spec_7.rb'
+ require('require_spec_7.rb').should == true
+ require('require_spec_7.rb').should == false
+
+ $LOADED_FEATURES.include?('require_spec_7.rb').should == true
+ end
+ end
+ ruby_version_is "1.9" do
+ it "checks $LOADED_FEATURES to see whether file is already loaded" do
+ abs_path = File.expand_path(
+ File.join($require_fixture_dir, 'require_spec_7.rb'))
+ $LOADED_FEATURES.include?(abs_path).should be_true
+ require('require_spec_7.rb').should be_false
+
+ $LOADED_FEATURES.delete abs_path
+ require('require_spec_7.rb').should be_true
+ require('require_spec_7.rb').should be_false
+
+ $LOADED_FEATURES.include?(abs_path).should be_true
+ end
+ end
+
it "raises a LoadError if the file can't be found" do
lambda { require "nonesuch#{$$}#{Time.now.to_f}" }.should raise_error LoadError
end
- it "only accepts strings" do
- lambda { require(nil) }.should raise_error(TypeError)
- lambda { require(42) }.should raise_error(TypeError)
- lambda { require([]) }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "only accepts strings" do
+ lambda { require(nil) }.should raise_error(TypeError)
+ lambda { require(42) }.should raise_error(TypeError)
+ lambda { require([]) }.should raise_error(TypeError)
+ end
end
- it "does not infinite loop on an rb file that requires itself" do
- $require_spec_recursive = nil
- $LOADED_FEATURES.delete 'require_spec_recursive.rb'
+ ruby_version_is "1.9" do
+ it "only accepts strings or objects with #to_path" do
+ lambda { require(nil) }.should raise_error(TypeError)
+ lambda { require(42) }.should raise_error(TypeError)
+ lambda { require([]) }.should raise_error(TypeError)
+ end
+ end
- $LOADED_FEATURES.include?('require_spec_recursive.rb').should == false
- require('require_spec_recursive').should == true
- $LOADED_FEATURES.include?('require_spec_recursive.rb').should == true
- $require_spec_recursive.nil?.should == false
+ ruby_version_is ""..."1.9" do
+ it "does not infinite loop on an rb file that requires itself" do
+ $require_spec_recursive = nil
+ $LOADED_FEATURES.delete 'require_spec_recursive.rb'
+
+ $LOADED_FEATURES.include?('require_spec_recursive.rb').should == false
+ require('require_spec_recursive').should == true
+ $LOADED_FEATURES.include?('require_spec_recursive.rb').should == true
+ $require_spec_recursive.nil?.should == false
+ end
end
+
+ ruby_version_is "1.9" do
+ it "does not infinite loop on an rb file that requires itself" do
+ abs_path = File.expand_path(
+ File.join($require_fixture_dir, 'require_spec_recursive.rb'))
+ $require_spec_recursive = nil
+ $LOADED_FEATURES.delete abs_path
+
+ $LOADED_FEATURES.include?(abs_path).should be_false
+ require('require_spec_recursive').should be_true
+ $LOADED_FEATURES.include?(abs_path).should be_true
+ $require_spec_recursive.should_not be_nil
+ end
+
+ it "calls #to_path on non-String arguments" do
+ abs_path = File.expand_path(
+ File.join($require_fixture_dir, 'require_spec.rb'))
+ path = mock('path')
+ path.should_receive(:to_path).and_return('require_spec.rb')
+ $LOADED_FEATURES.delete abs_path
+ require(path).should be_true
+ $LOADED_FEATURES.include?(abs_path).should be_true
+ end
+ end
end
describe "Shell expansion in Kernel#require" do
@@ -273,6 +516,7 @@
ENV["HOME"] = $require_fixture_dir
@rs_short = "~/require_spec_1.rb"
@rs_long = "#{$require_fixture_dir}/require_spec_1.rb"
+ @rs_abs = File.expand_path(@rs_long)
end
after :all do
@@ -280,8 +524,9 @@
end
before :each do
- $LOADED_FEATURES.delete @rs_long
- $LOADED_FEATURES.delete @rs_short
+ [@rs_long, @rs_short, @rs_abs].each do |path|
+ $LOADED_FEATURES.delete path
+ end
end
it "expands a preceding ~/ to the user's home directory for building the path to search" do
@@ -295,7 +540,9 @@
require(@rs_short).should == true
$require_spec_1.nil?.should == false
- $LOADED_FEATURES.find {|f| f == @rs_short || f == @rs_long }.nil?.should == false
+ $LOADED_FEATURES.find {|f|
+ f == @rs_short || f == @rs_long || f == @rs_abs
+ }.nil?.should == false
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/scan_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/scan_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/scan_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,12 +1,14 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/fixtures/classes'
-describe "Kernel#scan" do
- it "is a private method" do
- Kernel.should have_private_instance_method(:scan)
+ruby_version_is ""..."1.9" do
+ describe "Kernel#scan" do
+ it "is a private method" do
+ Kernel.should have_private_instance_method(:scan)
+ end
end
-end
-describe "Kernel.scan" do
- it "needs to be reviewed for spec completeness"
+ describe "Kernel.scan" do
+ it "needs to be reviewed for spec completeness"
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/singleton_method_added_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/singleton_method_added_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/singleton_method_added_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,8 +1,9 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/../../shared/kernel/singleton_method_added'
-describe "Kernel#singleton_method_added" do
- it "is a private method" do
- Kernel.should have_private_instance_method(:singleton_method_added)
+ruby_version_is ""..."1.9" do
+ describe "Kernel#singleton_method_added" do
+ it_behaves_like(:singleton_method_added, :singleton_method_added, Kernel)
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/singleton_method_removed_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/singleton_method_removed_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/singleton_method_removed_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,8 +1,8 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/../../shared/kernel/singleton_method_removed'
-describe "Kernel#singleton_method_removed" do
- it "is a private method" do
- Kernel.should have_private_instance_method(:singleton_method_removed)
+ruby_version_is ""..."1.9" do
+ describe "Kernel#singleton_method_removed" do
+ it_behaves_like(:singleton_method_removed, :singleton_method_removed, Kernel)
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/singleton_method_undefined_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/singleton_method_undefined_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/singleton_method_undefined_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,8 +1,7 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/../../shared/kernel/singleton_method_undefined'
-describe "Kernel#singleton_method_undefined" do
- it "is a private method" do
- Kernel.should have_private_instance_method(:singleton_method_undefined)
+ruby_version_is ""..."1.9" do
+ describe "Kernel#singleton_method_undefined" do
+ it_behaves_like(:singleton_method_undefined, :singleton_method_undefined, Kernel)
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/split_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/split_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/split_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,12 +1,14 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/fixtures/classes'
-describe "Kernel#split" do
- it "is a private method" do
- Kernel.should have_private_instance_method(:split)
+ruby_version_is ""..."1.9" do
+ describe "Kernel#split" do
+ it "is a private method" do
+ Kernel.should have_private_instance_method(:split)
+ end
end
-end
-describe "Kernel.split" do
- it "needs to be reviewed for spec completeness"
+ describe "Kernel.split" do
+ it "needs to be reviewed for spec completeness"
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/sub_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/sub_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/sub_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,22 +1,26 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/fixtures/classes'
-describe "Kernel#sub" do
- it "is a private method" do
- Kernel.should have_private_instance_method(:sub)
+# FIXME: These methods exist on 1.9 only when the -n or -p option is passed to
+# ruby, but we currently don't have a way of specifying that.
+ruby_version_is ""..."1.9" do
+ describe "Kernel#sub" do
+ it "is a private method" do
+ Kernel.should have_private_instance_method(:sub)
+ end
end
-end
-describe "Kernel#sub!" do
- it "is a private method" do
- Kernel.should have_private_instance_method(:sub!)
+ describe "Kernel#sub!" do
+ it "is a private method" do
+ Kernel.should have_private_instance_method(:sub!)
+ end
end
-end
-describe "Kernel.sub" do
- it "needs to be reviewed for spec completeness"
-end
+ describe "Kernel.sub" do
+ it "needs to be reviewed for spec completeness"
+ end
-describe "Kernel.sub!" do
- it "needs to be reviewed for spec completeness"
-end
+ describe "Kernel.sub!" do
+ it "needs to be reviewed for spec completeness"
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/system_spec_disabled.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/system_spec_disabled.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/system_spec_disabled.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -16,11 +16,25 @@
end
end
- it "returns false when it can't" do
- result = system("sad")
- result.should == false
+ ruby_version_is ""..."1.9" do
+ it "returns false when command execution fails" do
+ result = system("sad")
+ result.should == false
+ end
end
+ ruby_version_is "1.9" do
+ it "returns nil when command execution fails" do
+ result = system("sad")
+ result.should be_nil
+ end
+ end
+
+ it "returns false when the command has a non-zero exit status" do
+ result = system("#{RUBY_EXE} -e 'exit(1)'")
+ result.should be_false
+ end
+
it "does not write to stderr when it can't find a command" do
system("sad").should output_to_fd("") # nothing in stderr
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/throw_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/throw_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/throw_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -41,24 +41,17 @@
res.should == :return_value
end
- it "raises NameError if there is no catch block for the symbol" do
- proc {
- throw :blah
- }.should raise_error(NameError) { |error|
- # TODO:
- # See: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/17629
- #
- # The ruby docs are not clear whether NameError#name should
- # retrun String or Symbol. Well, the docs state the *String*
- # should be returned, but the actual MRI behavior is to return Symbol.
- # And in MRI 1.9, even different Exception raised altogether.
+ ruby_version_is ""..."1.9" do
+ it "raises a NameError if there is no catch block for the symbol" do
+ lambda { throw :blah }.should raise_error(NameError)
+ end
+ end
- # So, instead of checking that error.name == :blah, we perform
- # more generic test, suitable for different implementations
- # (like JRuby, since JRuby follows the ruby-doc, and returns String).
- error.name.to_s.should == "blah"
- }
- end
+ ruby_version_is "1.9" do
+ it "raises an ArgumentError if there is no catch block for the symbol" do
+ lambda { throw :blah }.should raise_error(ArgumentError)
+ end
+ end
it "raises ArgumentError if 3 or more arguments provided" do
lambda {
@@ -74,14 +67,26 @@
}.should raise_error(ArgumentError)
end
- it "raises TypeError if the first argument is not a symbol" do
- lambda {
- catch :blah do
- throw Object.new
- end
- }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises TypeError if the first argument is not a symbol" do
+ lambda {
+ catch :blah do
+ throw Object.new
+ end
+ }.should raise_error(TypeError)
+ end
end
+ ruby_version_is "1.9" do
+ it "can throw an object" do
+ lambda {
+ obj = Object.new
+ catch obj do
+ throw obj
+ end
+ }.should_not raise_error(NameError)
+ end
+ end
end
describe "Kernel#throw" do
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/to_a_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/to_a_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/to_a_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,22 +1,24 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/fixtures/classes'
-describe "Kernel#to_a" do
- it "is defined on Kernel" do
- Kernel.should have_instance_method('to_a')
+ruby_version_is ""..."1.9" do
+ describe "Kernel#to_a" do
+ it "is defined on Kernel" do
+ Kernel.should have_instance_method('to_a')
+ end
end
-end
-describe "Kernel#to_a when the receiver is an Array" do
- it "returns self" do
- array = [1, 2]
- array.to_a.should equal(array)
+ describe "Kernel#to_a when the receiver is an Array" do
+ it "returns self" do
+ array = [1, 2]
+ array.to_a.should equal(array)
+ end
end
-end
-describe "Kernel#to_a when the receiver is not an Array" do
- it "returns an Array containing self" do
- object = "I am not an array"
- object.to_a.should == [object]
+ describe "Kernel#to_a when the receiver is not an Array" do
+ it "returns an Array containing self" do
+ object = "I am not an array"
+ object.to_a.should == [object]
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/matchdata/select_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/matchdata/select_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/matchdata/select_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,7 +1,9 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-describe "MatchData#select" do
- it "yields the contents of the match array to a block" do
- /(.)(.)(\d+)(\d)/.match("THX1138: The Movie").select { |x| x }.should == ["HX1138", "H", "X", "113", "8"]
+ruby_version_is ""..."1.9" do
+ describe "MatchData#select" do
+ it "yields the contents of the match array to a block" do
+ /(.)(.)(\d+)(\d)/.match("THX1138: The Movie").select { |x| x }.should == ["HX1138", "H", "X", "113", "8"]
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/acos_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/acos_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/acos_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -30,10 +30,18 @@
end
end
- it "raises an ArgumentError if the string argument cannot be coerced with Float()" do
- lambda { Math.acos("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the string argument cannot be coerced with Float()" do
+ lambda { Math.acos("test") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the string argument cannot be coerced with Float()" do
+ lambda { Math.acos("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises an TypeError if the argument cannot be coerced with Float()" do
lambda { Math.acos(MathSpecs::UserClass.new) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/acosh_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/acosh_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/acosh_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -19,10 +19,18 @@
end
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.acosh("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.acosh("test") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.acosh("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.acosh(nil) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/asin_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/asin_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/asin_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -26,10 +26,18 @@
end
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.asin("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.asin("test") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.asin("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.asin(nil) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/asinh_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/asinh_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/asinh_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -18,10 +18,18 @@
#Math.asinh(-94906265.62).should be_close(-19.0615, TOLERANCE)
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.asinh("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.asinh("test") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.asinh("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.asinh(nil) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/atan2_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/atan2_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/atan2_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -13,12 +13,22 @@
Math.atan2(7.22, -3.3).should be_close(1.99950888779256, TOLERANCE)
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.atan2(1.0, "test") }.should raise_error(ArgumentError)
- lambda { Math.atan2("test", 0.0) }.should raise_error(ArgumentError)
- lambda { Math.atan2("test", "this") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.atan2(1.0, "test") }.should raise_error(ArgumentError)
+ lambda { Math.atan2("test", 0.0) }.should raise_error(ArgumentError)
+ lambda { Math.atan2("test", "this") }.should raise_error(ArgumentError)
+ end
end
-
+
+ ruby_version_is "1.9" do
+ it "raises an TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.atan2(1.0, "test") }.should raise_error(TypeError)
+ lambda { Math.atan2("test", 0.0) }.should raise_error(TypeError)
+ lambda { Math.atan2("test", "this") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.atan2(nil, 1.0) }.should raise_error(TypeError)
lambda { Math.atan2(-1.0, nil) }.should raise_error(TypeError)
Modified: MacRuby/branches/experimental/spec/frozen/core/math/atan_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/atan_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/atan_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -16,10 +16,18 @@
Math.atan(0.75).should be_close(0.643501108793284, TOLERANCE)
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.atan("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.atan("test") }.should raise_error(ArgumentError)
+ end
end
-
+
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.atan("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.atan(nil) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/atanh_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/atanh_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/atanh_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -46,10 +46,18 @@
end
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.atanh("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.atanh("test") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.atanh("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.atanh(nil) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/cos_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/cos_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/cos_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -14,17 +14,28 @@
Math.cos(3*Math::PI/2).should be_close(0.0, TOLERANCE)
Math.cos(2*Math::PI).should be_close(1.0, TOLERANCE)
end
+
+
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.cos("test") }.should raise_error(ArgumentError)
+ end
+ end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.cos("test") }.should raise_error(ArgumentError)
+ ruby_version_is "1.9" do
+ it "raises a TypeError unless the argument is Numeric and has #to_f" do
+ lambda { Math.cos("test") }.should raise_error(TypeError)
+ end
end
-
+
it "raises a TypeError if the argument is nil" do
lambda { Math.cos(nil) }.should raise_error(TypeError)
end
- it "accepts any argument that can be coerced with Float()" do
- Math.cos(MathSpecs::Float.new).should be_close(0.54030230586814, TOLERANCE)
+ it "coerces its argument with #to_f" do
+ f = mock_numeric('8.2')
+ f.should_receive(:to_f).and_return(8.2)
+ Math.cos(f).should == Math.cos(8.2)
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/cosh_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/cosh_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/cosh_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -13,10 +13,18 @@
Math.cosh(-2.99).should be_close(9.96798496414416, TOLERANCE)
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.cosh("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.cosh("test") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.cosh("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.cosh(nil) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/erf_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/erf_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/erf_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -20,10 +20,18 @@
Math.erf(-0.00000000000001).should be_close(0.0, TOLERANCE)
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.erf("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.erf("test") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.erf("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.erf(nil) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/erfc_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/erfc_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/erfc_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -19,10 +19,18 @@
Math.erfc(-0.00000000000001).should be_close(1.00000000000001, TOLERANCE)
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.erfc("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.erfc("test") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.erfc("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.erfc(nil) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/exp_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/exp_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/exp_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -13,10 +13,18 @@
Math.exp(1.25).should be_close(3.49034295746184, TOLERANCE)
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.exp("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.exp("test") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.exp("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.exp(nil) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/fixtures/classes.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/fixtures/classes.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/fixtures/classes.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -3,7 +3,7 @@
end
module MathSpecs
- class Float
+ class Float < Numeric
def initialize(value=1.0)
@value = value
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/frexp_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/frexp_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/frexp_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -8,10 +8,18 @@
exp.should == 7
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.frexp("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.frexp("test") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.frexp("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.frexp(nil) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/hypot_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/hypot_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/hypot_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -15,10 +15,18 @@
Math.hypot(2, 10).should be_close(10.1980390271856, TOLERANCE)
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.hypot("test", "this") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.hypot("test", "this") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.hypot("test", "this") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a ArgumentError if the argument is nil" do
lambda { Math.hypot(nil) }.should raise_error(ArgumentError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/ldexp_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/ldexp_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/ldexp_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -14,10 +14,18 @@
Math.ldexp(5.7, 4).should be_close(91.2, TOLERANCE)
end
- it "raises an ArgumentError if the first argument cannot be coerced with Float()" do
- lambda { Math.ldexp("test", 2) }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the first argument cannot be coerced with Float()" do
+ lambda { Math.ldexp("test", 2) }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the first argument cannot be coerced with Float()" do
+ lambda { Math.ldexp("test", 2) }.should raise_error(TypeError)
+ end
+ end
+
it "raises an TypeError if the second argument cannot be coerced with Integer()" do
lambda { Math.ldexp(3.2, "this") }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/log10_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/log10_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/log10_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -21,10 +21,18 @@
end
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.log10("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.log10("test") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.log10("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.log10(nil) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/log_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/log_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/log_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -21,10 +21,18 @@
end
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.log("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.log("test") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.log("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.log(nil) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/sin_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/sin_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/sin_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -15,10 +15,18 @@
Math.sin(2*Math::PI).should be_close(0.0, TOLERANCE)
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.sin("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.sin("test") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.sin("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.sin(nil) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/sinh_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/sinh_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/sinh_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -13,10 +13,18 @@
Math.sinh(-2.8).should be_close(-8.19191835423591, TOLERANCE)
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.sinh("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.sinh("test") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.sinh("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.sinh(nil) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/sqrt_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/sqrt_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/sqrt_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -9,13 +9,21 @@
it "returns the square root of the argument" do
Math.sqrt(1).should == 1.0
Math.sqrt(4.0).should == 2.0
- Math.sqrt(15241578780673814.441547445).to_s.should == '123456789.123457'
+ Math.sqrt(15241578780673814.441547445).should be_close(123456789.123457, TOLERANCE)
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.sqrt("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.sqrt("test") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.sqrt("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.sqrt(nil) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/tan_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/tan_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/tan_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -18,10 +18,18 @@
Math.tan(1.0/-0.0).nan?.should == true
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.tan("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.tan("test") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.tan("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.tan(nil) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/math/tanh_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/math/tanh_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/math/tanh_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -15,10 +15,18 @@
Math.tanh(-4.892).should be_close(-0.999887314427707, TOLERANCE)
end
- it "raises an ArgumentError if the argument cannot be coerced with Float()" do
- lambda { Math.tanh("test") }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if the argument cannot be coerced with Float()" do
+ lambda { Math.tanh("test") }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises an TypeError if the argument cannot be coerced with Float()" do
+ lambda { Math.tanh("test") }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the argument is nil" do
lambda { Math.tanh(nil) }.should raise_error(TypeError)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/module/attr_writer_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/attr_writer_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/module/attr_writer_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -24,18 +24,20 @@
o.instance_variable_get(:@test2).should == "test_2 updated"
end
- not_compliant_on :rubinius do
- it "creates a setter for an attribute name given as a Fixnum" do
- c = Class.new do
- attr_writer :test1.to_i
- end
+ ruby_version_is ""..."1.9" do
+ not_compliant_on :rubinius do
+ it "creates a setter for an attribute name given as a Fixnum" do
+ c = Class.new do
+ attr_writer :test1.to_i
+ end
- o = c.new
- o.respond_to?("test1").should == false
- o.respond_to?("test1=").should == true
+ o = c.new
+ o.respond_to?("test1").should == false
+ o.respond_to?("test1=").should == true
- o.test1 = "test_1"
- o.instance_variable_get(:@test1).should == "test_1"
+ o.test1 = "test_1"
+ o.instance_variable_get(:@test1).should == "test_1"
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/module/autoload_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/autoload_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/module/autoload_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -256,13 +256,30 @@
end.should raise_error(TypeError)
end
- it "raises a TypeError if not passed a String for the filename" do
- name = mock("autoload_name.rb")
- name.stub!(:to_s).and_return("autoload_name.rb")
- name.stub!(:to_str).and_return("autoload_name.rb")
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if not passed a String for the filename" do
+ name = mock("autoload_name.rb")
+ name.stub!(:to_s).and_return("autoload_name.rb")
+ name.stub!(:to_str).and_return("autoload_name.rb")
- lambda { ModuleSpecs::Autoload.autoload :Str, name }.should raise_error(TypeError)
+ lambda { ModuleSpecs::Autoload.autoload :Str, name }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a TypeError if not passed a String or object respodning to #to_path for the filename" do
+ name = mock("autoload_name.rb")
+
+ lambda { ModuleSpecs::Autoload.autoload :Str, name }.should raise_error(TypeError)
+ end
+
+ it "calls #to_path on non-String filename arguments" do
+ name = mock("autoload_name.rb")
+ name.should_receive(:to_path).and_return("autoload_name.rb")
+
+ lambda { ModuleSpecs::Autoload.autoload :Str, name }.should_not raise_error
+ end
+ end
end
describe "Module#autoload" do
Modified: MacRuby/branches/experimental/spec/frozen/core/module/class_variable_defined_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/class_variable_defined_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/module/class_variable_defined_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -26,11 +26,13 @@
c.class_variable_defined?("@@mvar").should == false
end
- not_compliant_on :rubinius do
- it "accepts Fixnums for class variables" do
- c = Class.new { class_variable_set :@@class_var, "test" }
- c.class_variable_defined?(:@@class_var.to_i).should == true
- c.class_variable_defined?(:@@no_class_var.to_i).should == false
+ ruby_version_is ""..."1.9" do
+ not_compliant_on :rubinius do
+ it "accepts Fixnums for class variables" do
+ c = Class.new { class_variable_set :@@class_var, "test" }
+ c.class_variable_defined?(:@@class_var.to_i).should == true
+ c.class_variable_defined?(:@@no_class_var.to_i).should == false
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/module/class_variable_get_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/class_variable_get_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/module/class_variable_get_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -33,17 +33,19 @@
ModuleSpecs::CVars.new.meta.should == :meta
end
- not_compliant_on :rubinius do
- it "accepts Fixnums for class variables" do
- c = Class.new { class_variable_set :@@class_var, "test" }
- c.send(:class_variable_get, :@@class_var.to_i).should == "test"
- end
+ ruby_version_is ""..."1.9" do
+ not_compliant_on :rubinius do
+ it "accepts Fixnums for class variables" do
+ c = Class.new { class_variable_set :@@class_var, "test" }
+ c.send(:class_variable_get, :@@class_var.to_i).should == "test"
+ end
- it "raises a NameError when a Fixnum for an uninitialized class variable is given" do
- c = Class.new
- lambda {
- c.send :class_variable_get, :@@no_class_var.to_i
- }.should raise_error(NameError)
+ it "raises a NameError when a Fixnum for an uninitialized class variable is given" do
+ c = Class.new
+ lambda {
+ c.send :class_variable_get, :@@no_class_var.to_i
+ }.should raise_error(NameError)
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/module/class_variable_set_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/class_variable_set_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/module/class_variable_set_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -18,23 +18,38 @@
c.send(:class_variable_get, "@@mvar").should == :new_mvar
end
- not_compliant_on :rubinius do
- it "accepts Fixnums for class variables" do
- c = Class.new
- c.send(:class_variable_set, :@@test2.to_i, "test2")
- c.send(:class_variable_get, :@@test2).should == "test2"
+ ruby_version_is ""..."1.9" do
+ not_compliant_on :rubinius do
+ it "accepts Fixnums for class variables" do
+ c = Class.new
+ c.send(:class_variable_set, :@@test2.to_i, "test2")
+ c.send(:class_variable_get, :@@test2).should == "test2"
+ end
end
end
- it "raises a TypeError when self is frozen" do
- lambda {
- Class.new.freeze.send(:class_variable_set, :@@test, "test")
- }.should raise_error(TypeError)
- lambda {
- Module.new.freeze.send(:class_variable_set, :@@test, "test")
- }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError when self is frozen" do
+ lambda {
+ Class.new.freeze.send(:class_variable_set, :@@test, "test")
+ }.should raise_error(TypeError)
+ lambda {
+ Module.new.freeze.send(:class_variable_set, :@@test, "test")
+ }.should raise_error(TypeError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError when self is frozen" do
+ lambda {
+ Class.new.freeze.send(:class_variable_set, :@@test, "test")
+ }.should raise_error(RuntimeError)
+ lambda {
+ Module.new.freeze.send(:class_variable_set, :@@test, "test")
+ }.should raise_error(RuntimeError)
+ end
+ end
+
it "raises a NameError when the given name is not allowed" do
c = Class.new
Modified: MacRuby/branches/experimental/spec/frozen/core/module/class_variables_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/class_variables_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/module/class_variables_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -2,24 +2,43 @@
require File.dirname(__FILE__) + '/fixtures/classes'
describe "Module#class_variables" do
- it "returns an Array with the names of class variables of self and self's ancestors" do
- ModuleSpecs::ClassVars::A.class_variables.should include("@@a_cvar")
- ModuleSpecs::ClassVars::M.class_variables.should include("@@m_cvar")
- ModuleSpecs::ClassVars::B.class_variables.should include("@@a_cvar", "@@b_cvar", "@@m_cvar")
- end
+ ruby_version_is ""..."1.9" do
+ it "returns an Array with the names of class variables of self and self's ancestors" do
+ ModuleSpecs::ClassVars::A.class_variables.should include("@@a_cvar")
+ ModuleSpecs::ClassVars::M.class_variables.should include("@@m_cvar")
+ ModuleSpecs::ClassVars::B.class_variables.should include("@@a_cvar", "@@b_cvar", "@@m_cvar")
+ end
- it "returns an Array with names of class variables defined in metaclasses" do
- ModuleSpecs::CVars.class_variables.should include("@@cls", "@@meta")
- end
+ it "returns an Array with names of class variables defined in metaclasses" do
+ ModuleSpecs::CVars.class_variables.should include("@@cls", "@@meta")
+ end
- it "returns an Array with names of class variables defined in included modules" do
- c = Class.new { include ModuleSpecs::MVars }
- c.class_variables.should include("@@mvar")
+ it "returns an Array with names of class variables defined in included modules" do
+ c = Class.new { include ModuleSpecs::MVars }
+ c.class_variables.should include("@@mvar")
+ end
+
+ it "does not return class variables defined in extended modules" do
+ c = Class.new
+ c.extend ModuleSpecs::MVars
+ c.class_variables.should_not include("@@mvar")
+ end
end
- it "does not return class variables defined in extended modules" do
- c = Class.new
- c.extend ModuleSpecs::MVars
- c.class_variables.should_not include("@@mvar")
+ ruby_version_is "1.9" do
+ it "returns an Array with the names of class variables of self" do
+ ModuleSpecs::ClassVars::A.class_variables.should include(:@@a_cvar)
+ ModuleSpecs::ClassVars::M.class_variables.should include(:@@m_cvar)
+ end
+
+ it "returns an Array with names of class variables defined in metaclasses" do
+ ModuleSpecs::CVars.class_variables.should include(:@@cls, :@@meta)
+ end
+
+ it "does not return class variables defined in extended modules" do
+ c = Class.new
+ c.extend ModuleSpecs::MVars
+ c.class_variables.should_not include(:@@mvar)
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/module/extended_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/extended_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/module/extended_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -38,7 +38,15 @@
end
end
- it "is private in its default implementation" do
- Module.new.private_methods.should include("extended")
+ ruby_version_is ""..."1.9" do
+ it "is private in its default implementation" do
+ Module.new.private_methods.should include("extended")
+ end
end
+
+ ruby_version_is "1.9" do
+ it "is private in its default implementation" do
+ Module.new.private_methods.should include(:extended)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/module/freeze_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/freeze_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/module/freeze_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -2,19 +2,39 @@
require File.dirname(__FILE__) + '/fixtures/classes'
describe "Module#freeze" do
- it "prevents further modifications to self" do
- m = Module.new.freeze
- m.frozen?.should == true
+ ruby_version_is ""..."1.9" do
+ it "prevents further modifications to self" do
+ m = Module.new.freeze
+ m.frozen?.should == true
- # Does not raise
- class << m; end
+ # Does not raise
+ class << m; end
- lambda {
- class << m
- def test() "test" end
- end
- }.should raise_error(TypeError)
+ lambda {
+ class << m
+ def test() "test" end
+ end
+ }.should raise_error(TypeError)
- lambda { def m.test() "test" end }.should raise_error(TypeError)
+ lambda { def m.test() "test" end }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "prevents further modifications to self" do
+ m = Module.new.freeze
+ m.frozen?.should == true
+
+ # Does not raise
+ class << m; end
+
+ lambda {
+ class << m
+ def test() "test" end
+ end
+ }.should raise_error(RuntimeError)
+
+ lambda { def m.test() "test" end }.should raise_error(RuntimeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/module/include_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/include_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/module/include_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -43,37 +43,69 @@
lambda { ModuleSpecs::SubclassSpec.send(:include, ModuleSpecs::Subclass.new) }.should_not raise_error(TypeError)
end
- it "imports constants to modules and classes" do
- ModuleSpecs::A.constants.should include("CONSTANT_A")
- ModuleSpecs::B.constants.should include("CONSTANT_A","CONSTANT_B")
- ModuleSpecs::C.constants.should include("CONSTANT_A","CONSTANT_B")
+ ruby_version_is ""..."1.9" do
+ it "imports constants to modules and classes" do
+ ModuleSpecs::A.constants.should include("CONSTANT_A")
+ ModuleSpecs::B.constants.should include("CONSTANT_A","CONSTANT_B")
+ ModuleSpecs::C.constants.should include("CONSTANT_A","CONSTANT_B")
+ end
end
+ ruby_version_is "1.9" do
+ it "imports constants to modules and classes" do
+ ModuleSpecs::A.constants.should include(:CONSTANT_A)
+ ModuleSpecs::B.constants.should include(:CONSTANT_A, :CONSTANT_B)
+ ModuleSpecs::C.constants.should include(:CONSTANT_A, :CONSTANT_B)
+ end
+ end
+
it "does not override existing constants in modules and classes" do
ModuleSpecs::A::OVERRIDE.should == :a
ModuleSpecs::B::OVERRIDE.should == :b
ModuleSpecs::C::OVERRIDE.should == :c
end
- it "imports instance methods to modules and classes" do
- ModuleSpecs::A.instance_methods.should include("ma")
- ModuleSpecs::B.instance_methods.should include("ma","mb")
- ModuleSpecs::C.instance_methods.should include("ma","mb")
+ ruby_version_is ""..."1.9" do
+ it "imports instance methods to modules and classes" do
+ ModuleSpecs::A.instance_methods.should include("ma")
+ ModuleSpecs::B.instance_methods.should include("ma","mb")
+ ModuleSpecs::C.instance_methods.should include("ma","mb")
+ end
end
+ ruby_version_is "1.9" do
+ it "imports instance methods to modules and classes" do
+ ModuleSpecs::A.instance_methods.should include(:ma)
+ ModuleSpecs::B.instance_methods.should include(:ma,:mb)
+ ModuleSpecs::C.instance_methods.should include(:ma,:mb)
+ end
+ end
+
it "imports constants to the toplevel" do
eval "include ModuleSpecs::Z", TOPLEVEL_BINDING
MODULE_SPEC_TOPLEVEL_CONSTANT.should == 1
end
- it "does not import methods to modules and classes" do
- ModuleSpecs::A.methods.include?("cma").should == true
- ModuleSpecs::B.methods.include?("cma").should == false
- ModuleSpecs::B.methods.include?("cmb").should == true
- ModuleSpecs::C.methods.include?("cma").should == false
- ModuleSpecs::C.methods.include?("cmb").should == false
+ ruby_version_is ""..."1.9" do
+ it "does not import methods to modules and classes" do
+ ModuleSpecs::A.methods.include?("cma").should == true
+ ModuleSpecs::B.methods.include?("cma").should == false
+ ModuleSpecs::B.methods.include?("cmb").should == true
+ ModuleSpecs::C.methods.include?("cma").should == false
+ ModuleSpecs::C.methods.include?("cmb").should == false
+ end
end
+ ruby_version_is "1.9" do
+ it "does not import methods to modules and classes" do
+ ModuleSpecs::A.methods.include?(:cma).should == true
+ ModuleSpecs::B.methods.include?(:cma).should == false
+ ModuleSpecs::B.methods.include?(:cmb).should == true
+ ModuleSpecs::C.methods.include?(:cma).should == false
+ ModuleSpecs::C.methods.include?(:cmb).should == false
+ end
+ end
+
it "attaches the module as the caller's immediate ancestor" do
module IncludeSpecsTop
def value; 5; end
Modified: MacRuby/branches/experimental/spec/frozen/core/module/included_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/included_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/module/included_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -33,7 +33,15 @@
c.test.should == :passed
end
- it "is private in its default implementation" do
- Module.new.private_methods.should include("included")
+ ruby_version_is ""..."1.9" do
+ it "is private in its default implementation" do
+ Module.new.private_methods.should include("included")
+ end
end
+
+ ruby_version_is "1.9" do
+ it "is private in its default implementation" do
+ Module.new.private_methods.should include(:included)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/module/instance_method_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/instance_method_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/module/instance_method_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -35,10 +35,19 @@
@mod_um.inspect.should =~ /\bModuleSpecs::InstanceMethChild\b/
end
- it "raises an ArgumentError if passed a Fixnum that is not a symbol" do
- lambda { Object.instance_method(0) }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if passed a Fixnum that is not a symbol" do
+ lambda { Object.instance_method(0) }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a TypeError if not passed a symbol" do
+ lambda { Object.instance_method([]) }.should raise_error(TypeError)
+ lambda { Object.instance_method(0) }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if the given name is not a string/symbol" do
lambda { Object.instance_method(nil) }.should raise_error(TypeError)
lambda { Object.instance_method(mock('x')) }.should raise_error(TypeError)
Modified: MacRuby/branches/experimental/spec/frozen/core/module/private_method_defined_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/private_method_defined_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/module/private_method_defined_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -31,12 +31,22 @@
ModuleSpecs::CountsMixin.private_method_defined?(:private_3).should == true
end
- it "raises an ArgumentError if passed a Fixnum" do
- lambda {
- ModuleSpecs::CountsMixin.private_method_defined?(1)
- }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if passed a Fixnum" do
+ lambda {
+ ModuleSpecs::CountsMixin.private_method_defined?(1)
+ }.should raise_error(ArgumentError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises an TypeError if passed a Fixnum" do
+ lambda {
+ ModuleSpecs::CountsMixin.private_method_defined?(1)
+ }.should raise_error(TypeError)
+ end
+ end
+
it "raises a TypeError if passed nil" do
lambda {
ModuleSpecs::CountsMixin.private_method_defined?(nil)
Modified: MacRuby/branches/experimental/spec/frozen/core/module/protected_instance_methods_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/protected_instance_methods_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/module/protected_instance_methods_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -2,24 +2,48 @@
require File.dirname(__FILE__) + '/fixtures/classes'
describe "Module#protected_instance_methods" do
- it "returns a list of protected methods in module and its ancestors" do
- methods = ModuleSpecs::CountsMixin.protected_instance_methods
- methods.should include('protected_3')
-
- methods = ModuleSpecs::CountsParent.protected_instance_methods
- methods.should include('protected_3')
- methods.should include('protected_2')
+ ruby_version_is ""..."1.9" do
+ it "returns a list of protected methods in module and its ancestors" do
+ methods = ModuleSpecs::CountsMixin.protected_instance_methods
+ methods.should include('protected_3')
+
+ methods = ModuleSpecs::CountsParent.protected_instance_methods
+ methods.should include('protected_3')
+ methods.should include('protected_2')
- methods = ModuleSpecs::CountsChild.protected_instance_methods
- methods.should include('protected_3')
- methods.should include('protected_2')
- methods.should include('protected_1')
+ methods = ModuleSpecs::CountsChild.protected_instance_methods
+ methods.should include('protected_3')
+ methods.should include('protected_2')
+ methods.should include('protected_1')
+ end
+
+ it "when passed false as a parameter, should return only methods defined in that module" do
+ ModuleSpecs::CountsMixin.protected_instance_methods(false).should == ['protected_3']
+ ModuleSpecs::CountsParent.protected_instance_methods(false).should == ['protected_2']
+ ModuleSpecs::CountsChild.protected_instance_methods(false).should == ['protected_1']
+ end
end
- it "when passed false as a parameter, should return only methods defined in that module" do
- ModuleSpecs::CountsMixin.protected_instance_methods(false).should == ['protected_3']
- ModuleSpecs::CountsParent.protected_instance_methods(false).should == ['protected_2']
- ModuleSpecs::CountsChild.protected_instance_methods(false).should == ['protected_1']
+ ruby_version_is "1.9" do
+ it "returns a list of protected methods in module and its ancestors" do
+ methods = ModuleSpecs::CountsMixin.protected_instance_methods
+ methods.should include(:protected_3)
+
+ methods = ModuleSpecs::CountsParent.protected_instance_methods
+ methods.should include(:protected_3)
+ methods.should include(:protected_2)
+
+ methods = ModuleSpecs::CountsChild.protected_instance_methods
+ methods.should include(:protected_3)
+ methods.should include(:protected_2)
+ methods.should include(:protected_1)
+ end
+
+ it "when passed false as a parameter, should return only methods defined in that module" do
+ ModuleSpecs::CountsMixin.protected_instance_methods(false).should == [:protected_3]
+ ModuleSpecs::CountsParent.protected_instance_methods(false).should == [:protected_2]
+ ModuleSpecs::CountsChild.protected_instance_methods(false).should == [:protected_1]
+ end
end
it "default list should be the same as passing true as an argument" do
Modified: MacRuby/branches/experimental/spec/frozen/core/module/protected_method_defined_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/protected_method_defined_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/module/protected_method_defined_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -32,25 +32,47 @@
end
not_compliant_on :rubinius do
- it "raises an ArgumentError if passed a Fixnum" do
- lambda {
- ModuleSpecs::CountsMixin.protected_method_defined?(1)
- }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if passed a Fixnum" do
+ lambda {
+ ModuleSpecs::CountsMixin.protected_method_defined?(1)
+ }.should raise_error(ArgumentError)
+ end
+
+ it "raises a TypeError if not passed a Symbol" do
+ lambda {
+ ModuleSpecs::CountsMixin.protected_method_defined?(nil)
+ }.should raise_error(TypeError)
+ lambda {
+ ModuleSpecs::CountsMixin.protected_method_defined?(false)
+ }.should raise_error(TypeError)
+
+ sym = mock('symbol')
+ def sym.to_sym() :protected_3 end
+ lambda {
+ ModuleSpecs::CountsMixin.protected_method_defined?(sym)
+ }.should raise_error(TypeError)
+ end
end
- it "raises a TypeError if not passed a Symbol" do
- lambda {
- ModuleSpecs::CountsMixin.protected_method_defined?(nil)
- }.should raise_error(TypeError)
- lambda {
- ModuleSpecs::CountsMixin.protected_method_defined?(false)
- }.should raise_error(TypeError)
+ ruby_version_is "1.9" do
+ it "raises a TypeError if not passed a Symbol" do
+ lambda {
+ ModuleSpecs::CountsMixin.protected_method_defined?(1)
+ }.should raise_error(TypeError)
+ lambda {
+ ModuleSpecs::CountsMixin.protected_method_defined?(nil)
+ }.should raise_error(TypeError)
+ lambda {
+ ModuleSpecs::CountsMixin.protected_method_defined?(false)
+ }.should raise_error(TypeError)
- sym = mock('symbol')
- def sym.to_sym() :protected_3 end
- lambda {
- ModuleSpecs::CountsMixin.protected_method_defined?(sym)
- }.should raise_error(TypeError)
+ sym = mock('symbol')
+ def sym.to_sym() :protected_3 end
+ lambda {
+ ModuleSpecs::CountsMixin.protected_method_defined?(sym)
+ }.should raise_error(TypeError)
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/module/public_method_defined_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/public_method_defined_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/module/public_method_defined_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -32,14 +32,36 @@
end
not_compliant_on :rubinius do
- it "raises an ArgumentError if called with a Fixnum" do
- lambda {
- ModuleSpecs::CountsMixin.public_method_defined?(1)
- }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises an ArgumentError if called with a Fixnum" do
+ lambda {
+ ModuleSpecs::CountsMixin.public_method_defined?(1)
+ }.should raise_error(ArgumentError)
+ end
+
+ it "raises a TypeError if not passed a Symbol" do
+ lambda {
+ ModuleSpecs::CountsMixin.public_method_defined?(nil)
+ }.should raise_error(TypeError)
+ lambda {
+ ModuleSpecs::CountsMixin.public_method_defined?(false)
+ }.should raise_error(TypeError)
+
+ sym = mock('symbol')
+ def sym.to_sym() :public_3 end
+ lambda {
+ ModuleSpecs::CountsMixin.public_method_defined?(sym)
+ }.should raise_error(TypeError)
+ end
end
-
+ end
+
+ ruby_version_is "1.9" do
it "raises a TypeError if not passed a Symbol" do
lambda {
+ ModuleSpecs::CountsMixin.public_method_defined?(1)
+ }.should raise_error(TypeError)
+ lambda {
ModuleSpecs::CountsMixin.public_method_defined?(nil)
}.should raise_error(TypeError)
lambda {
Modified: MacRuby/branches/experimental/spec/frozen/core/object/match_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/object/match_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/object/match_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,14 +1,29 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe Object, '=~' do
- it 'returns false matching any object' do
- o = Object.new
+ ruby_version_is ""..."1.9" do
+ it 'returns false matching any object' do
+ o = Object.new
- (o =~ /Object/).should == false
- (o =~ 'Object').should == false
- (o =~ Object).should == false
- (o =~ Object.new).should == false
- (o =~ nil).should == false
- (o =~ true).should == false
+ (o =~ /Object/).should == false
+ (o =~ 'Object').should == false
+ (o =~ Object).should == false
+ (o =~ Object.new).should == false
+ (o =~ nil).should == false
+ (o =~ true).should == false
+ end
end
+
+ ruby_version_is "1.9" do
+ it 'returns nil matching any object' do
+ o = Object.new
+
+ (o =~ /Object/).should be_nil
+ (o =~ 'Object').should be_nil
+ (o =~ Object).should be_nil
+ (o =~ Object.new).should be_nil
+ (o =~ nil).should be_nil
+ (o =~ true).should be_nil
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/precision/included_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/precision/included_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/precision/included_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,18 +1,20 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-describe "Precision.included" do
- it "raises a TypeError when a class mixed with Precision does not specify induced_from" do
- class Foo ;include Precision ;end
- lambda { Foo.induced_from(1) }.should raise_error(TypeError)
- end
+ruby_version_is ""..."1.9.1" do
+ describe "Precision.included" do
+ it "raises a TypeError when a class mixed with Precision does not specify induced_from" do
+ class Foo ;include Precision ;end
+ lambda { Foo.induced_from(1) }.should raise_error(TypeError)
+ end
- it "doesn't raise a TypeError when a class mixed with Precision specifies induced_from" do
- class Foo
- include Precision
- def self.induced_from(obj)
- # nothing
+ it "doesn't raise a TypeError when a class mixed with Precision specifies induced_from" do
+ class Foo
+ include Precision
+ def self.induced_from(obj)
+ # nothing
+ end
end
+ lambda { Foo.induced_from(1) }.should_not raise_error(TypeError)
end
- lambda { Foo.induced_from(1) }.should_not raise_error(TypeError)
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/precision/prec_f_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/precision/prec_f_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/precision/prec_f_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,12 +1,13 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-describe "Precision#prec_f" do
- it "converts a Integer to Float when called on an Integer" do
- 1.prec_f.should==1.0
- end
+ruby_version_is ""..."1.9.1" do
+ describe "Precision#prec_f" do
+ it "converts a Integer to Float when called on an Integer" do
+ 1.prec_f.should==1.0
+ end
- it "returns the same Float when called on a Float" do
- 1.9.prec_f.should==1.9
+ it "returns the same Float when called on a Float" do
+ 1.9.prec_f.should==1.9
+ end
end
end
-
Modified: MacRuby/branches/experimental/spec/frozen/core/precision/prec_i_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/precision/prec_i_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/precision/prec_i_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,11 +1,13 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-describe "Precision#prec_i" do
- it "returns the same Integer when called on an Integer" do
- 1.prec_i.should == 1
- end
+ruby_version_is ""..."1.9.1" do
+ describe "Precision#prec_i" do
+ it "returns the same Integer when called on an Integer" do
+ 1.prec_i.should == 1
+ end
- it "converts Float to an Integer when called on an Integer" do
- 1.9.prec_i.should == 1
+ it "converts Float to an Integer when called on an Integer" do
+ 1.9.prec_i.should == 1
+ end
end
-end
\ No newline at end of file
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/precision/prec_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/precision/prec_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/precision/prec_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,22 +1,23 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-describe "Float#prec" do
- it "returns the same Float when given the class Float" do
- 1.4.prec(Float).should == 1.4
- end
+ruby_version_is ""..."1.9.1" do
+ describe "Float#prec" do
+ it "returns the same Float when given the class Float" do
+ 1.4.prec(Float).should == 1.4
+ end
- it "converts the Float to an Integer when given the class Integer" do
- 1.4.prec(Integer).should == 1
+ it "converts the Float to an Integer when given the class Integer" do
+ 1.4.prec(Integer).should == 1
+ end
end
-end
-describe "Integer#prec" do
- it "returns the same Integer when given the class Integer" do
- 1.prec(Integer).should == 1
- end
+ describe "Integer#prec" do
+ it "returns the same Integer when given the class Integer" do
+ 1.prec(Integer).should == 1
+ end
- it "converts the Integer to Float when given the class Float" do
- 1.prec(Float).should == 1.0
+ it "converts the Integer to Float when given the class Float" do
+ 1.prec(Float).should == 1.0
+ end
end
end
-
Modified: MacRuby/branches/experimental/spec/frozen/core/proc/to_s_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/proc/to_s_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/proc/to_s_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,9 +1,20 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe "Proc#to_s" do
- it "returns a description of self" do
- Proc.new { "hello" }.to_s.should =~ /^#<Proc:(.*?)@(.*)\/to_s_spec\.rb:5>$/
- lambda { "hello" }.to_s.should =~ /^#<Proc:(.*?)@(.*)\/to_s_spec\.rb:6>$/
- proc { "hello" }.to_s.should =~ /^#<Proc:(.*?)@(.*)\/to_s_spec\.rb:7>$/
+
+ ruby_version_is ""..."1.9" do
+ it "returns a description of self" do
+ Proc.new { "hello" }.to_s.should =~ /^#<Proc:(.*?)@(.*)\/to_s_spec\.rb:7>$/
+ lambda { "hello" }.to_s.should =~ /^#<Proc:(.*?)@(.*)\/to_s_spec\.rb:8>$/
+ proc { "hello" }.to_s.should =~ /^#<Proc:(.*?)@(.*)\/to_s_spec\.rb:9>$/
+ end
end
+
+ ruby_version_is "1.9" do
+ it "returns a description of self" do
+ Proc.new { "hello" }.to_s.should =~ /^#<Proc:(.*?)@(.*)\/to_s_spec\.rb:15>$/
+ lambda { "hello" }.to_s.should =~ /^#<Proc:(.*?)@(.*)\/to_s_spec\.rb:16 \(lambda\)>$/
+ proc { "hello" }.to_s.should =~ /^#<Proc:(.*?)@(.*)\/to_s_spec\.rb:17>$/
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/process/fork_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/process/fork_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/process/fork_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,6 +1,16 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe "Process.fork" do
+ # As of 1.9.2 Process.respond_to?(:fork) returns false on platforms that do
+ # not implement it.
+ ruby_version_is "1.9" do
+ platform_is :windows do
+ it "is not implemented" do
+ Process.respond_to?(:fork).should be_false
+ end
+ end
+ end
+
not_supported_on :jruby, :windows do
before :each do
@file = tmp('i_exist')
@@ -11,6 +21,10 @@
File.delete(@file) if File.exist?(@file)
end
+ it "is implemented" do
+ Process.respond_to?(:fork).should be_true
+ end
+
it "return nil for the child process" do
child_id = Process.fork
if child_id == nil
Added: MacRuby/branches/experimental/spec/frozen/core/range/cover_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/range/cover_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/range/cover_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,57 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.9" do
+ describe "Range#cover?" do
+
+ it "raises an ArgumentError without exactly one argument" do
+ lambda{ (1..2).cover? }.should raise_error(ArgumentError)
+ lambda{ (1..2).cover?(1,2) }.should raise_error(ArgumentError)
+ end
+
+ it "returns true if argument is equal to the first value of the range" do
+ (0..5).cover?(0).should be_true
+ ('f'..'s').cover?('f').should be_true
+ end
+
+ it "returns true if argument is equal to the last value of the range" do
+ (0..5).cover?(5).should be_true
+ (0...5).cover?(4).should be_true
+ ('f'..'s').cover?('s').should be_true
+ end
+
+ it "returns true if argument is less than the last value of the range and greater than the first value" do
+ (20..30).cover?(28).should be_true
+ ('e'..'h').cover?('g').should be_true
+ ("\u{999}".."\u{9999}").cover? "\u{9995}"
+ end
+
+ it "returns true if argument is sole element in the range" do
+ (30..30).cover?(30).should be_true
+ end
+
+ it "returns false if range is empty" do
+ (30...30).cover?(30).should be_false
+ (30...30).cover?(nil).should be_false
+ end
+
+ it "returns false if the range does not contain the argument" do
+ ('A'..'C').cover?(20.9).should be_false
+ ('A'...'C').cover?('C').should be_false
+ end
+
+ it "uses the range element's <=> to make the comparison" do
+ a = mock('a')
+ a.should_receive(:<=>).twice.and_return(-1,-1)
+ (a..'z').cover?('b').should be_true
+ end
+
+ it "uses a continuous inclusion test" do
+ ('a'..'f').cover?('aa').should be_true
+ ('a'..'f').cover?('babe').should be_true
+ ('a'..'f').cover?('baby').should be_true
+ ('a'..'f').cover?('ga').should be_false
+ (-10..-2).cover?(-2.5).should be_true
+ end
+
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/regexp/kcode_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/regexp/kcode_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/regexp/kcode_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,15 +1,17 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-describe "Regexp#kcode" do
- it "returns the character set code" do
- default = /f.(o)/.kcode
- default.should_not == 'sjis'
- default.should_not == 'euc'
- default.should_not == 'utf8'
+ruby_version_is ""..."1.9" do
+ describe "Regexp#kcode" do
+ it "returns the character set code" do
+ default = /f.(o)/.kcode
+ default.should_not == 'sjis'
+ default.should_not == 'euc'
+ default.should_not == 'utf8'
- /ab+c/s.kcode.should == "sjis"
- /a(.)+s/n.kcode.should == "none"
- /xyz/e.kcode.should == "euc"
- /cars/u.kcode.should == "utf8"
+ /ab+c/s.kcode.should == "sjis"
+ /a(.)+s/n.kcode.should == "none"
+ /xyz/e.kcode.should == "euc"
+ /cars/u.kcode.should == "utf8"
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/regexp/shared/new.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/regexp/shared/new.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/regexp/shared/new.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -81,42 +81,44 @@
(r.options & Regexp::EXTENDED).should == 0
end
- it "does not enable multibyte support by default" do
- r = Regexp.send @method, 'Hi', true
- r.kcode.should_not == 'euc'
- r.kcode.should_not == 'sjis'
- r.kcode.should_not == 'utf8'
- end
+ ruby_version_is ""..."1.9" do
+ it "does not enable multibyte support by default" do
+ r = Regexp.send @method, 'Hi', true
+ r.kcode.should_not == 'euc'
+ r.kcode.should_not == 'sjis'
+ r.kcode.should_not == 'utf8'
+ end
- it "enables EUC encoding if third argument is 'e' or 'euc' (case-insensitive)" do
- Regexp.send(@method, 'Hi', nil, 'e').kcode.should == 'euc'
- Regexp.send(@method, 'Hi', nil, 'E').kcode.should == 'euc'
- Regexp.send(@method, 'Hi', nil, 'euc').kcode.should == 'euc'
- Regexp.send(@method, 'Hi', nil, 'EUC').kcode.should == 'euc'
- Regexp.send(@method, 'Hi', nil, 'EuC').kcode.should == 'euc'
- end
+ it "enables EUC encoding if third argument is 'e' or 'euc' (case-insensitive)" do
+ Regexp.send(@method, 'Hi', nil, 'e').kcode.should == 'euc'
+ Regexp.send(@method, 'Hi', nil, 'E').kcode.should == 'euc'
+ Regexp.send(@method, 'Hi', nil, 'euc').kcode.should == 'euc'
+ Regexp.send(@method, 'Hi', nil, 'EUC').kcode.should == 'euc'
+ Regexp.send(@method, 'Hi', nil, 'EuC').kcode.should == 'euc'
+ end
- it "enables SJIS encoding if third argument is 's' or 'sjis' (case-insensitive)" do
- Regexp.send(@method, 'Hi', nil, 's').kcode.should == 'sjis'
- Regexp.send(@method, 'Hi', nil, 'S').kcode.should == 'sjis'
- Regexp.send(@method, 'Hi', nil, 'sjis').kcode.should == 'sjis'
- Regexp.send(@method, 'Hi', nil, 'SJIS').kcode.should == 'sjis'
- Regexp.send(@method, 'Hi', nil, 'sJiS').kcode.should == 'sjis'
- end
+ it "enables SJIS encoding if third argument is 's' or 'sjis' (case-insensitive)" do
+ Regexp.send(@method, 'Hi', nil, 's').kcode.should == 'sjis'
+ Regexp.send(@method, 'Hi', nil, 'S').kcode.should == 'sjis'
+ Regexp.send(@method, 'Hi', nil, 'sjis').kcode.should == 'sjis'
+ Regexp.send(@method, 'Hi', nil, 'SJIS').kcode.should == 'sjis'
+ Regexp.send(@method, 'Hi', nil, 'sJiS').kcode.should == 'sjis'
+ end
- it "enables UTF-8 encoding if third argument is 'u' or 'utf8' (case-insensitive)" do
- Regexp.send(@method, 'Hi', nil, 'u').kcode.should == 'utf8'
- Regexp.send(@method, 'Hi', nil, 'U').kcode.should == 'utf8'
- Regexp.send(@method, 'Hi', nil, 'utf8').kcode.should == 'utf8'
- Regexp.send(@method, 'Hi', nil, 'UTF8').kcode.should == 'utf8'
- Regexp.send(@method, 'Hi', nil, 'uTf8').kcode.should == 'utf8'
- end
+ it "enables UTF-8 encoding if third argument is 'u' or 'utf8' (case-insensitive)" do
+ Regexp.send(@method, 'Hi', nil, 'u').kcode.should == 'utf8'
+ Regexp.send(@method, 'Hi', nil, 'U').kcode.should == 'utf8'
+ Regexp.send(@method, 'Hi', nil, 'utf8').kcode.should == 'utf8'
+ Regexp.send(@method, 'Hi', nil, 'UTF8').kcode.should == 'utf8'
+ Regexp.send(@method, 'Hi', nil, 'uTf8').kcode.should == 'utf8'
+ end
- it "disables multibyte support if third argument is 'n' or 'none' (case insensitive)" do
- Regexp.send(@method, 'Hi', nil, 'N').kcode.should == 'none'
- Regexp.send(@method, 'Hi', nil, 'n').kcode.should == 'none'
- Regexp.send(@method, 'Hi', nil, 'nONE').kcode.should == 'none'
- end
+ it "disables multibyte support if third argument is 'n' or 'none' (case insensitive)" do
+ Regexp.send(@method, 'Hi', nil, 'N').kcode.should == 'none'
+ Regexp.send(@method, 'Hi', nil, 'n').kcode.should == 'none'
+ Regexp.send(@method, 'Hi', nil, 'nONE').kcode.should == 'none'
+ end
+ end
end
describe :regexp_new_regexp, :shared => true do
@@ -145,17 +147,28 @@
(r.options & Regexp::IGNORECASE).should == 0
end
- it "does not enable multibyte support by default" do
- r = Regexp.send @method, /Hi/
- r.kcode.should_not == 'euc'
- r.kcode.should_not == 'sjis'
- r.kcode.should_not == 'utf8'
+ ruby_version_is ""..."1.9" do
+ it "does not enable multibyte support by default" do
+ r = Regexp.send @method, /Hi/
+ r.kcode.should_not == 'euc'
+ r.kcode.should_not == 'sjis'
+ r.kcode.should_not == 'utf8'
+ end
+
+ it "enables multibyte support if given in the literal" do
+ Regexp.send(@method, /Hi/u).kcode.should == 'utf8'
+ Regexp.send(@method, /Hi/e).kcode.should == 'euc'
+ Regexp.send(@method, /Hi/s).kcode.should == 'sjis'
+ Regexp.send(@method, /Hi/n).kcode.should == 'none'
+ end
end
- it "enables multibyte support if given in the literal" do
- Regexp.send(@method, /Hi/u).kcode.should == 'utf8'
- Regexp.send(@method, /Hi/e).kcode.should == 'euc'
- Regexp.send(@method, /Hi/s).kcode.should == 'sjis'
- Regexp.send(@method, /Hi/n).kcode.should == 'none'
+ ruby_version_is "1.9" do
+ it "enables multibyte support if given in the literal" do
+ Regexp.send(@method, /Hi/u).encoding.inspect.should == "#<Encoding:UTF-8>"
+ Regexp.send(@method, /Hi/e).encoding.inspect.should == "#<Encoding:EUC-JP>"
+ Regexp.send(@method, /Hi/s).encoding.inspect.should == "#<Encoding:Windows-31J>"
+ Regexp.send(@method, /Hi/n).encoding.inspect.should == "#<Encoding:US-ASCII>"
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/struct/members_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/struct/members_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/struct/members_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -2,12 +2,12 @@
require File.dirname(__FILE__) + '/fixtures/classes'
describe "Struct#members" do
- ruby_version_is "" ... "1.9" do
+ ruby_version_is ""..."1.9" do
it "returns an array of attribute names" do
Struct::Car.new.members.should == %w(make model year)
Struct::Car.new('Cadillac').members.should == %w(make model year)
Struct::Ruby.members.should == %w(version platform)
- end
+ end
end
ruby_version_is "1.9" do
@@ -15,6 +15,6 @@
Struct::Car.new.members.should == [:make, :model, :year]
Struct::Car.new('Cadillac').members.should == [:make, :model, :year]
Struct::Ruby.members.should == [:version, :platform]
- end
- end
-end
+ end
+ end
+end
\ No newline at end of file
Modified: MacRuby/branches/experimental/spec/frozen/core/struct/new_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/struct/new_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/struct/new_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -26,13 +26,19 @@
struct.name.should == "Struct::Foo"
end
- ruby_version_is "" ... "1.9" do
+ ruby_version_is ""..."1.9" do
it "creates a new anonymous class with nil first argument" do
struct = Struct.new(nil, :foo)
struct.new("bar").foo.should == "bar"
struct.class.should == Class
struct.name.should == ""
end
+
+ it "creates a new anonymous class with symbol arguments" do
+ struct = Struct.new(:make, :model)
+ struct.class.should == Class
+ struct.name.should == ""
+ end
end
ruby_version_is "1.9" do
@@ -40,31 +46,22 @@
struct = Struct.new(nil, :foo)
struct.new("bar").foo.should == "bar"
struct.class.should == Class
- struct.name.should == nil
+ struct.name.should be_nil
end
- end
- it "does not create a constant with symbol as first argument" do
- struct = Struct.new(:Animal, :name, :legs, :eyeballs)
- struct.should_not == Struct::Animal
- end
-
- ruby_version_is "" ... "1.9" do
it "creates a new anonymous class with symbol arguments" do
struct = Struct.new(:make, :model)
struct.class.should == Class
- struct.name.should == ""
+ struct.name.should == nil
end
end
- ruby_version_is "1.9" do
- it "creates a new anonymous class with symbol arguments" do
- struct = Struct.new(:make, :model)
- struct.class.should == Class
- struct.name.should == nil
- end
+ it "does not create a constant with symbol as first argument" do
+ struct = Struct.new(:Animal, :name, :legs, :eyeballs)
+ struct.should_not == Struct::Animal
end
+
it "fails with invalid constant name as first argument" do
lambda { Struct.new('animal', :name, :legs, :eyeballs) }.should raise_error(NameError)
end
@@ -87,20 +84,21 @@
end
not_compliant_on :rubinius do
- # XXX these 2 specs do not work as expected on 1.9 either
- it "accepts Fixnums as Symbols unless fixnum.to_sym.nil?" do
- num = :foo.to_i
- Struct.new(nil, num).new("bar").foo.should == "bar"
- end
+ ruby_version_is ""..."1.9" do
+ it "accepts Fixnums as Symbols unless fixnum.to_sym.nil?" do
+ num = :foo.to_i
+ Struct.new(nil, num).new("bar").foo.should == "bar"
+ end
- it "raises an ArgumentError if fixnum#to_sym is nil" do
- num = 10000
- num.to_sym.should == nil # if this fails, we need a new Fixnum to test
- lambda { Struct.new(:animal, num) }.should raise_error(ArgumentError)
+ it "raises an ArgumentError if fixnum#to_sym is nil" do
+ num = 10000
+ num.to_sym.should == nil # if this fails, we need a new Fixnum to test
+ lambda { Struct.new(:animal, num) }.should raise_error(ArgumentError)
+ end
end
end
- ruby_version_is "" ... "1.9" do
+ ruby_version_is ""..."1.9" do
it "instance_eval's a passed block" do
klass = Struct.new(:something) { @something_else = 'something else entirely!' }
klass.instance_variables.should include('@something_else')
Modified: MacRuby/branches/experimental/spec/frozen/core/symbol/inspect_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/symbol/inspect_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/symbol/inspect_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -64,9 +64,9 @@
:~ => ":~",
:| => ":|",
- :"!" => ":\"!\"",
- :"!=" => ":\"!=\"",
- :"!~" => ":\"!~\"",
+ :"!" => [":\"!\"", ":!" ],
+ :"!=" => [":\"!=\"", ":!="],
+ :"!~" => [":\"!~\"", ":!~"],
:"\$" => ":\"$\"", # for justice!
:"&&" => ":\"&&\"",
:"'" => ":\"\'\"",
@@ -96,9 +96,21 @@
:" " => ":\" \"",
}
- symbols.each do |input, expected|
- it "returns self as a symbol literal for #{expected}" do
- input.inspect.should == expected
+ ruby_version_is ""..."1.9" do
+ symbols.each do |input, expected|
+ expected = expected[0] if expected.is_a?(Array)
+ it "returns self as a symbol literal for #{expected}" do
+ input.inspect.should == expected
+ end
end
end
+
+ ruby_version_is "1.9" do
+ symbols.each do |input, expected|
+ expected = expected[1] if expected.is_a?(Array)
+ it "returns self as a symbol literal for #{expected}" do
+ input.inspect.should == expected
+ end
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/thread/critical_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/thread/critical_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/thread/critical_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,94 +1,96 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/fixtures/classes'
-describe "Thread.critical=" do
- before(:each) do
- ScratchPad.clear
- end
+ruby_version_is ""..."1.9.1" do
+ describe "Thread.critical=" do
+ before(:each) do
+ ScratchPad.clear
+ end
- it "should be sticky" do
- Thread.critical = true
- Thread.critical.should == true
- Thread.critical = false
- ThreadSpecs.critical_is_reset.should == true
- end
+ it "should be sticky" do
+ Thread.critical = true
+ Thread.critical.should == true
+ Thread.critical = false
+ ThreadSpecs.critical_is_reset.should == true
+ end
- it "allows all non-bool arguments" do
- Thread.critical = "Hello"
- Thread.critical.should == true
+ it "allows all non-bool arguments" do
+ Thread.critical = "Hello"
+ Thread.critical.should == true
- Thread.critical = nil
- ThreadSpecs.critical_is_reset.should == true
- end
+ Thread.critical = nil
+ ThreadSpecs.critical_is_reset.should == true
+ end
- it "functions as a critical section" do
- ThreadSpecs.counter = 0
- iters = 50
- t = Thread.new { ThreadSpecs.increment_counter(iters) }
- ThreadSpecs.increment_counter(iters)
- t.join
- ThreadSpecs.counter.should == iters * 2
- end
+ it "functions as a critical section" do
+ ThreadSpecs.counter = 0
+ iters = 50
+ t = Thread.new { ThreadSpecs.increment_counter(iters) }
+ ThreadSpecs.increment_counter(iters)
+ t.join
+ ThreadSpecs.counter.should == iters * 2
+ end
- it "does not change status of other existing threads" do
- t = ThreadSpecs.create_critical_thread { ScratchPad.record Thread.main.status }
- Thread.pass while t.status and t.status != false
- ScratchPad.recorded.should == "run"
- end
+ it "does not change status of other existing threads" do
+ t = ThreadSpecs.create_critical_thread { ScratchPad.record Thread.main.status }
+ Thread.pass while t.status and t.status != false
+ ScratchPad.recorded.should == "run"
+ end
- it "is reentrant" do
- Thread.critical = true
- Thread.critical = true
- Thread.critical.should == true
- Thread.critical = false
- Thread.critical = false
- ThreadSpecs.critical_is_reset.should == true
- end
+ it "is reentrant" do
+ Thread.critical = true
+ Thread.critical = true
+ Thread.critical.should == true
+ Thread.critical = false
+ Thread.critical = false
+ ThreadSpecs.critical_is_reset.should == true
+ end
- it "can be mismatched" do
- Thread.critical = true
- Thread.critical = true
- Thread.critical.should == true
- Thread.critical = false
- ThreadSpecs.critical_is_reset.should == true
- end
+ it "can be mismatched" do
+ Thread.critical = true
+ Thread.critical = true
+ Thread.critical.should == true
+ Thread.critical = false
+ ThreadSpecs.critical_is_reset.should == true
+ end
- # Hangs on 1.8.6.114 OS X, possibly also on Linux
- quarantine! do
- it "schedules other threads on Thread.pass" do
- ThreadSpecs.critical_thread_yields_to_main_thread { Thread.pass }
- end
+ # Hangs on 1.8.6.114 OS X, possibly also on Linux
+ quarantine! do
+ it "schedules other threads on Thread.pass" do
+ ThreadSpecs.critical_thread_yields_to_main_thread { Thread.pass }
+ end
- it "schedules other threads on sleep" do
- ThreadSpecs.critical_thread_yields_to_main_thread(true) { sleep }
- end
- end
+ it "schedules other threads on sleep" do
+ ThreadSpecs.critical_thread_yields_to_main_thread(true) { sleep }
+ end
+ end
- it "schedules other threads on Thread.stop" do
- # Note that Thread.Stop resets Thread.critical, whereas sleep does not
- ThreadSpecs.critical_thread_yields_to_main_thread(false, true) { Thread.stop }
- end
+ it "schedules other threads on Thread.stop" do
+ # Note that Thread.Stop resets Thread.critical, whereas sleep does not
+ ThreadSpecs.critical_thread_yields_to_main_thread(false, true) { Thread.stop }
+ end
- it "defers exit" do
- critical_thread = ThreadSpecs.create_and_kill_critical_thread()
- Thread.pass while critical_thread.status
- ScratchPad.recorded.should == "status=aborting"
- end
+ it "defers exit" do
+ critical_thread = ThreadSpecs.create_and_kill_critical_thread()
+ Thread.pass while critical_thread.status
+ ScratchPad.recorded.should == "status=aborting"
+ end
- it "defers exit until Thread.pass" do
- critical_thread = ThreadSpecs.create_and_kill_critical_thread(true)
- Thread.pass while critical_thread.status
- ScratchPad.recorded.should == nil
- end
-
- not_compliant_on(:ironruby) do # requires green threads so that another thread can be scheduled when the critical thread is killed
- it "is not reset if the critical thread is killed" do
+ it "defers exit until Thread.pass" do
critical_thread = ThreadSpecs.create_and_kill_critical_thread(true)
Thread.pass while critical_thread.status
- Thread.critical.should == true
+ ScratchPad.recorded.should == nil
+ end
- Thread.critical = false
- ThreadSpecs.critical_is_reset.should == true
+ not_compliant_on(:ironruby) do # requires green threads so that another thread can be scheduled when the critical thread is killed
+ it "is not reset if the critical thread is killed" do
+ critical_thread = ThreadSpecs.create_and_kill_critical_thread(true)
+ Thread.pass while critical_thread.status
+ Thread.critical.should == true
+
+ Thread.critical = false
+ ThreadSpecs.critical_is_reset.should == true
+ end
end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/thread/element_reference_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/thread/element_reference_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/thread/element_reference_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -37,8 +37,17 @@
t2["value"].should == 2
end
- it "raises exceptions on the wrong type of keys" do
- lambda { Thread.current[nil] }.should raise_error(TypeError)
- lambda { Thread.current[5] }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9.1" do
+ it "raises exceptions on the wrong type of keys" do
+ lambda { Thread.current[nil] }.should raise_error(TypeError)
+ lambda { Thread.current[5] }.should raise_error(ArgumentError)
+ end
end
+
+ ruby_version_is "1.9.1" do
+ it "raises exceptions on the wrong type of keys" do
+ lambda { Thread.current[nil] }.should raise_error(TypeError)
+ lambda { Thread.current[5] }.should raise_error(TypeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/thread/element_set_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/thread/element_set_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/thread/element_set_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -2,8 +2,17 @@
require File.dirname(__FILE__) + '/fixtures/classes'
describe "Thread#[]=" do
- it "raises exceptions on the wrong type of keys" do
- lambda { Thread.current[nil] = true }.should raise_error(TypeError)
- lambda { Thread.current[5] = true }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9.1" do
+ it "raises exceptions on the wrong type of keys" do
+ lambda { Thread.current[nil] = true }.should raise_error(TypeError)
+ lambda { Thread.current[5] = true }.should raise_error(ArgumentError)
+ end
end
+
+ ruby_version_is "1.9.1" do
+ it "raises exceptions on the wrong type of keys" do
+ lambda { Thread.current[nil] = true }.should raise_error(TypeError)
+ lambda { Thread.current[5] = true }.should raise_error(TypeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/thread/exit_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/thread/exit_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/thread/exit_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -2,6 +2,8 @@
require File.dirname(__FILE__) + '/fixtures/classes'
require File.dirname(__FILE__) + '/shared/exit'
-describe "Thread#exit" do
- it_behaves_like :thread_exit, :exit
+ruby_version_is ""..."1.9.1" do
+ describe "Thread#exit" do
+ it_behaves_like :thread_exit, :exit
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/thread/fixtures/classes.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/thread/fixtures/classes.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/thread/fixtures/classes.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -93,11 +93,11 @@
def self.status_of_aborting_thread
t = Thread.new { sleep }
begin
- Thread.critical = true
+ Thread.critical = true if Thread.respond_to? :critical
t.kill
Status.new t
ensure
- Thread.critical = false
+ Thread.critical = false if Thread.respond_to? :critical
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/thread/key_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/thread/key_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/thread/key_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -16,8 +16,17 @@
@th.key?(:stanley.to_s).should == false
end
- it "raises exceptions on the wrong type of keys" do
- lambda { Thread.current.key? nil }.should raise_error(TypeError)
- lambda { Thread.current.key? 5 }.should raise_error(ArgumentError)
+ ruby_version_is ""..."1.9" do
+ it "raises exceptions on the wrong type of keys" do
+ lambda { Thread.current.key? nil }.should raise_error(TypeError)
+ lambda { Thread.current.key? 5 }.should raise_error(ArgumentError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises exceptions on the wrong type of keys" do
+ lambda { Thread.current.key? nil }.should raise_error(TypeError)
+ lambda { Thread.current.key? 5 }.should raise_error(TypeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/thread/stop_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/thread/stop_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/thread/stop_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -10,12 +10,14 @@
t.value.should == 5
end
- it "resets Thread.critical to false" do
- t = Thread.new { Thread.critical = true; Thread.stop }
- Thread.pass while t.status and t.status != 'sleep'
- Thread.critical.should == false
- t.run
- t.join
+ ruby_version_is ""..."1.9.1" do
+ it "resets Thread.critical to false" do
+ t = Thread.new { Thread.critical = true; Thread.stop }
+ Thread.pass while t.status and t.status != 'sleep'
+ Thread.critical.should == false
+ t.run
+ t.join
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/time/strftime_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/time/strftime_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/core/time/strftime_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -70,4 +70,27 @@
time.strftime("%z").should == "+0000"
end
end
+
+ it "supports 12-hr formatting with %l" do
+ time = Time.local(2004, 8, 26, 22, 38, 3)
+ time.strftime('%l').should == '10'
+ morning_time = Time.local(2004, 8, 26, 6, 38, 3)
+ morning_time.strftime('%l').should == ' 6'
+ end
+
+ it "supports AM/PM formatting with %p" do
+ time = Time.local(2004, 8, 26, 22, 38, 3)
+ time.strftime('%p').should == 'PM'
+ time = Time.local(2004, 8, 26, 11, 38, 3)
+ time.strftime('%p').should == 'AM'
+ end
+
+ ruby_version_is "1.9" .. "" do
+ it "supports am/pm formatting with %P" do
+ time = Time.local(2004, 8, 26, 22, 38, 3)
+ time.strftime('%P').should == 'pm'
+ time = Time.local(2004, 8, 26, 11, 38, 3)
+ time.strftime('%P').should == 'am'
+ end
+ end
end
Added: MacRuby/branches/experimental/spec/frozen/fixtures/kernel/classes.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/fixtures/kernel/classes.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/fixtures/kernel/classes.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,56 @@
+module KernelSpecs
+ module MethodMissing
+ def self.method_missing(*args) :method_missing end
+ def self.method_missing(*args) :method_missing end
+ def self.existing() :existing end
+
+ def self.private_method() :private_method end
+ private_class_method :private_method
+ end
+
+ class MethodMissingC
+ def self.method_missing(*args) :method_missing end
+ def method_missing(*args) :instance_method_missing end
+
+ def self.existing() :existing end
+ def existing() :instance_existing end
+
+ def self.private_method() :private_method end
+ def self.protected_method() :protected_method end
+ class << self
+ private :private_method
+ protected :protected_method
+ end
+
+ def private_method() :private_instance_method end
+ private :private_method
+
+ def protected_method() :protected_instance_method end
+ protected :protected_method
+ end
+
+ module NoMethodMissing
+ def self.existing() :existing end
+
+ def self.private_method() :private_method end
+ private_class_method :private_method
+ end
+
+ class NoMethodMissingC
+ def self.existing() :existing end
+ def existing() :instance_existing end
+
+ def self.private_method() :private_method end
+ def self.protected_method() :protected_method end
+ class << self
+ private :private_method
+ protected :protected_method
+ end
+
+ def private_method() :private_instance_method end
+ private :private_method
+
+ def protected_method() :protected_instance_method end
+ protected :protected_method
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/language/class_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/class_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/language/class_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -12,18 +12,16 @@
ClassSpecs::A.class.should == Class
ClassSpecs::A.new.class.should == ClassSpecs::A
end
-
+
it "has no class variables" do
ClassSpecs::A.class_variables.should == []
end
- ruby_version_is "" ... "1.9" do
- it "raises TypeError if constant given as class name exists and is not a Module" do
- lambda {
- class ClassSpecsNumber
- end
- }.should raise_error(TypeError)
- end
+ it "raises TypeError if constant given as class name exists and is not a Module" do
+ lambda {
+ class ClassSpecsNumber
+ end
+ }.should raise_error(TypeError)
end
# test case known to be detecting bugs (JRuby, MRI 1.9)
@@ -45,66 +43,98 @@
end
}.should raise_error(TypeError)
end
-
+
it "allows using self as the superclass if self is a class" do
ClassSpecs::I::J.superclass.should == ClassSpecs::I
-
+
lambda {
class ShouldNotWork < self; end
}.should raise_error(TypeError)
end
-
+
# # I do not think this is a valid spec -- rue
# it "has no class-level instance variables" do
# ClassSpecs::A.instance_variables.should == []
# end
- it "allows the declaration of class variables in the body" do
- ClassSpecs::B.should have_class_variable(:@@cvar)
- ClassSpecs::B.send(:class_variable_get, :@@cvar).should == :cvar
- end
+ ruby_version_is ""..."1.9" do
+ it "allows the declaration of class variables in the body" do
+ ClassSpecs::B.class_variables.should == ["@@cvar"]
+ ClassSpecs::B.send(:class_variable_get, :@@cvar).should == :cvar
+ end
+
+ it "stores instance variables defined in the class body in the class object" do
+ ClassSpecs::B.instance_variables.include?("@ivar").should == true
+ ClassSpecs::B.instance_variable_get(:@ivar).should == :ivar
+ end
- it "stores instance variables defined in the class body in the class object" do
- ClassSpecs::B.should have_instance_variable(:@ivar)
- ClassSpecs::B.instance_variable_get(:@ivar).should == :ivar
- end
+ it "allows the declaration of class variables in a class method" do
+ ClassSpecs::C.class_variables.should == []
+ ClassSpecs::C.make_class_variable
+ ClassSpecs::C.class_variables.should == ["@@cvar"]
+ end
- it "allows the declaration of class variables in a class method" do
- ClassSpecs::C.class_variables.should == []
- ClassSpecs::C.make_class_variable
- ClassSpecs::C.should have_class_variable(:@@cvar)
+ it "allows the definition of class-level instance variables in a class method" do
+ ClassSpecs::C.instance_variables.include?("@civ").should == false
+ ClassSpecs::C.make_class_instance_variable
+ ClassSpecs::C.instance_variables.include?("@civ").should == true
+ end
+
+ it "allows the declaration of class variables in an instance method" do
+ ClassSpecs::D.class_variables.should == []
+ ClassSpecs::D.new.make_class_variable
+ ClassSpecs::D.class_variables.should == ["@@cvar"]
+ end
end
- it "allows the definition of class-level instance variables in a class method" do
- ClassSpecs::C.should_not have_instance_variable(:@civ)
- ClassSpecs::C.make_class_instance_variable
- ClassSpecs::C.should have_instance_variable(:@civ)
- end
+ ruby_version_is "1.9" do
+ it "allows the declaration of class variables in the body" do
+ ClassSpecs::B.class_variables.should == [:@@cvar]
+ ClassSpecs::B.send(:class_variable_get, :@@cvar).should == :cvar
+ end
+
+ it "stores instance variables defined in the class body in the class object" do
+ ClassSpecs::B.instance_variables.include?(:@ivar).should == true
+ ClassSpecs::B.instance_variable_get(:@ivar).should == :ivar
+ end
- it "allows the declaration of class variables in an instance method" do
- ClassSpecs::D.class_variables.should == []
- ClassSpecs::D.new.make_class_variable
- ClassSpecs::D.should have_class_variable(:@@cvar)
+ it "allows the declaration of class variables in a class method" do
+ ClassSpecs::C.class_variables.should == []
+ ClassSpecs::C.make_class_variable
+ ClassSpecs::C.class_variables.should == [:@@cvar]
+ end
+
+ it "allows the definition of class-level instance variables in a class method" do
+ ClassSpecs::C.instance_variables.include?(:@civ).should == false
+ ClassSpecs::C.make_class_instance_variable
+ ClassSpecs::C.instance_variables.include?(:@civ).should == true
+ end
+
+ it "allows the declaration of class variables in an instance method" do
+ ClassSpecs::D.class_variables.should == []
+ ClassSpecs::D.new.make_class_variable
+ ClassSpecs::D.class_variables.should == [:@@cvar]
+ end
end
it "allows the definition of instance methods" do
ClassSpecs::E.new.meth.should == :meth
end
-
+
it "allows the definition of class methods" do
ClassSpecs::E.cmeth.should == :cmeth
end
-
+
it "allows the definition of class methods using class << self" do
ClassSpecs::E.smeth.should == :smeth
end
-
+
it "allows the definition of Constants" do
Object.const_defined?('CONSTANT').should == false
ClassSpecs::E.const_defined?('CONSTANT').should == true
ClassSpecs::E::CONSTANT.should == :constant!
end
-
+
it "returns the value of the last statement in the body" do
class ClassSpecs::Empty; end.should == nil
class ClassSpecs::Twenty; 20; end.should == 20
@@ -114,17 +144,24 @@
end
describe "An outer class definition" do
- it "contains the inner classes" do
- ClassSpecs::Container.should have_constant(:A)
- ClassSpecs::Container.should have_constant(:B)
+ ruby_version_is ""..."1.9" do
+ it "contains the inner classes" do
+ ClassSpecs::Container.constants.should include('A', 'B')
+ end
end
+
+ ruby_version_is "1.9" do
+ it "contains the inner classes" do
+ ClassSpecs::Container.constants.should include(:A, :B)
+ end
+ end
end
describe "A Class Definitions extending an object" do
it "allows adding methods" do
ClassSpecs::O.smeth.should == :smeth
end
-
+
it "raises a TypeError when trying to extend numbers" do
lambda {
eval <<-CODE
@@ -144,11 +181,11 @@
c.meth.should == :meth
c.another.should == :another
end
-
+
it "overwrites existing methods" do
ClassSpecs::G.new.override.should == :override
end
-
+
it "raises a TypeError when superclasses mismatch" do
lambda { class ClassSpecs::A < Array; end }.should raise_error(TypeError)
end
@@ -161,7 +198,7 @@
end
end
ClassSpecs::M.m.should == 1
- end
+ end
end
describe "class provides hooks" do
Modified: MacRuby/branches/experimental/spec/frozen/language/metaclass_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/metaclass_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/language/metaclass_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -27,8 +27,8 @@
cls.is_a?(Class).should == true
cls.should_not equal(Object)
end
-
- deviates_on(:rubinius) do
+
+ deviates_on(:rubinius) do
it "is a MetaClass instance" do
cls = class << mock('x'); self; end
cls.is_a?(MetaClass).should == true
@@ -95,13 +95,26 @@
end.should raise_error(NameError)
end
- it "appears in the metaclass constant list" do
- klass = (class << @object; self; end)
- klass.should have_constant(:CONST)
+ ruby_version_is ""..."1.9" do
+ it "appears in the metaclass constant list" do
+ constants = class << @object; constants; end
+ constants.should include("CONST")
+ end
+
+ it "does not appear in the object's class constant list" do
+ @object.class.constants.should_not include("CONST")
+ end
end
- it "does not appear in the object's class constant list" do
- @object.class.constants.should_not include("CONST")
+ ruby_version_is "1.9" do
+ it "appears in the metaclass constant list" do
+ constants = class << @object; constants; end
+ constants.should include(:CONST)
+ end
+
+ it "does not appear in the object's class constant list" do
+ @object.class.constants.should_not include(:CONST)
+ end
end
it "is not preserved when the object is duped" do
@@ -119,8 +132,4 @@
CONST.should_not be_nil
end
end
-end
-
-
-
-
+end
\ No newline at end of file
Modified: MacRuby/branches/experimental/spec/frozen/language/private_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/private_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/language/private_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -2,29 +2,58 @@
require File.dirname(__FILE__) + '/fixtures/private'
describe "The private keyword" do
- it "marks following methods as being private" do
- a = Private::A.new
- a.methods.should_not include("bar")
- lambda { a.bar }.should raise_error(NoMethodError)
+ ruby_version_is ""..."1.9" do
+ it "marks following methods as being private" do
+ a = Private::A.new
+ a.methods.should_not include("bar")
+ lambda { a.bar }.should raise_error(NoMethodError)
- b = Private::B.new
- b.methods.should_not include("bar")
- lambda { b.bar }.should raise_error(NoMethodError)
- end
+ b = Private::B.new
+ b.methods.should_not include("bar")
+ lambda { b.bar }.should raise_error(NoMethodError)
+ end
- it "is overridden when a new class is opened" do
- c = Private::B::C.new
- c.methods.should include("baz")
- c.baz
- Private::B::public_class_method1.should == 1
- Private::B::public_class_method2.should == 2
- lambda { Private::B::private_class_method1 }.should raise_error(NoMethodError)
+ it "is overridden when a new class is opened" do
+ c = Private::B::C.new
+ c.methods.should include("baz")
+ c.baz
+ Private::B::public_class_method1.should == 1
+ Private::B::public_class_method2.should == 2
+ lambda { Private::B::private_class_method1 }.should raise_error(NoMethodError)
+ end
+
+ it "is no longer in effect when the class is closed" do
+ b = Private::B.new
+ b.methods.should include("foo")
+ b.foo
+ end
end
- it "is no longer in effect when the class is closed" do
- b = Private::B.new
- b.methods.should include("foo")
- b.foo
+ ruby_version_is "1.9" do
+ it "marks following methods as being private" do
+ a = Private::A.new
+ a.methods.should_not include(:bar)
+ lambda { a.bar }.should raise_error(NoMethodError)
+
+ b = Private::B.new
+ b.methods.should_not include(:bar)
+ lambda { b.bar }.should raise_error(NoMethodError)
+ end
+
+ it "is overridden when a new class is opened" do
+ c = Private::B::C.new
+ c.methods.should include(:baz)
+ c.baz
+ Private::B::public_class_method1.should == 1
+ Private::B::public_class_method2.should == 2
+ lambda { Private::B::private_class_method1 }.should raise_error(NoMethodError)
+ end
+
+ it "is no longer in effect when the class is closed" do
+ b = Private::B.new
+ b.methods.should include(:foo)
+ b.foo
+ end
end
it "changes visibility of previously called method" do
Modified: MacRuby/branches/experimental/spec/frozen/library/bigdecimal/new_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/bigdecimal/new_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/bigdecimal/new_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -17,6 +17,13 @@
}
end
+ ruby_bug "1589", "1.8.6.368" do
+ it "doesn't segfault when using a very large string to build the number" do
+ b = BigDecimal.new("1" + "0"*10000000)
+ b._dump.should == "#{b.precs[1]}:0.1E10000001"
+ end
+ end
+
it "Number of significant digits >= given precision" do
pi_string = "3.1415923"
BigDecimal.new("3.1415923", 10).precs[1].should >= 10
Modified: MacRuby/branches/experimental/spec/frozen/library/date/shared/civil.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/date/shared/civil.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/date/shared/civil.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -63,4 +63,14 @@
lambda { Date.send(@method, 2000, 2, 2, r.jd) }.should raise_error(ArgumentError)
end
+
+ ruby_bug "1589", "1.8.6.368" do
+ require 'bigdecimal'
+ require 'bigdecimal/util'
+ it "doesn't blow up (illegal instruction and segfault, respectively) when fed huge numbers" do
+ ["9E69999999","1"*10000000].each do |dv|
+ lambda { Date.new(2002,10,dv.to_d) }.should raise_error(BigDecimal::FloatDomainError)
+ end
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/ftools/catname_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/ftools/catname_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/ftools/catname_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,16 +1,20 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require 'ftools'
-describe "File.catname" do
- it "returns the 2nd arg if it's not a directory" do
- File.catname("blah", "/etc/passwd").should == "/etc/passwd"
- end
+ruby_version_is ""..."1.9" do
- it "uses File.join with the args" do
- File.catname("passwd", ".").should == "./passwd"
+ require 'ftools'
+
+ describe "File.catname" do
+ it "returns the 2nd arg if it's not a directory" do
+ File.catname("blah", "/etc/passwd").should == "/etc/passwd"
+ end
+
+ it "uses File.join with the args" do
+ File.catname("passwd", ".").should == "./passwd"
+ end
+
+ it "uses File.basename on the 1st arg before joining" do
+ File.catname("etc/passwd", ".").should == "./passwd"
+ end
end
-
- it "uses File.basename on the 1st arg before joining" do
- File.catname("etc/passwd", ".").should == "./passwd"
- end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/ftools/chmod_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/ftools/chmod_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/ftools/chmod_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,23 +1,27 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require 'ftools'
-describe "File.chmod" do
- before(:each) do
- (1..2).each do |n|
- system "echo 'hello rubinius' > chmod_test_#{n}"
- system "chmod 0777 chmod_test_#{n}"
+ruby_version_is ""..."1.9" do
+
+ require 'ftools'
+
+ describe "File.chmod" do
+ before(:each) do
+ (1..2).each do |n|
+ system "echo 'hello rubinius' > chmod_test_#{n}"
+ system "chmod 0777 chmod_test_#{n}"
+ end
end
+
+ after(:each) do
+ (1..2).each { |n| File.unlink "chmod_test_#{n}" rescue nil }
+ end
+
+ it "changes the mode to 1st arg for files in 2nd arg" do
+ `ls -l chmod_test_1`.should =~ /^-rwxrwxrwx /
+ `ls -l chmod_test_2`.should =~ /^-rwxrwxrwx /
+ File.chmod 0644, "chmod_test_1", "chmod_test_2"
+ `ls -l chmod_test_1`.should =~ /^-rw-r--r-- /
+ `ls -l chmod_test_2`.should =~ /^-rw-r--r-- /
+ end
end
-
- after(:each) do
- (1..2).each { |n| File.unlink "chmod_test_#{n}" rescue nil }
- end
-
- it "changes the mode to 1st arg for files in 2nd arg" do
- `ls -l chmod_test_1`.should =~ /^-rwxrwxrwx /
- `ls -l chmod_test_2`.should =~ /^-rwxrwxrwx /
- File.chmod 0644, "chmod_test_1", "chmod_test_2"
- `ls -l chmod_test_1`.should =~ /^-rw-r--r-- /
- `ls -l chmod_test_2`.should =~ /^-rw-r--r-- /
- end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/ftools/compare_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/ftools/compare_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/ftools/compare_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,27 +1,31 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require 'ftools'
-describe "File.compare" do
- before(:each) do
- (1..3).to_a.each do |n|
- if n == 3
- system "echo 'hello mri' > compare_test_#{n}"
- else
- system "echo 'hello rubinius' > compare_test_#{n}"
+ruby_version_is ""..."1.9" do
+
+ require 'ftools'
+
+ describe "File.compare" do
+ before(:each) do
+ (1..3).to_a.each do |n|
+ if n == 3
+ system "echo 'hello mri' > compare_test_#{n}"
+ else
+ system "echo 'hello rubinius' > compare_test_#{n}"
+ end
+ system "chmod a+x compare_test_#{n}"
end
- system "chmod a+x compare_test_#{n}"
end
- end
-
- after(:each) do
- (1..3).to_a.each { |n| File.unlink "compare_test_#{n}" }
- end
-
- it "compares the file at 1st arg to the file at 2nd arg" do
- File.compare("compare_test_1", "compare_test_2").should == true
- File.compare("compare_test_2", "compare_test_1").should == true
- File.compare("compare_test_1", "compare_test_3").should == false
- File.compare("compare_test_2", "compare_test_3").should == false
+ after(:each) do
+ (1..3).to_a.each { |n| File.unlink "compare_test_#{n}" }
+ end
+
+ it "compares the file at 1st arg to the file at 2nd arg" do
+ File.compare("compare_test_1", "compare_test_2").should == true
+ File.compare("compare_test_2", "compare_test_1").should == true
+
+ File.compare("compare_test_1", "compare_test_3").should == false
+ File.compare("compare_test_2", "compare_test_3").should == false
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/ftools/copy_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/ftools/copy_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/ftools/copy_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,27 +1,31 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require 'ftools'
-describe "File.copy" do
- before(:each) do
- system "echo 'hello rubinius' > copy_test"
- system "chmod a+x copy_test"
- end
-
- after(:each) do
- File.unlink "copy_test"
- File.unlink "copy_test_dest" rescue nil
- end
-
- it "copies the file at 1st arg to the file at 2nd arg" do
- File.copy("copy_test", "copy_test_dest")
- fd = File.open("copy_test_dest")
- data = fd.read
- data.should == "hello rubinius\n"
- fd.close
+ruby_version_is ""..."1.9" do
+
+ require 'ftools'
+
+ describe "File.copy" do
+ before(:each) do
+ system "echo 'hello rubinius' > copy_test"
+ system "chmod a+x copy_test"
+ end
- omode = File.stat("copy_test").mode
- mode = File.stat("copy_test_dest").mode
+ after(:each) do
+ File.unlink "copy_test"
+ File.unlink "copy_test_dest" rescue nil
+ end
- omode.should == mode
+ it "copies the file at 1st arg to the file at 2nd arg" do
+ File.copy("copy_test", "copy_test_dest")
+ fd = File.open("copy_test_dest")
+ data = fd.read
+ data.should == "hello rubinius\n"
+ fd.close
+
+ omode = File.stat("copy_test").mode
+ mode = File.stat("copy_test_dest").mode
+
+ omode.should == mode
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/ftools/install_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/ftools/install_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/ftools/install_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,19 +1,23 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require 'ftools'
-describe "File.install" do
- before(:each) do
- system "echo 'hello rubinius' > install_test_1"
- system "chmod 0777 install_test_1"
- end
+ruby_version_is ""..."1.9" do
- after(:each) do
- (1..2).each { |n| File.unlink "install_test_#{n}" rescue nil }
+ require 'ftools'
+
+ describe "File.install" do
+ before(:each) do
+ system "echo 'hello rubinius' > install_test_1"
+ system "chmod 0777 install_test_1"
+ end
+
+ after(:each) do
+ (1..2).each { |n| File.unlink "install_test_#{n}" rescue nil }
+ end
+
+ it "changes the mode to 1st arg for files in 2nd arg" do
+ `ls -l install_test_1`.should =~ /^-rwxrwxrwx /
+ File.install "install_test_1", "install_test_2", 0644
+ `ls -l install_test_2`.should =~ /^-rw-r--r-- /
+ end
end
-
- it "changes the mode to 1st arg for files in 2nd arg" do
- `ls -l install_test_1`.should =~ /^-rwxrwxrwx /
- File.install "install_test_1", "install_test_2", 0644
- `ls -l install_test_2`.should =~ /^-rw-r--r-- /
- end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/ftools/makedirs_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/ftools/makedirs_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/ftools/makedirs_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,21 +1,25 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require 'ftools'
-describe "File.makedirs" do
- before(:each) do
+ruby_version_is ""..."1.9" do
+
+ require 'ftools'
+
+ describe "File.makedirs" do
+ before(:each) do
+ end
+
+ after(:each) do
+ FileUtils.rm_rf("makedirs_test")
+ flunk if File.exist?("makedirs_test")
+ end
+
+ it "creates the dirs from arg" do
+ File.exist?("makedirs_test").should == false
+ File.makedirs("makedirs_test/second_dir")
+ File.exist?("makedirs_test").should == true
+ File.directory?("makedirs_test").should == true
+ File.exist?("makedirs_test/second_dir").should == true
+ File.directory?("makedirs_test/second_dir").should == true
+ end
end
-
- after(:each) do
- FileUtils.rm_rf("makedirs_test")
- flunk if File.exist?("makedirs_test")
- end
-
- it "creates the dirs from arg" do
- File.exist?("makedirs_test").should == false
- File.makedirs("makedirs_test/second_dir")
- File.exist?("makedirs_test").should == true
- File.directory?("makedirs_test").should == true
- File.exist?("makedirs_test/second_dir").should == true
- File.directory?("makedirs_test/second_dir").should == true
- end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/ftools/move_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/ftools/move_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/ftools/move_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,26 +1,30 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require 'ftools'
-describe "File.move" do
- before(:each) do
- system "echo 'hello rubinius' > move_test"
- system "chmod a+x move_test"
- end
-
- after(:each) do
- File.unlink "move_test_dest"
- File.unlink "move_test" rescue nil
- end
-
- it "moves the file at 1st arg to the file at 2nd arg" do
- omode = File.stat("move_test").mode
- File.move("move_test", "move_test_dest")
- fd = File.open("move_test_dest")
- data = fd.read
- data.should == "hello rubinius\n"
- fd.close
- mode = File.stat("move_test_dest").mode
+ruby_version_is ""..."1.9" do
+
+ require 'ftools'
+
+ describe "File.move" do
+ before(:each) do
+ system "echo 'hello rubinius' > move_test"
+ system "chmod a+x move_test"
+ end
- omode.should == mode
+ after(:each) do
+ File.unlink "move_test_dest"
+ File.unlink "move_test" rescue nil
+ end
+
+ it "moves the file at 1st arg to the file at 2nd arg" do
+ omode = File.stat("move_test").mode
+ File.move("move_test", "move_test_dest")
+ fd = File.open("move_test_dest")
+ data = fd.read
+ data.should == "hello rubinius\n"
+ fd.close
+ mode = File.stat("move_test_dest").mode
+
+ omode.should == mode
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/ftools/safe_unlink_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/ftools/safe_unlink_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/ftools/safe_unlink_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,23 +1,27 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require 'ftools'
-describe "File.safe_unlink" do
- before(:each) do
- (1..2).each do |n|
- system "echo 'hello rubinius' > safe_unlink_test_#{n}"
- system "chmod 0777 safe_unlink_test_#{n}"
+ruby_version_is ""..."1.9" do
+
+ require 'ftools'
+
+ describe "File.safe_unlink" do
+ before(:each) do
+ (1..2).each do |n|
+ system "echo 'hello rubinius' > safe_unlink_test_#{n}"
+ system "chmod 0777 safe_unlink_test_#{n}"
+ end
end
+
+ after(:each) do
+ (1..2).each { |n| File.unlink "safe_unlink_test_#{n}" rescue nil }
+ end
+
+ it "deletes the files in arg and returns an array of files deleted" do
+ File.exist?("safe_unlink_test_1").should == true
+ File.exist?("safe_unlink_test_2").should == true
+ File.safe_unlink("safe_unlink_test_1", "safe_unlink_test_2").should == ["safe_unlink_test_1", "safe_unlink_test_2"]
+ File.exist?("safe_unlink_test_1").should == false
+ File.exist?("safe_unlink_test_2").should == false
+ end
end
-
- after(:each) do
- (1..2).each { |n| File.unlink "safe_unlink_test_#{n}" rescue nil }
- end
-
- it "deletes the files in arg and returns an array of files deleted" do
- File.exist?("safe_unlink_test_1").should == true
- File.exist?("safe_unlink_test_2").should == true
- File.safe_unlink("safe_unlink_test_1", "safe_unlink_test_2").should == ["safe_unlink_test_1", "safe_unlink_test_2"]
- File.exist?("safe_unlink_test_1").should == false
- File.exist?("safe_unlink_test_2").should == false
- end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/ftools/syscopy_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/ftools/syscopy_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/ftools/syscopy_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,27 +1,31 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require 'ftools'
-describe "File.syscopy" do
- before(:each) do
- system "echo 'hello rubinius' > syscopy_test"
- system "chmod a+x syscopy_test"
- end
-
- after(:each) do
- File.unlink "syscopy_test"
- File.unlink "syscopy_test_dest" rescue nil
- end
-
- it "copies the file at 1st arg to the file at 2nd arg" do
- File.syscopy("syscopy_test", "syscopy_test_dest")
- fd = File.open("syscopy_test_dest")
- data = fd.read
- data.should == "hello rubinius\n"
- fd.close
+ruby_version_is ""..."1.9" do
+
+ require 'ftools'
+
+ describe "File.syscopy" do
+ before(:each) do
+ system "echo 'hello rubinius' > syscopy_test"
+ system "chmod a+x syscopy_test"
+ end
- omode = File.stat("syscopy_test").mode
- mode = File.stat("syscopy_test_dest").mode
+ after(:each) do
+ File.unlink "syscopy_test"
+ File.unlink "syscopy_test_dest" rescue nil
+ end
- omode.should == mode
+ it "copies the file at 1st arg to the file at 2nd arg" do
+ File.syscopy("syscopy_test", "syscopy_test_dest")
+ fd = File.open("syscopy_test_dest")
+ data = fd.read
+ data.should == "hello rubinius\n"
+ fd.close
+
+ omode = File.stat("syscopy_test").mode
+ mode = File.stat("syscopy_test_dest").mode
+
+ omode.should == mode
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/generator/each_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/generator/each_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/generator/each_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,27 +1,31 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/common'
-describe "Generator#each" do
- it "enumerates the elements" do
- g = GeneratorSpecs.four_elems
- result = []
+ruby_version_is ""..."1.9" do
+
+ require File.dirname(__FILE__) + '/fixtures/common'
+
+ describe "Generator#each" do
+ it "enumerates the elements" do
+ g = GeneratorSpecs.four_elems
+ result = []
- g.each { |element|
- result << element
- }
+ g.each { |element|
+ result << element
+ }
- result.should == ['A', 'B', 'C', 'Z']
- end
+ result.should == ['A', 'B', 'C', 'Z']
+ end
- it "rewinds the generator and only then enumerates the elements" do
- g = GeneratorSpecs.four_elems
- g.next; g.next
- result = []
+ it "rewinds the generator and only then enumerates the elements" do
+ g = GeneratorSpecs.four_elems
+ g.next; g.next
+ result = []
- g.each { |element|
- result << element
- }
+ g.each { |element|
+ result << element
+ }
- result.should == ['A', 'B', 'C', 'Z']
+ result.should == ['A', 'B', 'C', 'Z']
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/generator/new_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/generator/new_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/generator/new_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,22 +1,24 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require 'generator'
-describe "Generator.new" do
- it "creates a new generator from an Enumerable object" do
- g = Generator.new(['A', 'B', 'C', 'Z'])
- g.should_not == nil
- g.kind_of?(Generator).should == true
- end
+ruby_version_is ""..."1.9" do
+ require 'generator'
+ describe "Generator.new" do
+ it "creates a new generator from an Enumerable object" do
+ g = Generator.new(['A', 'B', 'C', 'Z'])
+ g.should_not == nil
+ g.kind_of?(Generator).should == true
+ end
- it "creates a new generator from a block" do
- g = Generator.new { |g|
- for i in 'A'..'C'
- g.yield i
- end
- g.yield 'Z'
- }
+ it "creates a new generator from a block" do
+ g = Generator.new { |g|
+ for i in 'A'..'C'
+ g.yield i
+ end
+ g.yield 'Z'
+ }
- g.should_not == nil
- g.kind_of?(Generator).should == true
+ g.should_not == nil
+ g.kind_of?(Generator).should == true
+ end
end
-end
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/generator/next_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/generator/next_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/generator/next_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,74 +1,77 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/common'
-describe "Generator#next?" do
- it "returns false for empty generator" do
- GeneratorSpecs.empty.next?.should == false
- end
+ruby_version_is ""..."1.9" do
+ require File.dirname(__FILE__) + '/fixtures/common'
- it "returns true for non-empty generator" do
- g = Generator.new([1])
- g.next?.should == true
+ describe "Generator#next?" do
+ it "returns false for empty generator" do
+ GeneratorSpecs.empty.next?.should == false
+ end
- GeneratorSpecs.two_elems.next?.should == true
+ it "returns true for non-empty generator" do
+ g = Generator.new([1])
+ g.next?.should == true
- g = Generator.new(['A', 'B', 'C', 'D', 'E', 'F'])
- g.next?.should == true
- end
+ GeneratorSpecs.two_elems.next?.should == true
- it "returns true if the generator has not reached the end yet" do
- g = GeneratorSpecs.two_elems
- g.next
- g.next?.should == true
- end
+ g = Generator.new(['A', 'B', 'C', 'D', 'E', 'F'])
+ g.next?.should == true
+ end
- it "returns false if the generator has reached the end" do
- g = GeneratorSpecs.two_elems
- g.next
- g.next
- g.next?.should == false
- end
+ it "returns true if the generator has not reached the end yet" do
+ g = GeneratorSpecs.two_elems
+ g.next
+ g.next?.should == true
+ end
- it "returns false if end? returns true" do
- g = GeneratorSpecs.two_elems
- def g.end?; true end
- g.next?.should == false
- end
-end
+ it "returns false if the generator has reached the end" do
+ g = GeneratorSpecs.two_elems
+ g.next
+ g.next
+ g.next?.should == false
+ end
-describe "Generator#next" do
- it "raises an EOFError on empty generator" do
- lambda { GeneratorSpecs.empty.next }.should raise_error(EOFError)
+ it "returns false if end? returns true" do
+ g = GeneratorSpecs.two_elems
+ def g.end?; true end
+ g.next?.should == false
+ end
end
- it "raises an EOFError if no elements available" do
- g = GeneratorSpecs.two_elems
- g.next;
- g.next
- lambda { g.next }.should raise_error(EOFError)
- end
+ describe "Generator#next" do
+ it "raises an EOFError on empty generator" do
+ lambda { GeneratorSpecs.empty.next }.should raise_error(EOFError)
+ end
- it "raises an EOFError if end? returns true" do
- g = GeneratorSpecs.two_elems
- def g.end?; true end
- lambda { g.next }.should raise_error(EOFError)
- end
+ it "raises an EOFError if no elements available" do
+ g = GeneratorSpecs.two_elems
+ g.next;
+ g.next
+ lambda { g.next }.should raise_error(EOFError)
+ end
- it "returns the element at the current position and moves forward" do
- g = GeneratorSpecs.two_elems
- g.index.should == 0
- g.next.should == 1
- g.index.should == 1
- end
+ it "raises an EOFError if end? returns true" do
+ g = GeneratorSpecs.two_elems
+ def g.end?; true end
+ lambda { g.next }.should raise_error(EOFError)
+ end
- it "subsequent calls should return all elements in proper order" do
- g = GeneratorSpecs.four_elems
-
- result = []
- while g.next?
- result << g.next
+ it "returns the element at the current position and moves forward" do
+ g = GeneratorSpecs.two_elems
+ g.index.should == 0
+ g.next.should == 1
+ g.index.should == 1
end
- result.should == ['A', 'B', 'C', 'Z']
- end
+ it "subsequent calls should return all elements in proper order" do
+ g = GeneratorSpecs.four_elems
+
+ result = []
+ while g.next?
+ result << g.next
+ end
+
+ result.should == ['A', 'B', 'C', 'Z']
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/generator/rewind_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/generator/rewind_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/generator/rewind_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,29 +1,33 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/common'
-describe "Generator#rewind" do
- it "does nothing for empty generator" do
- g = GeneratorSpecs.empty
- g.index.should == 0
- g.rewind
- g.index.should == 0
- end
+ruby_version_is ""..."1.9" do
+
+ require File.dirname(__FILE__) + '/fixtures/common'
- it "rewinds the generator" do
- g = GeneratorSpecs.two_elems
- orig = g.next
- g.index.should == 1
- g.rewind
- g.index.should == 0
- g.next.should == orig
- end
+ describe "Generator#rewind" do
+ it "does nothing for empty generator" do
+ g = GeneratorSpecs.empty
+ g.index.should == 0
+ g.rewind
+ g.index.should == 0
+ end
- it "rewinds the previously finished generator" do
- g = GeneratorSpecs.two_elems
- g.next; g.next
- g.rewind
- g.end?.should == false
- g.next?.should == true
- g.next.should == 1
+ it "rewinds the generator" do
+ g = GeneratorSpecs.two_elems
+ orig = g.next
+ g.index.should == 1
+ g.rewind
+ g.index.should == 0
+ g.next.should == orig
+ end
+
+ it "rewinds the previously finished generator" do
+ g = GeneratorSpecs.two_elems
+ g.next; g.next
+ g.rewind
+ g.end?.should == false
+ g.next?.should == true
+ g.next.should == 1
+ end
end
end
Deleted: MacRuby/branches/experimental/spec/frozen/library/parsedate/parsedate.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/parsedate/parsedate.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/parsedate/parsedate.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,95 +0,0 @@
-require File.dirname(__FILE__) + "/../../spec_helper"
-require "parsedate"
-
-describe "ParseDate.parsedate" do
- it "returns Array of 8 nils given an empty String" do
- ParseDate.parsedate("").should == [nil] * 8
- end
-
- it "raises TypeError given nil" do
- lambda { ParseDate.parsedate(nil) }.should raise_error(TypeError)
- end
-
- it "raises NoMethodError given Time" do
- lambda { ParseDate.parsedate(Time.now) }.should raise_error(NoMethodError)
- end
-
- it "returns Array with weekday number, given a full day name" do
- ParseDate.parsedate("Sunday").should == [nil] * 7 + [0]
- end
-
- it "returns Array with weekday number, given a 3 letter day name" do
- ParseDate.parsedate("mon").should == [nil] * 7 + [1]
- end
-
- it "returns Array with weekday number, given a String containing a word starting with day" do
- ParseDate.parsedate("ignore friday monday ignore").should == [nil] * 7 + [5]
- ParseDate.parsedate("ignorefriday").should == [nil] * 8
- ParseDate.parsedate("fridayignore").should == [nil] * 7 + [5]
- # friday, not monday!
- ParseDate.parsedate("friends on monday").should == [nil] * 7 + [5]
- end
-
- it "returns Array of 8 nils, given a single digit String" do
- ParseDate.parsedate("8").should == [nil] * 8
- end
-
- it "returns Array with day set, given a String of 2 digits" do
- ParseDate.parsedate("08").should == [nil, nil] + [8] + [nil] * 5
- ParseDate.parsedate("99").should == [nil, nil] + [99] + [nil] * 5
- end
-
- it "returns Array of 8 nils, given a String of 3 digits" do
- ParseDate.parsedate("100").should == [nil] * 8
- end
-
- it "returns Array with month and day set, given a String of 4 digits" do
- ParseDate.parsedate("1050").should == [nil] + [10,50] + [nil] * 5
- end
-
- it "returns Array with year set, given a String of 5 digits" do
- ParseDate.parsedate("10500").should == [10] + [nil] * 7
- end
-
- it "returns Array with date fields set, given a String of 6 digits" do
- ParseDate.parsedate("105070").should == [10, 50, 70] + [nil] * 5
- end
-
- it "returns Array with 4-digit year set, given a String of 7 digits" do
- ParseDate.parsedate("1050701").should == [1050] + [nil] * 7
- end
-
- it "returns Array with date fields set, given a String of 8 digits" do
- ParseDate.parsedate("10507011").should == [1050, 70, 11] + [nil] * 5
- end
-
- it "returns Array of 8 nils, given a odd-sized String of 9 or more digits" do
- ParseDate.parsedate("123456789").should == [nil] * 8
- ParseDate.parsedate("12345678901").should == [nil] * 8
- end
-
- it "returns Array with date & hour fields set, given a String of 10 digits" do
- ParseDate.parsedate("1234567890").should == [1234, 56, 78, 90] + [nil] * 4
- end
-
- it "returns Array with date, hour & minute fields set, given a String of 12 digits" do
- ParseDate.parsedate("123456789012").should == [1234, 56, 78, 90, 12] + [nil] * 3
- end
-
- it "returns Array with date & time fields set, given a String of 14 digits" do
- ParseDate.parsedate("12345678901234").should == [1234, 56, 78, 90, 12, 34, nil, nil]
- end
-
- it "returns Array with year and month set, given a String like nn-nn" do
- ParseDate.parsedate("08-09").should == [8,9] + [nil] * 6
- ParseDate.parsedate("08-09",true).should == [2008,9] + [nil] * 6
- end
-
- it "returns Array with day and hour set, given a String like n-nn" do
- ParseDate.parsedate("8-09").should == [nil,nil] + [9,8] + [nil] * 4
- end
-
- it "returns Array with day and timezone set, given a String like nn-n" do
- ParseDate.parsedate("08-9").should == [nil,nil,8,nil,nil,nil,"-9",nil]
- end
-end
Added: MacRuby/branches/experimental/spec/frozen/library/parsedate/parsedate_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/parsedate/parsedate_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/parsedate/parsedate_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,98 @@
+require File.dirname(__FILE__) + "/../../spec_helper"
+
+ruby_version_is ""..."1.9" do
+ require "parsedate"
+
+ describe "ParseDate.parsedate" do
+ it "returns Array of 8 nils given an empty String" do
+ ParseDate.parsedate("").should == [nil] * 8
+ end
+
+ it "raises TypeError given nil" do
+ lambda { ParseDate.parsedate(nil) }.should raise_error(TypeError)
+ end
+
+ it "raises NoMethodError given Time" do
+ lambda { ParseDate.parsedate(Time.now) }.should raise_error(NoMethodError)
+ end
+
+ it "returns Array with weekday number, given a full day name" do
+ ParseDate.parsedate("Sunday").should == [nil] * 7 + [0]
+ end
+
+ it "returns Array with weekday number, given a 3 letter day name" do
+ ParseDate.parsedate("mon").should == [nil] * 7 + [1]
+ end
+
+ it "returns Array with weekday number, given a String containing a word starting with day" do
+ ParseDate.parsedate("ignore friday monday ignore").should == [nil] * 7 + [5]
+ ParseDate.parsedate("ignorefriday").should == [nil] * 8
+ ParseDate.parsedate("fridayignore").should == [nil] * 7 + [5]
+ # friday, not monday!
+ ParseDate.parsedate("friends on monday").should == [nil] * 7 + [5]
+ end
+
+ it "returns Array of 8 nils, given a single digit String" do
+ ParseDate.parsedate("8").should == [nil] * 8
+ end
+
+ it "returns Array with day set, given a String of 2 digits" do
+ ParseDate.parsedate("08").should == [nil, nil] + [8] + [nil] * 5
+ ParseDate.parsedate("99").should == [nil, nil] + [99] + [nil] * 5
+ end
+
+ it "returns Array of 8 nils, given a String of 3 digits" do
+ ParseDate.parsedate("100").should == [nil] * 8
+ end
+
+ it "returns Array with month and day set, given a String of 4 digits" do
+ ParseDate.parsedate("1050").should == [nil] + [10,50] + [nil] * 5
+ end
+
+ it "returns Array with year set, given a String of 5 digits" do
+ ParseDate.parsedate("10500").should == [10] + [nil] * 7
+ end
+
+ it "returns Array with date fields set, given a String of 6 digits" do
+ ParseDate.parsedate("105070").should == [10, 50, 70] + [nil] * 5
+ end
+
+ it "returns Array with 4-digit year set, given a String of 7 digits" do
+ ParseDate.parsedate("1050701").should == [1050] + [nil] * 7
+ end
+
+ it "returns Array with date fields set, given a String of 8 digits" do
+ ParseDate.parsedate("10507011").should == [1050, 70, 11] + [nil] * 5
+ end
+
+ it "returns Array of 8 nils, given a odd-sized String of 9 or more digits" do
+ ParseDate.parsedate("123456789").should == [nil] * 8
+ ParseDate.parsedate("12345678901").should == [nil] * 8
+ end
+
+ it "returns Array with date & hour fields set, given a String of 10 digits" do
+ ParseDate.parsedate("1234567890").should == [1234, 56, 78, 90] + [nil] * 4
+ end
+
+ it "returns Array with date, hour & minute fields set, given a String of 12 digits" do
+ ParseDate.parsedate("123456789012").should == [1234, 56, 78, 90, 12] + [nil] * 3
+ end
+
+ it "returns Array with date & time fields set, given a String of 14 digits" do
+ ParseDate.parsedate("12345678901234").should == [1234, 56, 78, 90, 12, 34, nil, nil]
+ end
+
+ it "returns Array with year and month set, given a String like nn-nn" do
+ ParseDate.parsedate("08-09").should == [8,9] + [nil] * 6
+ ParseDate.parsedate("08-09",true).should == [2008,9] + [nil] * 6
+ end
+
+ it "returns Array with day and hour set, given a String like n-nn" do
+ ParseDate.parsedate("8-09").should == [nil,nil] + [9,8] + [nil] * 4
+ end
+
+ it "returns Array with day and timezone set, given a String like nn-n" do
+ ParseDate.parsedate("08-9").should == [nil,nil,8,nil,nil,nil,"-9",nil]
+ end
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/ping/pingecho_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/ping/pingecho_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/ping/pingecho_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,27 +1,31 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require 'ping'
-describe "Ping.pingecho" do
+ruby_version_is ""..."1.9" do
+
+ require 'ping'
- it "responds to pingecho method" do
- Ping.should respond_to(:pingecho)
- end
+ describe "Ping.pingecho" do
- it "pings a host using the correct number of arguments" do
- Ping.pingecho('127.0.0.1', 10, 7).should be_true
- Ping.pingecho('127.0.0.1', 10).should be_true
- Ping.pingecho('127.0.0.1').should be_true
- end
+ it "responds to pingecho method" do
+ Ping.should respond_to(:pingecho)
+ end
- it "raises ArgumentError for wrong number of arguments" do
- lambda { Ping.pingecho }.should raise_error(ArgumentError)
- lambda { Ping.pingecho 'one', 'two', 'three', 'four' }.should raise_error(ArgumentError)
- end
+ it "pings a host using the correct number of arguments" do
+ Ping.pingecho('127.0.0.1', 10, 7).should be_true
+ Ping.pingecho('127.0.0.1', 10).should be_true
+ Ping.pingecho('127.0.0.1').should be_true
+ end
- it "returns false for invalid parameters" do
- Ping.pingecho('127.0.0.1', 5, 'invalid port').should be_false
- Ping.pingecho('127.0.0.1', 'invalid timeout').should be_false
- Ping.pingecho(123).should be_false
+ it "raises ArgumentError for wrong number of arguments" do
+ lambda { Ping.pingecho }.should raise_error(ArgumentError)
+ lambda { Ping.pingecho 'one', 'two', 'three', 'four' }.should raise_error(ArgumentError)
+ end
+
+ it "returns false for invalid parameters" do
+ Ping.pingecho('127.0.0.1', 5, 'invalid port').should be_false
+ Ping.pingecho('127.0.0.1', 'invalid timeout').should be_false
+ Ping.pingecho(123).should be_false
+ end
+
end
-
end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/Rational_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/Rational_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/Rational_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -3,28 +3,56 @@
describe "Rational when passed Integer, Integer" do
it "returns a new Rational number" do
- Rational(1, 2).should == Rational.new!(1, 2)
- Rational(-3, -5).should == Rational.new!(-3, -5)
- Rational(bignum_value, 3).should == Rational.new!(bignum_value, 3)
+ rat = Rational(1, 2)
+ rat.numerator.should == 1
+ rat.denominator.should == 2
+ rat.should be_an_instance_of(Rational)
+
+ rat = Rational(-3, -5)
+ rat.numerator.should == 3
+ rat.denominator.should == 5
+ rat.should be_an_instance_of(Rational)
+
+ rat = Rational(bignum_value, 3)
+ rat.numerator.should == bignum_value
+ rat.denominator.should == 3
+ rat.should be_an_instance_of(Rational)
end
it "automatically reduces the Rational" do
- Rational(2, 4).should == Rational.new!(1, 2)
- Rational(3, 9).should == Rational.new!(1, 3)
+ rat = Rational(2, 4)
+ rat.numerator.should == 1
+ rat.denominator.should == 2
+
+ rat = Rational(3, 9)
+ rat.numerator.should == 1
+ rat.denominator.should == 3
end
end
# Guard against the Mathn library
conflicts_with :Prime do
- describe "Rational when passed Integer" do
- it "returns a new Rational number with 1 as the denominator" do
- Rational(1).should eql(Rational.new!(1, 1))
- Rational(-3).should eql(Rational.new!(-3, 1))
- Rational(bignum_value).should eql(Rational.new!(bignum_value, 1))
+ ruby_version_is ""..."1.9" do
+ describe "Rational when passed Integer" do
+ it "returns a new Rational number with 1 as the denominator" do
+ Rational(1).should eql(Rational.new!(1, 1))
+ Rational(-3).should eql(Rational.new!(-3, 1))
+ Rational(bignum_value).should eql(Rational.new!(bignum_value, 1))
+ end
end
end
+ ruby_version_is "1.9" do
+ describe "Rational when passed Integer" do
+ it "returns a new Rational number with 1 as the denominator" do
+ Rational(1).should eql(Rational(1, 1))
+ Rational(-3).should eql(Rational(-3, 1))
+ Rational(bignum_value).should eql(Rational(bignum_value, 1))
+ end
+ end
+ end
+
describe "Rational when passed Integer and Rational::Unify is defined" do
after :each do
Rational.send :remove_const, :Unify
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/equal_value_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/equal_value_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/equal_value_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -11,9 +11,11 @@
(Rational(-bignum_value, 3) == Rational(bignum_value, -3)).should be_true
end
- it "returns false if self has different numerator/denominator but the same numerical value as the passed argument" do
- (Rational(3, 4) == Rational.new!(6, 8)).should be_false
- (Rational(-3, 4) == Rational.new!(-6, 8)).should be_false
+ ruby_version_is ""..."1.9" do
+ it "returns false if self has different numerator/denominator but the same numerical value as the passed argument" do
+ (Rational(3, 4) == Rational.new!(6, 8)).should be_false
+ (Rational(-3, 4) == Rational.new!(-6, 8)).should be_false
+ end
end
end
@@ -23,9 +25,13 @@
(Rational(4, 2) == 2).should be_true
(Rational(-4, 2) == -2).should be_true
(Rational(4, -2) == -2).should be_true
+ end
- (Rational.new!(4, 2) == 2).should be_false
- (Rational.new!(9, 3) == 3).should be_false
+ ruby_version_is ""..."1.9" do
+ it "returns true if self is constructed with #new! and has the passed argument as numerator and a denominator of 1" do
+ (Rational.new!(4, 2) == 2).should be_false
+ (Rational.new!(9, 3) == 3).should be_false
+ end
end
end
@@ -35,10 +41,14 @@
(Rational(4, 2) == 2.0).should be_true
(Rational(-4, 2) == -2.0).should be_true
(Rational(4, -2) == -2.0).should be_true
+ end
- # This is inconsistent to behaviour when passed Integers or Rationals
- (Rational.new!(4, 2) == 2.0).should be_true
- (Rational.new!(9, 3) == 3.0).should be_true
+ ruby_version_is ""..."1.9" do
+ it "converts self to Float and compares it with the passed argument when the #new! constructor is used" do
+ # This is inconsistent to behaviour when passed Integers or Rationals
+ (Rational.new!(4, 2) == 2.0).should be_true
+ (Rational.new!(9, 3) == 3.0).should be_true
+ end
end
end
@@ -49,4 +59,4 @@
(Rational(3, 4) == obj).should == :result
end
-end
\ No newline at end of file
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/new_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/new_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/new_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,21 +1,23 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require 'rational'
-describe "Rational.new" do
- it "is private" do
- Rational.private_methods.should include("new")
+ruby_version_is ""..."1.9" do
+ describe "Rational.new" do
+ it "is private" do
+ Rational.private_methods.should include("new")
+ end
end
-end
-describe "Rational.new!" do
- it "returns a Rational with the passed numerator and denominator not reduced to their lowest terms" do
- Rational.new!(2, 4).should_not eql(Rational(1, 4))
- Rational.new!(6, 8).should_not eql(Rational(3, 4))
- Rational.new!(-5, 10).should_not eql(Rational(-1, 2))
+ describe "Rational.new!" do
+ it "returns a Rational with the passed numerator and denominator not reduced to their lowest terms" do
+ Rational.new!(2, 4).should_not eql(Rational(1, 4))
+ Rational.new!(6, 8).should_not eql(Rational(3, 4))
+ Rational.new!(-5, 10).should_not eql(Rational(-1, 2))
+ end
+
+ it "does not check for divisions by 0" do
+ lambda { Rational.new!(4, 0) }.should_not raise_error(ZeroDivisionError)
+ lambda { Rational.new!(0, 0) }.should_not raise_error(ZeroDivisionError)
+ end
end
-
- it "does not check for divisions by 0" do
- lambda { Rational.new!(4, 0) }.should_not raise_error(ZeroDivisionError)
- lambda { Rational.new!(0, 0) }.should_not raise_error(ZeroDivisionError)
- end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/rational/reduce_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/rational/reduce_spec.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/library/rational/reduce_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,31 +1,34 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require 'rational'
-describe "Rational.reduce when Unify is defined" do
- # This is not consistent with the Complex library, Complex checks
- # Complex::Unify and not the top-level Unify.
- it "returns an Integer when the reduced denominator is 1" do
- begin
- Unify = true
-
- Rational.reduce(3, 1).should eql(3)
- Rational.reduce(5, 1).should eql(5)
- Rational.reduce(4, 2).should eql(2)
- Rational.reduce(-9, 3).should eql(-3)
- ensure
- Object.send :remove_const, :Unify
+
+ruby_version_is ""..."1.9" do
+ describe "Rational.reduce when Unify is defined" do
+ # This is not consistent with the Complex library, Complex checks
+ # Complex::Unify and not the top-level Unify.
+ it "returns an Integer when the reduced denominator is 1" do
+ begin
+ Unify = true
+
+ Rational.reduce(3, 1).should eql(3)
+ Rational.reduce(5, 1).should eql(5)
+ Rational.reduce(4, 2).should eql(2)
+ Rational.reduce(-9, 3).should eql(-3)
+ ensure
+ Object.send :remove_const, :Unify
+ end
end
end
-end
-describe "Rational.reduce" do
- it "returns a new Rational with the passed numerator and denominator reduced to their lowest terms" do
- Rational(6, 8).should eql(Rational(3, 4))
- Rational(-5, 10).should eql(Rational(-1, 2))
+ describe "Rational.reduce" do
+ it "returns a new Rational with the passed numerator and denominator reduced to their lowest terms" do
+ Rational(6, 8).should eql(Rational(3, 4))
+ Rational(-5, 10).should eql(Rational(-1, 2))
+ end
+
+ it "raises a ZeroDivisionError when the passed denominator is 0" do
+ lambda { Rational.reduce(4, 0) }.should raise_error(ZeroDivisionError)
+ lambda { Rational.reduce(-1, 0) }.should raise_error(ZeroDivisionError)
+ end
end
-
- it "raises a ZeroDivisionError when the passed denominator is 0" do
- lambda { Rational.reduce(4, 0) }.should raise_error(ZeroDivisionError)
- lambda { Rational.reduce(-1, 0) }.should raise_error(ZeroDivisionError)
- end
end
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/buffer_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/buffer_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/buffer_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,214 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+FFISpecs::LongSize = FFI::Platform::LONG_SIZE / 8
+
+describe "FFI::Buffer#total" do
+ [1,2,3].each do |i|
+ { :char => 1, :uchar => 1, :short => 2, :ushort => 2, :int => 4,
+ :uint => 4, :long => FFISpecs::LongSize, :ulong => FFISpecs::LongSize,
+ :long_long => 8, :ulong_long => 8, :float => 4, :double => 8
+ }.each_pair do |t, s|
+ it "FFI::Buffer.alloc_in(#{t}, #{i}).total == #{i * s}" do
+ FFI::Buffer.alloc_in(t, i).total.should == i * s
+ end
+ it "FFI::Buffer.alloc_out(#{t}, #{i}).total == #{i * s}" do
+ FFI::Buffer.alloc_out(t, i).total.should == i * s
+ end
+ it "FFI::Buffer.alloc_inout(#{t}, #{i}).total == #{i * s}" do
+ FFI::Buffer.alloc_inout(t, i).total.should == i * s
+ end
+ end
+ end
+end
+
+describe "FFI::Buffer#put_char" do
+ bufsize = 4
+ (0..127).each do |i|
+ (0..bufsize-1).each do |offset|
+ it "put_char(#{offset}, #{i}).get_char(#{offset}) == #{i}" do
+ FFI::Buffer.alloc_in(bufsize).put_char(offset, i).get_char(offset).should == i
+ end
+ end
+ end
+end
+
+describe "FFI::Buffer#put_uchar" do
+ bufsize = 4
+ (0..255).each do |i|
+ (0..bufsize-1).each do |offset|
+ it "FFI::Buffer.put_uchar(#{offset}, #{i}).get_uchar(#{offset}) == #{i}" do
+ FFI::Buffer.alloc_in(bufsize).put_uchar(offset, i).get_uchar(offset).should == i
+ end
+ end
+ end
+end
+
+describe "FFI::Buffer#put_short" do
+ bufsize = 4
+ [0, 1, 128, 32767].each do |i|
+ (0..bufsize-2).each do |offset|
+ it "put_short(#{offset}, #{i}).get_short(#{offset}) == #{i}" do
+ FFI::Buffer.alloc_in(bufsize).put_short(offset, i).get_short(offset).should == i
+ end
+ end
+ end
+end
+
+describe "FFI::Buffer#put_ushort" do
+ bufsize = 4
+ [ 0, 1, 128, 32767, 65535, 0xfee1, 0xdead, 0xbeef, 0xcafe ].each do |i|
+ (0..bufsize-2).each do |offset|
+ it "put_ushort(#{offset}, #{i}).get_ushort(#{offset}) == #{i}" do
+ FFI::Buffer.alloc_in(bufsize).put_ushort(offset, i).get_ushort(offset).should == i
+ end
+ end
+ end
+end
+
+describe "FFI::Buffer#put_int" do
+ bufsize = 8
+ [0, 1, 128, 32767, 0x7ffffff ].each do |i|
+ (0..bufsize-4).each do |offset|
+ it "put_int(#{offset}, #{i}).get_int(#{offset}) == #{i}" do
+ FFI::Buffer.alloc_in(bufsize).put_int(offset, i).get_int(offset).should == i
+ end
+ end
+ end
+end
+
+describe "FFI::Buffer#put_uint" do
+ bufsize = 8
+ [ 0, 1, 128, 32767, 65535, 0xfee1dead, 0xcafebabe, 0xffffffff ].each do |i|
+ (0..bufsize-4).each do |offset|
+ it "put_uint(#{offset}, #{i}).get_uint(#{offset}) == #{i}" do
+ FFI::Buffer.alloc_in(bufsize).put_uint(offset, i).get_uint(offset).should == i
+ end
+ end
+ end
+end
+
+describe "FFI::Buffer#put_long" do
+ bufsize = 16
+ [0, 1, 128, 32767, 0x7ffffff ].each do |i|
+ (0..bufsize-FFISpecs::LongSize).each do |offset|
+ it "put_long(#{offset}, #{i}).get_long(#{offset}) == #{i}" do
+ FFI::Buffer.alloc_in(bufsize).put_long(offset, i).get_long(offset).should == i
+ end
+ end
+ end
+end
+
+describe "FFI::Buffer#put_ulong" do
+ bufsize = 16
+ [ 0, 1, 128, 32767, 65535, 0xfee1dead, 0xcafebabe, 0xffffffff ].each do |i|
+ (0..bufsize-FFISpecs::LongSize).each do |offset|
+ it "put_ulong(#{offset}, #{i}).get_ulong(#{offset}) == #{i}" do
+ FFI::Buffer.alloc_in(bufsize).put_ulong(offset, i).get_ulong(offset).should == i
+ end
+ end
+ end
+end
+
+describe "FFI::Buffer#put_long_long" do
+ bufsize = 16
+ [0, 1, 128, 32767, 0x7ffffffffffffff ].each do |i|
+ (0..bufsize-8).each do |offset|
+ it "put_long_long(#{offset}, #{i}).get_long_long(#{offset}) == #{i}" do
+ FFI::Buffer.alloc_in(bufsize).put_long_long(offset, i).get_long_long(offset).should == i
+ end
+ end
+ end
+end
+
+describe "FFI::Buffer#put_ulong_long" do
+ bufsize = 16
+ [ 0, 1, 128, 32767, 65535, 0xdeadcafebabe, 0x7fffffffffffffff ].each do |i|
+ (0..bufsize-8).each do |offset|
+ it "put_ulong_long(#{offset}, #{i}).get_ulong_long(#{offset}) == #{i}" do
+ FFI::Buffer.alloc_in(bufsize).put_ulong_long(offset, i).get_ulong_long(offset).should == i
+ end
+ end
+ end
+end
+
+describe "Reading/Writing binary strings" do
+ it "FFI::Buffer#put_bytes" do
+ str = "hello\0world"
+ buf = FFI::Buffer.new 1024
+ buf.put_bytes(0, str);
+ s2 = buf.get_bytes(0, 11);
+ s2.should == str
+ end
+
+ it "FFI::Buffer#put_bytes with index and length" do
+ str = "hello\0world"
+ buf = FFI::Buffer.new 1024
+ buf.put_bytes(0, str, 5, 6);
+ s2 = buf.get_bytes(0, 6);
+ s2.should == str[5..-1]
+ end
+
+ it "FFI::Buffer#put_bytes with only index" do
+ str = "hello\0world"
+ buf = FFI::Buffer.new 1024
+ buf.put_bytes(0, str, 5);
+ s2 = buf.get_bytes(0, 6);
+ s2.should == str[5..-1]
+ end
+
+ it "FFI::Buffer#put_bytes with index > str.length" do
+ str = "hello\0world"
+ buf = FFI::Buffer.new 1024
+ lambda { buf.put_bytes(0, str, 12); }.should raise_error
+ end
+
+ it "FFI::Buffer#put_bytes with length > str.length" do
+ str = "hello\0world"
+ buf = FFI::Buffer.new 1024
+ lambda { buf.put_bytes(0, str, 0, 12); }.should raise_error
+ end
+
+ it "FFI::Buffer#put_bytes with negative index" do
+ str = "hello\0world"
+ buf = FFI::Buffer.new 1024
+ lambda { buf.put_bytes(0, str, -1, 12); }.should raise_error
+ end
+end
+
+describe "Reading/Writing ascii strings" do
+ it "FFI::Buffer#put_string with string containing zero byte" do
+ str = "hello\0world"
+ buf = FFI::Buffer.new 1024
+ buf.put_string(0, str);
+ s2 = buf.get_bytes(0, 11);
+ s2.should == str
+ end
+
+ it "FFI::Buffer#get_string with string containing zero byte" do
+ str = "hello\0world"
+ buf = FFI::Buffer.new 1024
+ buf.put_bytes(0, str);
+ s2 = buf.get_string(0, 11);
+ s2.should == "hello"
+ end
+
+ it "FFI::Buffer#put_string without length should NUL terminate" do
+ str = "hello"
+ buf = FFI::Buffer.new 1024
+ buf.put_string(0, str);
+ s2 = buf.get_bytes(0, 6);
+ s2.should == "hello\0"
+ end
+end
+
+describe "FFI::Buffer#put_pointer" do
+ it "put_pointer(0, p).get_pointer(0) == p" do
+ p = FFI::MemoryPointer.new :ulong_long
+ p.put_uint(0, 0xdeadbeef)
+ buf = FFI::Buffer.alloc_inout 8
+ p2 = buf.put_pointer(0, p).get_pointer(0)
+ p2.should_not be_nil
+ p2.should == p
+ p2.get_uint(0).should == 0xdeadbeef
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/callback_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/callback_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/callback_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,524 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+describe "Callback" do
+# module LibC
+# extend Library
+# callback :qsort_cmp, [ :pointer, :pointer ], :int
+# attach_function :qsort, [ :pointer, :int, :int, :qsort_cmp ], :int
+# end
+# it "arguments get passed correctly" do
+# p = FFI::MemoryPointer.new(:int, 2)
+# p.put_array_of_int32(0, [ 1 , 2 ])
+# args = []
+# cmp = proc do |p1, p2| args.push(p1.get_int(0)); args.push(p2.get_int(0)); 0; end
+# # this is a bit dodgey, as it relies on qsort passing the args in order
+# LibC.qsort(p, 2, 4, cmp)
+# args.should == [ 1, 2 ]
+# end
+#
+# it "Block can be substituted for Callback as last argument" do
+# p = FFI::MemoryPointer.new(:int, 2)
+# p.put_array_of_int32(0, [ 1 , 2 ])
+# args = []
+# # this is a bit dodgey, as it relies on qsort passing the args in order
+# LibC.qsort(p, 2, 4) do |p1, p2|
+# args.push(p1.get_int(0))
+# args.push(p2.get_int(0))
+# 0
+# end
+# args.should == [ 1, 2 ]
+# end
+
+ it "function with Callback plus another arg should raise error if no arg given" do
+ lambda { FFISpecs::LibTest.testCallbackCrV { |*a| } }.should raise_error
+ end
+
+ it "returning :char (0)" do
+ FFISpecs::LibTest.testCallbackVrS8 { 0 }.should == 0
+ end
+
+ it "returning :char (127)" do
+ FFISpecs::LibTest.testCallbackVrS8 { 127 }.should == 127
+ end
+
+ it "returning :char (-128)" do
+ FFISpecs::LibTest.testCallbackVrS8 { -128 }.should == -128
+ end
+
+ # test wrap around
+ it "returning :char (128)" do
+ FFISpecs::LibTest.testCallbackVrS8 { 128 }.should == -128
+ end
+
+ it "returning :char (255)" do
+ FFISpecs::LibTest.testCallbackVrS8 { 0xff }.should == -1
+ end
+
+ it "returning :uchar (0)" do
+ FFISpecs::LibTest.testCallbackVrU8 { 0 }.should == 0
+ end
+
+ it "returning :uchar (0xff)" do
+ FFISpecs::LibTest.testCallbackVrU8 { 0xff }.should == 0xff
+ end
+
+ it "returning :uchar (-1)" do
+ FFISpecs::LibTest.testCallbackVrU8 { -1 }.should == 0xff
+ end
+
+ it "returning :uchar (128)" do
+ FFISpecs::LibTest.testCallbackVrU8 { 128 }.should == 128
+ end
+
+ it "returning :uchar (-128)" do
+ FFISpecs::LibTest.testCallbackVrU8 { -128 }.should == 128
+ end
+
+ it "returning :short (0)" do
+ FFISpecs::LibTest.testCallbackVrS16 { 0 }.should == 0
+ end
+
+ it "returning :short (0x7fff)" do
+ FFISpecs::LibTest.testCallbackVrS16 { 0x7fff }.should == 0x7fff
+ end
+
+ # test wrap around
+ it "returning :short (0x8000)" do
+ FFISpecs::LibTest.testCallbackVrS16 { 0x8000 }.should == -0x8000
+ end
+
+ it "returning :short (0xffff)" do
+ FFISpecs::LibTest.testCallbackVrS16 { 0xffff }.should == -1
+ end
+
+ it "returning :ushort (0)" do
+ FFISpecs::LibTest.testCallbackVrU16 { 0 }.should == 0
+ end
+
+ it "returning :ushort (0x7fff)" do
+ FFISpecs::LibTest.testCallbackVrU16 { 0x7fff }.should == 0x7fff
+ end
+
+ it "returning :ushort (0x8000)" do
+ FFISpecs::LibTest.testCallbackVrU16 { 0x8000 }.should == 0x8000
+ end
+
+ it "returning :ushort (0xffff)" do
+ FFISpecs::LibTest.testCallbackVrU16 { 0xffff }.should == 0xffff
+ end
+
+ it "returning :ushort (-1)" do
+ FFISpecs::LibTest.testCallbackVrU16 { -1 }.should == 0xffff
+ end
+
+ it "returning :int (0)" do
+ FFISpecs::LibTest.testCallbackVrS32 { 0 }.should == 0
+ end
+
+ it "returning :int (0x7fffffff)" do
+ FFISpecs::LibTest.testCallbackVrS32 { 0x7fffffff }.should == 0x7fffffff
+ end
+
+ # test wrap around
+ it "returning :int (-0x80000000)" do
+ FFISpecs::LibTest.testCallbackVrS32 { -0x80000000 }.should == -0x80000000
+ end
+
+ it "returning :int (-1)" do
+ FFISpecs::LibTest.testCallbackVrS32 { -1 }.should == -1
+ end
+
+ it "returning :uint (0)" do
+ FFISpecs::LibTest.testCallbackVrU32 { 0 }.should == 0
+ end
+
+ it "returning :uint (0x7fffffff)" do
+ FFISpecs::LibTest.testCallbackVrU32 { 0x7fffffff }.should == 0x7fffffff
+ end
+
+ # test wrap around
+ it "returning :uint (0x80000000)" do
+ FFISpecs::LibTest.testCallbackVrU32 { 0x80000000 }.should == 0x80000000
+ end
+
+ it "returning :uint (0xffffffff)" do
+ FFISpecs::LibTest.testCallbackVrU32 { 0xffffffff }.should == 0xffffffff
+ end
+
+ it "Callback returning :uint (-1)" do
+ FFISpecs::LibTest.testCallbackVrU32 { -1 }.should == 0xffffffff
+ end
+
+ it "returning :long (0)" do
+ FFISpecs::LibTest.testCallbackVrL { 0 }.should == 0
+ end
+
+ it "returning :long (0x7fffffff)" do
+ FFISpecs::LibTest.testCallbackVrL { 0x7fffffff }.should == 0x7fffffff
+ end
+
+ # test wrap around
+ it "returning :long (-0x80000000)" do
+ FFISpecs::LibTest.testCallbackVrL { -0x80000000 }.should == -0x80000000
+ end
+
+ it "returning :long (-1)" do
+ FFISpecs::LibTest.testCallbackVrL { -1 }.should == -1
+ end
+
+ it "returning :ulong (0)" do
+ FFISpecs::LibTest.testCallbackVrUL { 0 }.should == 0
+ end
+
+ it "returning :ulong (0x7fffffff)" do
+ FFISpecs::LibTest.testCallbackVrUL { 0x7fffffff }.should == 0x7fffffff
+ end
+
+ # test wrap around
+ it "returning :ulong (0x80000000)" do
+ FFISpecs::LibTest.testCallbackVrUL { 0x80000000 }.should == 0x80000000
+ end
+
+ it "returning :ulong (0xffffffff)" do
+ FFISpecs::LibTest.testCallbackVrUL { 0xffffffff }.should == 0xffffffff
+ end
+
+ it "Callback returning :ulong (-1)" do
+ FFISpecs::LibTest.testCallbackVrUL { -1 }.should == 0xffffffff
+ end
+
+ it "returning :long_long (0)" do
+ FFISpecs::LibTest.testCallbackVrS64 { 0 }.should == 0
+ end
+
+ it "returning :long_long (0x7fffffffffffffff)" do
+ FFISpecs::LibTest.testCallbackVrS64 { 0x7fffffffffffffff }.should == 0x7fffffffffffffff
+ end
+
+ # test wrap around
+ it "returning :long_long (-0x8000000000000000)" do
+ FFISpecs::LibTest.testCallbackVrS64 { -0x8000000000000000 }.should == -0x8000000000000000
+ end
+
+ it "returning :long_long (-1)" do
+ FFISpecs::LibTest.testCallbackVrS64 { -1 }.should == -1
+ end
+
+ it "returning :pointer (nil)" do
+ FFISpecs::LibTest.testCallbackVrP { nil }.null?.should be_true
+ end
+
+ it "returning :pointer (FFI::MemoryPointer)" do
+ p = FFI::MemoryPointer.new :long
+ FFISpecs::LibTest.testCallbackVrP { p }.should == p
+ end
+
+ it "global variable" do
+ proc = Proc.new { 0x1e }
+ FFISpecs::LibTest.cbVrS8 = proc
+ FFISpecs::LibTest.testGVarCallbackVrS8(FFISpecs::LibTest.pVrS8).should == 0x1e
+ end
+
+ describe "When the callback is considered optional by the underlying library" do
+ it "should handle receiving 'nil' in place of the closure" do
+ lambda { FFISpecs::LibTest.testOptionalCallbackCrV(nil, 13) }.should_not raise_error
+ end
+ end
+
+ describe 'when inlined' do
+ it 'could be anonymous' do
+ FFISpecs::LibTest.testCallbackVrS8 { 0 }.should == 0
+ end
+ end
+
+ describe "as return value" do
+ it "should not blow up when a callback is defined that returns a callback" do
+ lambda {
+ FFISpecs::LibTest.module_eval do
+ callback :cb_return_type_1, [ :short ], :short
+ callback :cb_lookup_1, [ :short ], :cb_return_type_1
+ attach_function :testReturnsCallback_1, :testReturnsClosure, [ :cb_lookup_1, :short ], :cb_return_type_1
+ end
+ }.should_not raise_error
+ end
+
+ it "should return a callback" do
+ lookup_proc_called = false
+ return_proc_called = false
+
+ return_proc = Proc.new do |a|
+ return_proc_called = true
+ a * 2
+ end
+ lookup_proc = Proc.new do
+ lookup_proc_called = true
+ return_proc
+ end
+
+ val = FFISpecs::LibTest.testReturnsCallback(lookup_proc, 0x1234)
+ val.should == 0x1234 * 2
+ lookup_proc_called.should be_true
+ return_proc_called.should be_true
+ end
+
+ it 'should not blow up when a callback takes a callback as argument' do
+ lambda {
+ FFISpecs::LibTest.module_eval do
+ callback :cb_argument, [ :int ], :int
+ callback :cb_with_cb_argument, [ :cb_argument, :int ], :int
+ attach_function :testCallbackAsArgument, :testArgumentClosure, [ :cb_with_cb_argument, :int ], :int
+ end
+ }.should_not raise_error
+ end
+
+ it 'should be able to use the callback argument' do
+ # TODO: Moving this to fixtures/classes.rb breaks
+ module FFISpecs::LibTest
+ callback :cb_argument, [ :int ], :int
+ callback :cb_with_cb_argument, [ :cb_argument, :int ], :int
+ attach_function :testCallbackAsArgument, :testArgumentClosure, [ :cb_with_cb_argument, :cb_argument, :int ], :int
+ end
+
+ callback_arg_called = false
+ callback_with_callback_arg_called = false
+
+ callback_arg = Proc.new do |val|
+ callback_arg_called = true
+ val * 2
+ end
+ callback_with_callback_arg = Proc.new do |cb, val|
+ callback_with_callback_arg_called = true
+ cb.call(val)
+ end
+
+ val = FFISpecs::LibTest.testCallbackAsArgument(callback_with_callback_arg, callback_arg, 0xff1)
+
+ val.should == 0xff1 * 2
+ callback_arg_called.should be_true
+ callback_with_callback_arg_called.should be_true
+ end
+
+ it 'function returns callable object' do
+ f = FFISpecs::LibTest.testReturnsFunctionPointer
+ f.call(3).should == 6
+ end
+ end
+end
+
+describe "primitive argument" do
+ it ":char (0) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackCrV(0) { |i| v = i }
+ v.should == 0
+ end
+
+ it ":char (127) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackCrV(127) { |i| v = i }
+ v.should == 127
+ end
+
+ it ":char (-128) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackCrV(-128) { |i| v = i }
+ v.should == -128
+ end
+
+ it ":char (-1) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackCrV(-1) { |i| v = i }
+ v.should == -1
+ end
+
+ it ":uchar (0) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackU8rV(0) { |i| v = i }
+ v.should == 0
+ end
+
+ it ":uchar (127) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackU8rV(127) { |i| v = i }
+ v.should == 127
+ end
+
+ it ":uchar (128) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackU8rV(128) { |i| v = i }
+ v.should == 128
+ end
+
+ it ":uchar (255) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackU8rV(255) { |i| v = i }
+ v.should == 255
+ end
+
+ it ":short (0) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackSrV(0) { |i| v = i }
+ v.should == 0
+ end
+
+ it ":short (0x7fff) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackSrV(0x7fff) { |i| v = i }
+ v.should == 0x7fff
+ end
+
+ it ":short (-0x8000) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackSrV(-0x8000) { |i| v = i }
+ v.should == -0x8000
+ end
+
+ it ":short (-1) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackSrV(-1) { |i| v = i }
+ v.should == -1
+ end
+
+ it ":ushort (0) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackU16rV(0) { |i| v = i }
+ v.should == 0
+ end
+
+ it ":ushort (0x7fff) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackU16rV(0x7fff) { |i| v = i }
+ v.should == 0x7fff
+ end
+
+ it ":ushort (0x8000) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackU16rV(0x8000) { |i| v = i }
+ v.should == 0x8000
+ end
+
+ it ":ushort (0xffff) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackU16rV(0xffff) { |i| v = i }
+ v.should == 0xffff
+ end
+
+ it ":int (0) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackIrV(0) { |i| v = i }
+ v.should == 0
+ end
+
+ it ":int (0x7fffffff) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackIrV(0x7fffffff) { |i| v = i }
+ v.should == 0x7fffffff
+ end
+
+ it ":int (-0x80000000) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackIrV(-0x80000000) { |i| v = i }
+ v.should == -0x80000000
+ end
+
+ it ":int (-1) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackIrV(-1) { |i| v = i }
+ v.should == -1
+ end
+
+ it ":uint (0) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackU32rV(0) { |i| v = i }
+ v.should == 0
+ end
+
+ it ":uint (0x7fffffff) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackU32rV(0x7fffffff) { |i| v = i }
+ v.should == 0x7fffffff
+ end
+
+ it ":uint (0x80000000) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackU32rV(0x80000000) { |i| v = i }
+ v.should == 0x80000000
+ end
+
+ it ":uint (0xffffffff) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackU32rV(0xffffffff) { |i| v = i }
+ v.should == 0xffffffff
+ end
+
+ it ":long (0) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackLrV(0) { |i| v = i }
+ v.should == 0
+ end
+
+ it ":long (0x7fffffff) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackLrV(0x7fffffff) { |i| v = i }
+ v.should == 0x7fffffff
+ end
+
+ it ":long (-0x80000000) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackLrV(-0x80000000) { |i| v = i }
+ v.should == -0x80000000
+ end
+
+ it ":long (-1) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackLrV(-1) { |i| v = i }
+ v.should == -1
+ end
+
+ it ":ulong (0) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackULrV(0) { |i| v = i }
+ v.should == 0
+ end
+
+ it ":ulong (0x7fffffff) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackULrV(0x7fffffff) { |i| v = i }
+ v.should == 0x7fffffff
+ end
+
+ it ":ulong (0x80000000) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackULrV(0x80000000) { |i| v = i }
+ v.should == 0x80000000
+ end
+
+ it ":ulong (0xffffffff) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackULrV(0xffffffff) { |i| v = i }
+ v.should == 0xffffffff
+ end
+
+ it ":long_long (0) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackLLrV(0) { |i| v = i }
+ v.should == 0
+ end
+
+ it ":long_long (0x7fffffffffffffff) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackLLrV(0x7fffffffffffffff) { |i| v = i }
+ v.should == 0x7fffffffffffffff
+ end
+
+ it ":long_long (-0x8000000000000000) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackLLrV(-0x8000000000000000) { |i| v = i }
+ v.should == -0x8000000000000000
+ end
+
+ it ":long_long (-1) argument" do
+ v = 0xdeadbeef
+ FFISpecs::LibTest.testCallbackLLrV(-1) { |i| v = i }
+ v.should == -1
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/enum_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/enum_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/enum_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,139 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+describe "A library with no enum defined" do
+ it "returns nil when asked for an enum" do
+ FFISpecs::TestEnum0.enum_type(:foo).should == nil
+ end
+end
+
+describe "An untagged enum" do
+ it "constants can be used as function parameters and return value" do
+ FFISpecs::TestEnum1.test_untagged_enum(:c1).should == 0
+ FFISpecs::TestEnum1.test_untagged_enum(:c2).should == 1
+ FFISpecs::TestEnum1.test_untagged_enum(:c3).should == 2
+ FFISpecs::TestEnum1.test_untagged_enum(:c4).should == 3
+ FFISpecs::TestEnum1.test_untagged_enum(:c5).should == 42
+ FFISpecs::TestEnum1.test_untagged_enum(:c6).should == 43
+ FFISpecs::TestEnum1.test_untagged_enum(:c7).should == 44
+ FFISpecs::TestEnum1.test_untagged_enum(:c8).should == 45
+ FFISpecs::TestEnum1.test_untagged_enum(:c9).should == 42
+ FFISpecs::TestEnum1.test_untagged_enum(:c10).should == 43
+ FFISpecs::TestEnum1.test_untagged_enum(:c11).should == 4242
+ FFISpecs::TestEnum1.test_untagged_enum(:c12).should == 4243
+ FFISpecs::TestEnum1.test_untagged_enum(:c13).should == 42
+ FFISpecs::TestEnum1.test_untagged_enum(:c14).should == 4242
+ FFISpecs::TestEnum1.test_untagged_enum(:c15).should == 424242
+ FFISpecs::TestEnum1.test_untagged_enum(:c16).should == 42424242
+ end
+end
+
+describe "A tagged typedef enum" do
+ it "is accessible through its tag" do
+ FFISpecs::TestEnum3.enum_type(:enum_type1).should_not == nil
+ FFISpecs::TestEnum3.enum_type(:enum_type2).should_not == nil
+ FFISpecs::TestEnum3.enum_type(:enum_type3).should_not == nil
+ FFISpecs::TestEnum3.enum_type(:enum_type4).should_not == nil
+ end
+
+ it "contains enum constants" do
+ FFISpecs::TestEnum3.enum_type(:enum_type1).symbols.length.should == 4
+ FFISpecs::TestEnum3.enum_type(:enum_type2).symbols.length.should == 4
+ FFISpecs::TestEnum3.enum_type(:enum_type3).symbols.length.should == 4
+ FFISpecs::TestEnum3.enum_type(:enum_type4).symbols.length.should == 4
+ end
+
+ it "constants can be used as function parameters and return value" do
+ FFISpecs::TestEnum3.test_tagged_typedef_enum1(:c1).should == :c1
+ FFISpecs::TestEnum3.test_tagged_typedef_enum1(:c2).should == :c2
+ FFISpecs::TestEnum3.test_tagged_typedef_enum1(:c3).should == :c3
+ FFISpecs::TestEnum3.test_tagged_typedef_enum1(:c4).should == :c4
+ FFISpecs::TestEnum3.test_tagged_typedef_enum2(:c5).should == :c5
+ FFISpecs::TestEnum3.test_tagged_typedef_enum2(:c6).should == :c6
+ FFISpecs::TestEnum3.test_tagged_typedef_enum2(:c7).should == :c7
+ FFISpecs::TestEnum3.test_tagged_typedef_enum2(:c8).should == :c8
+ FFISpecs::TestEnum3.test_tagged_typedef_enum3(:c9).should == :c9
+ FFISpecs::TestEnum3.test_tagged_typedef_enum3(:c10).should == :c10
+ FFISpecs::TestEnum3.test_tagged_typedef_enum3(:c11).should == :c11
+ FFISpecs::TestEnum3.test_tagged_typedef_enum3(:c12).should == :c12
+ FFISpecs::TestEnum3.test_tagged_typedef_enum4(:c13).should == :c13
+ FFISpecs::TestEnum3.test_tagged_typedef_enum4(:c14).should == :c14
+ FFISpecs::TestEnum3.test_tagged_typedef_enum4(:c15).should == :c15
+ FFISpecs::TestEnum3.test_tagged_typedef_enum4(:c16).should == :c16
+ end
+end
+
+describe "All enums" do
+ it "have autonumbered constants when defined with names only" do
+ FFISpecs::TestEnum1.enum_value(:c1).should == 0
+ FFISpecs::TestEnum1.enum_value(:c2).should == 1
+ FFISpecs::TestEnum1.enum_value(:c3).should == 2
+ FFISpecs::TestEnum1.enum_value(:c4).should == 3
+
+ FFISpecs::TestEnum3.enum_value(:c1).should == 0
+ FFISpecs::TestEnum3.enum_value(:c2).should == 1
+ FFISpecs::TestEnum3.enum_value(:c3).should == 2
+ FFISpecs::TestEnum3.enum_value(:c4).should == 3
+ end
+
+ it "can have an explicit first constant and autonumbered subsequent constants" do
+ FFISpecs::TestEnum1.enum_value(:c5).should == 42
+ FFISpecs::TestEnum1.enum_value(:c6).should == 43
+ FFISpecs::TestEnum1.enum_value(:c7).should == 44
+ FFISpecs::TestEnum1.enum_value(:c8).should == 45
+
+ FFISpecs::TestEnum3.enum_value(:c5).should == 42
+ FFISpecs::TestEnum3.enum_value(:c6).should == 43
+ FFISpecs::TestEnum3.enum_value(:c7).should == 44
+ FFISpecs::TestEnum3.enum_value(:c8).should == 45
+ end
+
+ it "can have a mix of explicit and autonumbered constants" do
+ FFISpecs::TestEnum1.enum_value(:c9).should == 42
+ FFISpecs::TestEnum1.enum_value(:c10).should == 43
+ FFISpecs::TestEnum1.enum_value(:c11).should == 4242
+ FFISpecs::TestEnum1.enum_value(:c12).should == 4243
+
+ FFISpecs::TestEnum3.enum_value(:c9).should == 42
+ FFISpecs::TestEnum3.enum_value(:c10).should == 43
+ FFISpecs::TestEnum3.enum_value(:c11).should == 4242
+ FFISpecs::TestEnum3.enum_value(:c12).should == 4243
+ end
+
+ it "can have all its constants explicitely valued" do
+ FFISpecs::TestEnum1.enum_value(:c13).should == 42
+ FFISpecs::TestEnum1.enum_value(:c14).should == 4242
+ FFISpecs::TestEnum1.enum_value(:c15).should == 424242
+ FFISpecs::TestEnum1.enum_value(:c16).should == 42424242
+
+ FFISpecs::TestEnum3.enum_value(:c13).should == 42
+ FFISpecs::TestEnum3.enum_value(:c14).should == 4242
+ FFISpecs::TestEnum3.enum_value(:c15).should == 424242
+ FFISpecs::TestEnum3.enum_value(:c16).should == 42424242
+ end
+
+ it "return the constant corresponding to a specific value" do
+ enum = FFISpecs::TestEnum3.enum_type(:enum_type1)
+ enum[0].should == :c1
+ enum[1].should == :c2
+ enum[2].should == :c3
+ enum[3].should == :c4
+
+ enum = FFISpecs::TestEnum3.enum_type(:enum_type2)
+ enum[42].should == :c5
+ enum[43].should == :c6
+ enum[44].should == :c7
+ enum[45].should == :c8
+
+ enum = FFISpecs::TestEnum3.enum_type(:enum_type3)
+ enum[42].should == :c9
+ enum[43].should == :c10
+ enum[4242].should == :c11
+ enum[4243].should == :c12
+
+ enum = FFISpecs::TestEnum3.enum_type(:enum_type4)
+ enum[42].should == :c13
+ enum[4242].should == :c14
+ enum[424242].should == :c15
+ enum[42424242].should == :c16
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/errno_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/errno_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/errno_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,9 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+describe "FFI.errno" do
+ it "FFI.errno contains errno from last function" do
+ FFISpecs::LibTest.setLastError(0)
+ FFISpecs::LibTest.setLastError(0x12345678)
+ FFI.errno.should == 0x12345678
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/Benchmark.c
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/Benchmark.c (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/Benchmark.c 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2007 Wayne Meissner. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/types.h>
+#include <stdint.h>
+
+void returnVoid() {
+
+}
+
+void returnVoidI(int arg) {
+
+}
+int returnInt() {
+ return 0;
+}
+
+int returnIntI(int arg) {
+ return arg;
+}
+
+typedef int8_t s8;
+typedef uint8_t u8;
+typedef int16_t s16;
+typedef uint16_t u16;
+typedef int32_t s32;
+typedef uint32_t u32;
+typedef int64_t s64;
+typedef uint64_t u64;
+typedef float f32;
+typedef double f64;
+typedef void v;
+typedef char* S;
+typedef void* P;
+
+#define B6(R, T1, T2, T3, T4, T5, T6) R bench_##T1##T2##T3##T4##T5##T6##_##R(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) {}
+#define B5(R, T1, T2, T3, T4, T5) R bench_##T1##T2##T3##T4##T5##_##R(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) {}
+#define B4(R, T1, T2, T3, T4) R bench_##T1##T2##T3##T4##_##R(T1 a1, T2 a2, T3 a3, T4 a4) {}
+#define B3(R, T1, T2, T3) R bench_##T1##T2##T3##_##R(T1 a1, T2 a2, T3 a3) {}
+#define B2(R, T1, T2) R bench_##T1##T2##_##R(T1 a1, T2 a2) {}
+#define B1(R, T1) R bench_##T1##_##R(T1 a1) {}
+#define BrV(T) B1(v, T); B2(v, T, T); B3(v, T, T, T); B4(v, T, T, T, T); B5(v, T, T, T, T, T); B6(v, T, T, T, T, T, T);
+BrV(u32);
+BrV(s32);
+BrV(s64);
+BrV(u64);
+BrV(f32);
+BrV(f64);
+BrV(S);
+BrV(P);
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/BufferTest.c
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/BufferTest.c (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/BufferTest.c 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2007 Wayne Meissner
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#define MEMSET(buf, value, size) do { \
+ int i; for (i = 0; i < size; ++i) buf[i] = value; \
+} while(0)
+#define MEMCPY(dst, src, size) do { \
+ int i; for (i = 0; i < size; ++i) dst[i] = src[i]; \
+} while(0)
+
+#define FILL(JTYPE, CTYPE) \
+void fill##JTYPE##Buffer(CTYPE* buf, CTYPE value, int size) { MEMSET(buf, value, size); }
+
+#define COPY(JTYPE, CTYPE) \
+void copy##JTYPE##Buffer(CTYPE* dst, CTYPE* src, int size) { MEMCPY(dst, src, size); }
+
+#define FUNC(JTYPE, CTYPE) \
+ FILL(JTYPE, CTYPE); \
+ COPY(JTYPE, CTYPE)
+
+FUNC(Byte, char);
+FUNC(Short, short);
+FUNC(Int, int);
+FUNC(Long, long long);
+FUNC(Float, float);
+FUNC(Double, double);
+
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/ClosureTest.c
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/ClosureTest.c (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/ClosureTest.c 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2007 Wayne Meissner. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+
+void testClosureVrV(void (*closure)(void))
+{
+ (*closure)();
+}
+char testClosureVrB(char (*closure)(void))
+{
+ return (*closure)();
+}
+short testClosureVrS(short (*closure)(void))
+{
+ return (*closure)();
+}
+int testClosureVrI(int (*closure)(void))
+{
+ return (*closure)();
+}
+long long testClosureVrL(long (*closure)(void))
+{
+ return (*closure)();
+}
+long long testClosureVrLL(long long (*closure)(void))
+{
+ return (*closure)();
+}
+float testClosureVrF(float (*closure)(void))
+{
+ return (*closure)();
+}
+double testClosureVrD(double (*closure)(void))
+{
+ return (*closure)();
+}
+void* testClosureVrP(void* (*closure)(void))
+{
+ return (*closure)();
+}
+void testClosureBrV(void (*closure)(char), char a1)
+{
+ (*closure)(a1);
+}
+void testClosureSrV(void (*closure)(short), short a1)
+{
+ (*closure)(a1);
+}
+void testClosureIrV(void (*closure)(int), int a1)
+{
+ (*closure)(a1);
+}
+void testClosureLrV(void (*closure)(long), long a1)
+{
+ (*closure)(a1);
+}
+void testClosureULrV(void (*closure)(unsigned long), unsigned long a1)
+{
+ (*closure)(a1);
+}
+void testClosureLLrV(void (*closure)(long long), long long a1)
+{
+ (*closure)(a1);
+}
+void testClosureFrV(void (*closure)(float), float a1)
+{
+ (*closure)(a1);
+}
+void testClosureDrV(void (*closure)(double), double a1)
+{
+ (*closure)(a1);
+}
+void testOptionalClosureBrV(void (*closure)(char), char a1)
+{
+ if (closure) {
+ (*closure)(a1);
+ }
+}
+
+struct s8f32s32 {
+ char s8;
+ float f32;
+ int s32;
+};
+
+// Takes a struct argument
+void testClosureTrV(void (*closure)(struct s8f32s32 s), struct s8f32s32* s)
+{
+ (*closure)(*s);
+}
+
+// Returns a struct value
+struct s8f32s32 testClosureVrT(struct s8f32s32 (*closure)())
+{
+ return (*closure)();
+}
+
+typedef int (*returnTypeClosure_t)(int) ;
+typedef returnTypeClosure_t (*lookupClosure_t)();
+
+int testReturnsClosure(lookupClosure_t lookup, int val)
+{
+ returnTypeClosure_t func = lookup ? (*lookup)() : NULL;
+ return func ? (*func)(val) : 0;
+}
+
+static int multiplyByTwo(int value)
+{
+ return value * 2;
+}
+
+returnTypeClosure_t testReturnsFunctionPointer()
+{
+ return multiplyByTwo;
+}
+
+typedef int (*argumentClosure_t)(int);
+typedef int (*withArgumentClosure_t)(argumentClosure_t, int);
+
+int testArgumentClosure(withArgumentClosure_t closure_with, argumentClosure_t closure_arg, int val)
+{
+ return (*closure_with)(closure_arg, val);
+}
+
+
+//
+// These macros produce functions of the form:
+// testClosureBIrV(void (*closure)(char, int), char a1, int a2) {}
+//
+#define C2_(J1, J2, N1, N2) \
+void testClosure##J1##J2##rV(void (*closure)(N1, N2), N1 a1, N2 a2) \
+{ \
+ (*closure)(a1, a2); \
+}
+
+#define C2(J, N) \
+ C2_(B, J, char, N) \
+ C2_(S, J, short, N) \
+ C2_(I, J, int, N) \
+ C2_(LL, J, long long, N) \
+ C2_(F, J, float, N) \
+ C2_(D, J, double, N) \
+
+
+C2(B, char);
+C2(S, short);
+C2(I, int);
+C2(LL, long long);
+C2(F, float);
+C2(D, double);
+
+#define C3_(J1, J2, J3, N1, N2, N3) \
+void testClosure##J1##J2##J3##rV(void (*closure)(N1, N2, N3), N1 a1, N2 a2, N3 a3) \
+{ \
+ (*closure)(a1, a2, a3); \
+}
+
+
+#define C3(J, N) \
+ C3_(B, J, B, char, N, char) \
+ C3_(S, J, S, short, N, short) \
+ C3_(I, J, I, int, N, int) \
+ C3_(LL, J, LL, long long, N, long long) \
+ C3_(F, J, F, float, N, float) \
+ C3_(D, J, D, double, N, double) \
+
+C3(B, char);
+C3(S, short);
+C3(I, int);
+C3(LL, long long);
+C3(F, float);
+C3(D, double);
+C3_(B, S, I, char, short, int);
+C3_(B, S, LL, char, short, long long);
+C3_(LL, S, B, long long, short, char);
+C3_(LL, B, S, long long, char, short);
+
+
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/EnumTest.c
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/EnumTest.c (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/EnumTest.c 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2007 Wayne Meissner. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+int test_untagged_enum(int val) {
+ return val;
+}
+
+int test_untagged_typedef_enum(int val) {
+ return val;
+}
+
+typedef enum {c1, c2, c3, c4} enum_type1;
+enum_type1 test_tagged_typedef_enum1(enum_type1 val) {
+ return val;
+}
+
+typedef enum {c5 = 42, c6, c7, c8} enum_type2;
+enum_type2 test_tagged_typedef_enum2(enum_type2 val) {
+ return val;
+}
+
+typedef enum {c9 = 42, c10, c11 = 4242, c12} enum_type3;
+enum_type3 test_tagged_typedef_enum3(enum_type3 val) {
+ return val;
+}
+
+typedef enum {c13 = 42, c14 = 4242, c15 = 424242, c16 = 42424242} enum_type4;
+enum_type4 test_tagged_typedef_enum4(enum_type4 val) {
+ return val;
+}
+
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/GNUmakefile
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/GNUmakefile (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/GNUmakefile 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,121 @@
+# -*- makefile -*-
+OS = $(shell uname -s | tr '[:upper:]' '[:lower:]')
+CPU = $(shell uname -m | sed -e 's/i[345678]86/i386/')
+MODEL = 32 # Default to 32bit compiles
+PLATFORM = $(CPU)-$(OS)
+ifeq ($(OS), sunos)
+ OS = solaris
+endif
+
+SRC_DIR = fixtures
+BUILD_DIR ?= build
+TEST_BUILD_DIR = $(SRC_DIR)/$(BUILD_DIR)/libtest
+# Set defaults to unix (linux/solaris/bsd)
+PREFIX = lib
+LIBEXT = so
+LIBNAME = $(PREFIX)test.$(LIBEXT)
+
+export MACOSX_DEPLOYMENT_TARGET=10.4
+
+ifeq ($(OS),linux)
+CCACHE := $(shell /usr/bin/which ccache)
+endif
+
+TEST_SRCS = $(wildcard $(SRC_DIR)/*.c)
+TEST_OBJS := $(patsubst $(SRC_DIR)/%.c, $(TEST_BUILD_DIR)/%.o, $(TEST_SRCS))
+
+#
+# Compiler/linker flags from:
+# http://weblogs.java.net/blog/kellyohair/archive/2006/01/compilation_of_1.html
+JFLAGS = -fno-omit-frame-pointer -fno-strict-aliasing
+OFLAGS = -O2 $(JFLAGS)
+WFLAGS = -W -Werror -Wall -Wno-unused -Wno-parentheses
+PICFLAGS = -fPIC
+SOFLAGS = -shared -mimpure-text -Wl,-O1
+LDFLAGS += $(SOFLAGS)
+
+IFLAGS = -I"$(BUILD_DIR)"
+CFLAGS = $(OFLAGS) $(WFLAGS) $(IFLAGS) $(PICFLAGS) -D_REENTRANT
+
+ifeq ($(OS), win32)
+ CC += -mno-cygwin
+ LDFLAGS += -mno-cygwin -Wl,--add-stdcall-alias
+endif
+ifeq ($(OS), darwin)
+ ARCHFLAGS = -arch ppc
+ ifeq ($(CPU),i386)
+ ARCHFLAGS += -arch i386 -arch x86_64
+ endif
+ CFLAGS += $(ARCHFLAGS) -isysroot /Developer/SDKs/MacOSX10.4u.sdk -DTARGET_RT_MAC_CFM=0
+ CFLAGS += -fno-common
+ LDFLAGS = $(ARCHFLAGS) -dynamiclib -Wl,-syslibroot,$(SDKROOT) -mmacosx-version-min=10.4
+ # link against the universal libraries on ppc machines
+ LDFLAGS += -L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib
+ LIBEXT = dylib
+ FFI_CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk
+ PICFLAGS =
+ SOFLAGS =
+endif
+
+ifeq ($(OS), linux)
+ SOFLAGS += -Wl,-soname,$(LIBNAME)
+endif
+
+ifeq ($(OS), solaris)
+ CC = /usr/sfw/bin/gcc -std=c99
+ LD = /usr/ccs/bin/ld
+ SOFLAGS = -shared -static-libgcc
+endif
+
+ifeq ($(OS), aix)
+ LIBEXT = a
+ SOFLAGS = -shared -static-libgcc
+ PICFLAGS += -pthread
+endif
+
+ifneq ($(findstring cygwin, $(OS)),)
+ CFLAGS += -mno-cygwin -mwin32
+ LIBEXT = dll
+# PREFIX =
+ PICFLAGS=
+endif
+ifneq ($(findstring mingw, $(OS)),)
+ LIBEXT = dll
+ PICFLAGS=
+endif
+ifeq ($(CPU), sparcv9)
+ MODEL = 64
+endif
+
+ifeq ($(CPU), amd64)
+ MODEL = 64
+endif
+
+ifeq ($(CPU), x86_64)
+ MODEL = 64
+endif
+
+# On platforms (linux, solaris) that support both 32bit and 64bit, force building for one or the other
+ifneq ($(or $(findstring linux, $(OS)), $(findstring solaris, $(OS))),)
+ # Change the CC/LD instead of CFLAGS/LDFLAGS, incase other things in the flags
+ # makes the libffi build choke
+ CC += -m$(MODEL)
+ LD += -m$(MODEL)
+endif
+
+LIBTEST = $(TEST_BUILD_DIR)/$(LIBNAME)
+
+all: $(LIBTEST)
+
+$(TEST_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
+ @mkdir -p $(@D)
+ $(CCACHE) $(CC) $(CFLAGS) -c $< -o $@
+
+$(LIBTEST): $(TEST_OBJS)
+ $(CC) -o $@ $(LDFLAGS) $(TEST_OBJS) -lm
+
+clean::
+ # nothing to do - ant will delete the build dir
+
+debug::
+ @echo "SRCS=$(TEST_SRCS)"
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/GlobalVariable.c
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/GlobalVariable.c (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/GlobalVariable.c 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,36 @@
+#include <sys/types.h>
+#include <stdint.h>
+
+typedef int8_t s8;
+typedef uint8_t u8;
+typedef int16_t s16;
+typedef uint16_t u16;
+typedef int32_t s32;
+typedef uint32_t u32;
+typedef int64_t s64;
+typedef uint64_t u64;
+typedef signed long sL;
+typedef unsigned long uL;
+typedef float f32;
+typedef double f64;
+typedef unsigned long ulong;
+typedef void* pointer;
+typedef void* P;
+
+#define GVAR(T) \
+ extern T gvar_##T; \
+ T gvar_##T = (T) -1; \
+ T gvar_##T##_get() { return gvar_##T; }; \
+ void gvar_##T##_set(T v) { gvar_##T = v; }
+
+GVAR(s8);
+GVAR(u8);
+GVAR(s16);
+GVAR(u16);
+GVAR(s32);
+GVAR(u32);
+GVAR(s64);
+GVAR(u64);
+GVAR(long);
+GVAR(ulong);
+GVAR(pointer);
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/LastErrorTest.c
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/LastErrorTest.c (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/LastErrorTest.c 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2008 Wayne Meissner. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#if defined(_WIN32) || defined(__WIN32__)
+# include <windows.h>
+#else
+# include <errno.h>
+#endif
+
+int setLastError(int error) {
+#if defined(_WIN32) || defined(__WIN32__)
+ SetLastError(error);
+#else
+ errno = error;
+#endif
+ return -1;
+}
+
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/NumberTest.c
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/NumberTest.c (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/NumberTest.c 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2007 Wayne Meissner. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+
+#ifdef __sparc
+ #define fix_mem_access __asm("ta 6")
+#else
+ #define fix_mem_access
+#endif
+
+typedef int8_t s8;
+typedef uint8_t u8;
+typedef int16_t s16;
+typedef uint16_t u16;
+typedef int32_t s32;
+typedef uint32_t u32;
+typedef int64_t s64;
+typedef uint64_t u64;
+typedef signed long sL;
+typedef unsigned long uL;
+typedef float f32;
+typedef double f64;
+typedef unsigned long ulong;
+
+#define ADD(T) T add_##T(T arg1, T arg2) { return arg1 + arg2; }
+#define SUB(T) T sub_##T(T arg1, T arg2) { return arg1 - arg2; }
+#define MUL(T) T mul_##T(T arg1, T arg2) { return arg1 * arg2; }
+#define DIV(T) T div_##T(T arg1, T arg2) { return arg1 / arg2; }
+#define RET(T) T ret_##T(T arg1) { return arg1; }
+#define SET(T) static T T##_;void set_##T(T arg1) { T##_ = arg1; }
+#define GET(T) T get_##T() { return T##_; }
+typedef char* ptr;
+#define TEST(T) ADD(T) SUB(T) MUL(T) DIV(T) RET(T) SET(T) GET(T)
+TEST(s8);
+TEST(u8);
+TEST(s16);
+TEST(u16);
+TEST(s32);
+TEST(u32);
+TEST(s64);
+TEST(u64);
+TEST(float);
+TEST(double);
+TEST(long);
+TEST(ulong);
+
+#define ADD2(R, T1, T2) R add_##T1##T2##_##R(T1 arg1, T2 arg2) { return arg1 + arg2; }
+#define SUB2(R, T1, T2) R sub_##T1##T2##_##R(T1 arg1, T2 arg2) { return arg1 - arg2; }
+#define MUL2(R, T1, T2) R mul_##T1##T2##_##R(T1 arg1, T2 arg2) { return arg1 * arg2; }
+#define DIV2(R, T1, T2) R div_##T1##T2##_##R(T1 arg1, T2 arg2) { return arg1 / arg2; }
+
+#define T2__(R, T1, T2) ADD2(R, T1, T2) SUB2(R, T1, T2) MUL2(R, T1, T2) DIV2(R, T1, T2)
+#define T2_(R, T1) \
+ T2__(R, T1, s8) T2__(R, T1, u8) \
+ T2__(R, T1, s16) T2__(R, T1, u16) \
+ T2__(R, T1, s32) T2__(R, T1, u32) \
+ T2__(R, T1, sL) T2__(R, T1, uL) \
+ T2__(R, T1, s64) T2__(R, T1, u64) \
+
+#define TEST2(R) \
+ T2_(R, s8) T2_(R, u8) T2_(R, s16) T2_(R, u16) T2_(R, s32) T2_(R, u32) \
+ T2_(R, sL) T2_(R, uL) T2_(R, s64) T2_(R, u64)
+
+#ifdef notyet
+TEST2(s32)
+TEST2(u32)
+TEST2(s64)
+TEST2(u64)
+#endif
+
+#define ADD3(R, T1, T2, T3) R add_##T1##T2##T3##_##R(T1 arg1, T2 arg2, T3 arg3) { return arg1 + arg2 + arg3; }
+#define pack_f32(buf, v) do { *(float *)(buf) = v; } while(0)
+#define pack_f64(buf, v) do { *(double *)(buf) = v; } while(0)
+#define pack_int(buf, v) do { *(buf) = v; } while(0)
+#define pack_s8 pack_int
+#define pack_u8 pack_int
+#define pack_s16 pack_int
+#define pack_u16 pack_int
+#define pack_s32 pack_int
+#define pack_u32 pack_int
+#define pack_s64 pack_int
+#define pack_u64 pack_int
+#define pack_sL pack_int
+#define pack_uL pack_int
+
+#define PACK3(R, T1, T2, T3) void pack_##T1##T2##T3##_##R(T1 arg1, T2 arg2, T3 arg3, R* r) { \
+ fix_mem_access; \
+ pack_##T1(&r[0], arg1); \
+ pack_##T2(&r[1], arg2); \
+ pack_##T3(&r[2], arg3); \
+}
+
+#define T3___(R, T1, T2, T3) PACK3(R, T1, T2, T3) /* SUB2(R, T1, T2) MUL2(R, T1, T2) DIV2(R, T1, T2) */
+#define T3__(R, T1, T2) \
+ T3___(R, T1, T2, s8) T3___(R, T1, T2, u8) \
+ T3___(R, T1, T2, s16) T3___(R, T1, T2, u16) \
+ T3___(R, T1, T2, s32) T3___(R, T1, T2, u32) \
+ T3___(R, T1, T2, sL) T3___(R, T1, T2, uL) \
+ T3___(R, T1, T2, s64) T3___(R, T1, T2, u64) \
+ T3___(R, T1, T2, f32) T3___(R, T1, T2, f64) \
+
+#define T3_(R, T1) \
+ T3__(R, T1, s8) T3__(R, T1, u8) \
+ T3__(R, T1, s16) T3__(R, T1, u16) \
+ T3__(R, T1, s32) T3__(R, T1, u32) \
+ T3__(R, T1, sL) T3__(R, T1, uL) \
+ T3__(R, T1, s64) T3__(R, T1, u64) \
+ T3__(R, T1, f32) T3__(R, T1, f64) \
+
+#define TEST3(R) \
+ T3_(R, s8) T3_(R, u8) T3_(R, s16) T3_(R, u16) T3_(R, s32) T3_(R, u32) \
+ T3_(R, sL) T3_(R, uL) T3_(R, s64) T3_(R, u64) T3_(R, f32) T3_(R, f64)
+
+TEST3(s64)
+
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/PointerTest.c
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/PointerTest.c (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/PointerTest.c 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2007 Wayne Meissner. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+typedef void* ptr;
+typedef void* pointer;
+#ifdef _WIN32
+typedef char* caddr_t;
+#endif
+
+#define RET(T) T ptr_ret_##T(void* arg1, int offset) { \
+ T tmp; memcpy(&tmp, (caddr_t) arg1 + offset, sizeof(tmp)); return tmp; \
+}
+#define SET(T) void ptr_set_##T(void* arg1, int offset, T value) { \
+ memcpy((caddr_t) arg1 + offset, &value, sizeof(value)); \
+}
+#define TEST(T) SET(T) RET(T)
+
+TEST(int8_t);
+TEST(int16_t);
+TEST(int32_t);
+TEST(int64_t);
+TEST(float);
+TEST(double);
+TEST(pointer);
+
+void*
+ptr_return_array_element(void **ptrArray, int arrayIndex)
+{
+ return ptrArray[arrayIndex];
+}
+
+void
+ptr_set_array_element(void **ptrArray, int arrayIndex, void *value)
+{
+ ptrArray[arrayIndex] = value;
+}
+
+void*
+ptr_malloc(int size)
+{
+ return calloc(1, size);
+}
+void
+ptr_free(void* ptr)
+{
+ free(ptr);
+}
+
+void*
+ptr_from_address(uintptr_t addr)
+{
+ return (void *) addr;
+}
+
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/ReferenceTest.c
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/ReferenceTest.c (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/ReferenceTest.c 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007 Wayne Meissner. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdint.h>
+
+#define REF(T) void ref_##T(T arg, T* result) { *result = arg; }
+#define ADD(T) void ref_add_##T(T arg1, T arg2, T* result) { *result = arg1 + arg2; }
+#define SUB(T) void ref_sub_##T(T arg1, T arg2, T* result) { *result = arg1 - arg2; }
+#define MUL(T) void ref_mul_##T(T arg1, T arg2, T* result) { *result = arg1 * arg2; }
+#define DIV(T) void ref_div_##T(T arg1, T arg2, T* result) { *result = arg1 / arg2; }
+#define TEST(T) ADD(T) SUB(T) MUL(T) DIV(T) REF(T)
+
+TEST(int8_t);
+TEST(int16_t);
+TEST(int32_t);
+TEST(int64_t);
+TEST(float);
+TEST(double);
+
+
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/StringTest.c
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/StringTest.c (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/StringTest.c 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007 Wayne Meissner. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <string.h>
+
+int
+string_equals(const char* s1, const char* s2)
+{
+ return strcmp(s1, s2) == 0;
+}
+
+void
+string_set(char* s1, const char* s2)
+{
+ strcpy(s1, s2);
+}
+void
+string_concat(char* dst, const char* src)
+{
+ strcat(dst, src);
+}
+void
+string_dummy(char* dummy)
+{
+}
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/StructTest.c
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/StructTest.c (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/StructTest.c 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,217 @@
+/*
+ * Copyright (c) 2007 Wayne Meissner. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <string.h>
+
+typedef char s8;
+typedef short s16;
+typedef int s32;
+typedef long long s64;
+typedef float f32;
+typedef double f64;
+
+typedef struct bugged_struct {
+ unsigned char visible;
+ unsigned int x;
+ unsigned int y;
+ short rx;
+ short ry;
+ unsigned char order;
+ unsigned char size;
+} bugged_struct_t;
+
+unsigned int
+bugged_struct_size() {
+ return sizeof(bugged_struct_t);
+}
+
+struct test1 {
+ char b;
+ short s;
+ int i;
+ long long j;
+ long l;
+ float f;
+ double d;
+ char string[32];
+};
+
+struct struct_with_array {
+ char c;
+ int a[5];
+};
+
+struct nested {
+ int i;
+};
+
+struct container {
+ char first;
+ struct nested s;
+};
+
+int
+struct_align_nested_struct(struct container* a) { return a->s.i; }
+
+void*
+struct_field_array(struct struct_with_array* s) { return &s->a; }
+
+struct container*
+struct_make_container_struct(int i)
+{
+ static struct container cs;
+ memset(&cs, 0, sizeof(cs));
+ cs.first = 1;
+ cs.s.i = i;
+ return &cs;
+}
+
+#define T(x, type) \
+ type struct_field_##type(struct test1* t) { return t->x; } \
+ struct type##_align { char first; type value; }; \
+ type struct_align_##type(struct type##_align* a) { return a->value; }
+
+T(b, s8);
+T(s, s16);
+T(i, s32);
+T(j, s64);
+T(f, f32);
+T(d, f64);
+T(l, long);
+
+void
+struct_set_string(struct test1* t, char* s)
+{
+ strcpy(t->string, s);
+}
+
+struct test1*
+struct_make_struct(char b, short s, int i, long long ll, float f, double d)
+{
+ static struct test1 t;
+ memset(&t, 0, sizeof(t));
+ t.b = b;
+ t.s = s;
+ t.i = i;
+ t.j = ll;
+ t.f = f;
+ t.d = d;
+ return &t;
+}
+
+typedef int (*add_cb)(int a1, int a2);
+typedef int (*sub_cb)(int a1, int a2);
+struct test2 {
+ add_cb add_callback;
+ sub_cb sub_callback;
+};
+
+int
+struct_call_add_cb(struct test2* t, int a1, int a2)
+{
+ return t->add_callback(a1, a2);
+}
+
+int
+struct_call_sub_cb(struct test2* t, int a1, int a2)
+{
+ return t->sub_callback(a1, a2);
+}
+
+
+struct struct_with_array*
+struct_make_struct_with_array(int a_0, int a_1, int a_2, int a_3, int a_4)
+{
+ static struct struct_with_array s;
+
+ memset(&s, 0, sizeof(s));
+
+ s.a[0] = a_0;
+ s.a[1] = a_1;
+ s.a[2] = a_2;
+ s.a[3] = a_3;
+ s.a[4] = a_4;
+
+ return &s;
+
+}
+
+struct s8s32 {
+ char s8;
+ int s32;
+};
+
+struct s8s32
+struct_return_s8s32()
+{
+ struct s8s32 s;
+ s.s8 = 0x7f;
+ s.s32 = 0x12345678;
+
+ return s;
+}
+
+struct s8s32
+struct_s8s32_set(char s8, int s32)
+{
+ struct s8s32 s;
+
+ s.s8 = s8;
+ s.s32 = s32;
+
+ return s;
+}
+
+int
+struct_s8s32_get_s8(struct s8s32 s)
+{
+ return s.s8;
+}
+
+int
+struct_s8s32_get_s32(struct s8s32 s)
+{
+ return s.s32;
+}
+
+// Pass a struct and an int arg, ensure the int arg is passed correctly
+int
+struct_s8s32_s32_ret_s32(struct s8s32 s, int s32)
+{
+ return s32;
+}
+
+// Pass a struct and a long long arg, ensure the long long arg is passed correctly
+long long
+struct_s8s32_s64_ret_s64(struct s8s32 s, long long s64)
+{
+ return s64;
+}
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/UnionTest.c
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/UnionTest.c (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/UnionTest.c 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2007 Wayne Meissner. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+typedef char s8;
+typedef short s16;
+typedef int s32;
+typedef long long s64;
+typedef float f32;
+typedef double f64;
+
+typedef union union_test {
+ char b;
+ short s;
+ int i;
+ long long j;
+ long l;
+ float f;
+ double d;
+ s8 a[10];
+} union_test_t;
+
+#define T(x, type) \
+ type union_align_##type(union_test_t* u) { return u->x; } \
+ union_test_t* union_make_union_with_##type(type value) { static union_test_t u; u.x = value; return &u; }
+
+T(b, s8);
+T(s, s16);
+T(i, s32);
+T(j, s64);
+T(f, f32);
+T(d, f64);
+T(l, long);
+
+unsigned int union_size() { return sizeof(union_test_t); }
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/VariadicTest.c
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/VariadicTest.c (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/VariadicTest.c 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,57 @@
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdarg.h>
+
+typedef int8_t s8;
+typedef uint8_t u8;
+typedef int16_t s16;
+typedef uint16_t u16;
+typedef int32_t s32;
+typedef uint32_t u32;
+typedef int64_t s64;
+typedef uint64_t u64;
+typedef signed long sL;
+typedef unsigned long uL;
+typedef float F;
+typedef double D;
+
+void pack_varargs(s64* buf, const char* fmt, ...)
+{
+ va_list ap;
+ int c;
+ double d;
+ va_start(ap, fmt);
+ while ((c = *fmt++)) {
+ switch (c) {
+ case 'c':
+ case 's':
+ case 'i':
+ *buf++ = va_arg(ap, s32);
+ break;
+ case 'l':
+ *buf++ = va_arg(ap, long);
+ break;
+ case 'j':
+ *buf++ = va_arg(ap, s64);
+ break;
+ case 'f':
+ case 'd':
+ d = va_arg(ap, double);
+ memcpy(buf++, &d, sizeof(d));
+ break;
+ case 'C':
+ case 'S':
+ case 'I':
+ *buf++ = va_arg(ap, u32);
+ break;
+ case 'L':
+ *buf++ = va_arg(ap, unsigned long);
+ break;
+ }
+ }
+ va_end(ap);
+}
+
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/classes.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/classes.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/fixtures/classes.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,438 @@
+module FFISpecs
+ #
+ # Callback fixtures
+ #
+ module LibTest
+ callback :cbVrS8, [ ], :char
+ callback :cbVrU8, [ ], :uchar
+ callback :cbVrS16, [ ], :short
+ callback :cbVrU16, [ ], :ushort
+ callback :cbVrS32, [ ], :int
+ callback :cbVrU32, [ ], :uint
+ callback :cbVrL, [ ], :long
+ callback :cbVrUL, [ ], :ulong
+ callback :cbVrS64, [ ], :long_long
+ callback :cbVrU64, [ ], :ulong_long
+ callback :cbVrP, [], :pointer
+ callback :cbCrV, [ :char ], :void
+ callback :cbSrV, [ :short ], :void
+ callback :cbIrV, [ :int ], :void
+ callback :cbLrV, [ :long ], :void
+ callback :cbULrV, [ :ulong ], :void
+ callback :cbLrV, [ :long_long ], :void
+
+ attach_function :testCallbackVrS8, :testClosureVrB, [ :cbVrS8 ], :char
+ attach_function :testCallbackVrU8, :testClosureVrB, [ :cbVrU8 ], :uchar
+ attach_function :testCallbackVrS16, :testClosureVrS, [ :cbVrS16 ], :short
+ attach_function :testCallbackVrU16, :testClosureVrS, [ :cbVrU16 ], :ushort
+ attach_function :testCallbackVrS32, :testClosureVrI, [ :cbVrS32 ], :int
+ attach_function :testCallbackVrU32, :testClosureVrI, [ :cbVrU32 ], :uint
+ attach_function :testCallbackVrL, :testClosureVrL, [ :cbVrL ], :long
+ attach_function :testCallbackVrUL, :testClosureVrL, [ :cbVrUL ], :ulong
+ attach_function :testCallbackVrS64, :testClosureVrLL, [ :cbVrS64 ], :long_long
+ attach_function :testCallbackVrU64, :testClosureVrLL, [ :cbVrU64 ], :ulong_long
+ attach_function :testCallbackVrP, :testClosureVrP, [ :cbVrP ], :pointer
+ attach_function :testCallbackCrV, :testClosureBrV, [ :cbCrV, :char ], :void
+ attach_variable :cbVrS8, :gvar_pointer, :cbVrS8
+ attach_variable :pVrS8, :gvar_pointer, :pointer
+ attach_function :testGVarCallbackVrS8, :testClosureVrB, [ :pointer ], :char
+ attach_function :testOptionalCallbackCrV, :testOptionalClosureBrV, [ :cbCrV, :char ], :void
+
+ attach_function :testCallbackVrS8, :testClosureVrB, [ callback([ ], :char) ], :char
+
+ callback :cb_return_type, [ :int ], :int
+ callback :cb_lookup, [ ], :cb_return_type
+ attach_function :testReturnsCallback, :testReturnsClosure, [ :cb_lookup, :int ], :int
+
+ callback :funcptr, [ :int ], :int
+ attach_function :testReturnsFunctionPointer, [ ], :funcptr
+
+ callback :cbS8rV, [ :char ], :void
+ callback :cbU8rV, [ :uchar ], :void
+ callback :cbS16rV, [ :short ], :void
+ callback :cbU16rV, [ :ushort ], :void
+
+ callback :cbS32rV, [ :int ], :void
+ callback :cbU32rV, [ :uint ], :void
+
+ callback :cbLrV, [ :long ], :void
+ callback :cbULrV, [ :ulong ], :void
+
+ callback :cbS64rV, [ :long_long ], :void
+ attach_function :testCallbackCrV, :testClosureBrV, [ :cbS8rV, :char ], :void
+ attach_function :testCallbackU8rV, :testClosureBrV, [ :cbU8rV, :uchar ], :void
+ attach_function :testCallbackSrV, :testClosureSrV, [ :cbS16rV, :short ], :void
+ attach_function :testCallbackU16rV, :testClosureSrV, [ :cbU16rV, :ushort ], :void
+ attach_function :testCallbackIrV, :testClosureIrV, [ :cbS32rV, :int ], :void
+ attach_function :testCallbackU32rV, :testClosureIrV, [ :cbU32rV, :uint ], :void
+
+ attach_function :testCallbackLrV, :testClosureLrV, [ :cbLrV, :long ], :void
+ attach_function :testCallbackULrV, :testClosureULrV, [ :cbULrV, :ulong ], :void
+
+ attach_function :testCallbackLLrV, :testClosureLLrV, [ :cbS64rV, :long_long ], :void
+ end
+
+ #
+ # Enum fixtures
+ #
+ module TestEnum0
+ extend FFI::Library
+ end
+
+ module TestEnum1
+ extend FFI::Library
+ ffi_lib LIBRARY
+
+ enum [:c1, :c2, :c3, :c4]
+ enum [:c5, 42, :c6, :c7, :c8]
+ enum [:c9, 42, :c10, :c11, 4242, :c12]
+ enum [:c13, 42, :c14, 4242, :c15, 424242, :c16, 42424242]
+
+ attach_function :test_untagged_enum, [:int], :int
+ end
+
+ module TestEnum3
+ extend FFI::Library
+ ffi_lib LIBRARY
+
+ enum :enum_type1, [:c1, :c2, :c3, :c4]
+ enum :enum_type2, [:c5, 42, :c6, :c7, :c8]
+ enum :enum_type3, [:c9, 42, :c10, :c11, 4242, :c12]
+ enum :enum_type4, [:c13, 42, :c14, 4242, :c15, 424242, :c16, 42424242]
+
+ attach_function :test_tagged_typedef_enum1, [:enum_type1], :enum_type1
+ attach_function :test_tagged_typedef_enum2, [:enum_type2], :enum_type2
+ attach_function :test_tagged_typedef_enum3, [:enum_type3], :enum_type3
+ attach_function :test_tagged_typedef_enum4, [:enum_type4], :enum_type4
+ end
+
+ #
+ # Errno fixtures
+ #
+ module LibTest
+ attach_function :setLastError, [ :int ], :void
+ end
+
+ #
+ # ManagedStruct fixtures
+ #
+ module LibTest
+ attach_function :ptr_from_address, [ FFI::Platform::ADDRESS_SIZE == 32 ? :uint : :ulong_long ], :pointer
+ end
+
+ class NoRelease < ManagedStruct
+ layout :i, :int
+ end
+
+ class WhatClassAmI < ManagedStruct
+ layout :i, :int
+ def self.release; end
+ end
+
+ class PleaseReleaseMe < ManagedStruct
+ layout :i, :int
+ @@count = 0
+ def self.release
+ @@count += 1
+ end
+ def self.wait_gc(count)
+ loop = 5
+ while loop > 0 && @@count < count
+ loop -= 1
+ if RUBY_PLATFORM =~ /java/
+ require 'java'
+ java.lang.System.gc
+ else
+ GC.start
+ end
+ sleep 0.05 if @@count < count
+ end
+ end
+ end
+
+ #
+ # Number fixtures
+ #
+ module LibTest
+ attach_function :ret_s8, [ :char ], :char
+ attach_function :ret_u8, [ :uchar ], :uchar
+ attach_function :ret_s16, [ :short ], :short
+ attach_function :ret_u16, [ :ushort ], :ushort
+ attach_function :ret_s32, [ :int ], :int
+ attach_function :ret_u32, [ :uint ], :uint
+ attach_function :ret_s64, [ :long_long ], :long_long
+ attach_function :ret_u64, [ :ulong_long ], :ulong_long
+ attach_function :ret_long, [ :long ], :long
+ attach_function :ret_ulong, [ :ulong ], :ulong
+ attach_function :set_s8, [ :char ], :void
+ attach_function :get_s8, [ ], :char
+ attach_function :set_float, [ :float ], :void
+ attach_function :get_float, [ ], :float
+ attach_function :set_double, [ :double ], :void
+ attach_function :get_double, [ ], :double
+ end
+
+ PACK_VALUES = {
+ 's8' => [ 0x12 ],
+ 'u8' => [ 0x34 ],
+ 's16' => [ 0x5678 ],
+ 'u16' => [ 0x9abc ],
+ 's32' => [ 0x7654321f ],
+ 'u32' => [ 0xfee1babe ],
+ 'sL' => [ 0x1f2e3d4c ],
+ 'uL' => [ 0xf7e8d9ca ],
+ 's64' => [ 0x1eafdeadbeefa1b2 ],
+ #'f32' => [ 1.234567 ], # TODO: Why is this disabled?
+ 'f64' => [ 9.87654321 ]
+ }
+
+ TYPE_MAP = {
+ 's8' => :char, 'u8' => :uchar, 's16' => :short, 'u16' => :ushort,
+ 's32' => :int, 'u32' => :uint, 's64' => :long_long, 'u64' => :ulong_long,
+ 'sL' => :long, 'uL' => :ulong, 'f32' => :float, 'f64' => :double
+ }
+ TYPES = TYPE_MAP.keys
+
+ module LibTest
+ [ 's32', 'u32', 's64', 'u64' ].each do |rt|
+ TYPES.each do |t1|
+ TYPES.each do |t2|
+ TYPES.each do |t3|
+ begin
+ attach_function "pack_#{t1}#{t2}#{t3}_#{rt}",
+ [ TYPE_MAP[t1], TYPE_MAP[t2], TYPE_MAP[t3], :buffer_out ], :void
+ rescue FFI::NotFoundError
+ end
+ end
+ end
+ end
+ end
+ end
+
+ #
+ # Pointer fixtures
+ #
+ module LibTest
+ attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int
+ attach_function :ptr_from_address, [ FFI::Platform::ADDRESS_SIZE == 32 ? :uint : :ulong_long ], :pointer
+ attach_function :ptr_set_pointer, [ :pointer, :int, :pointer ], :void
+ end
+
+ class ToPtrTest
+ def initialize(ptr)
+ @ptr = ptr
+ end
+ def to_ptr
+ @ptr
+ end
+ end
+
+ require 'delegate'
+ class PointerDelegate < DelegateClass(FFI::Pointer)
+ def initialize(ptr)
+ super
+ @ptr = ptr
+ end
+ def to_ptr
+ @ptr
+ end
+ end
+
+ class AutoPointerTestHelper
+ @@count = 0
+ def self.release
+ @@count += 1 if @@count > 0
+ end
+ def self.reset
+ @@count = 0
+ end
+ def self.gc_everything(count)
+ loop = 5
+ while @@count < count && loop > 0
+ loop -= 1
+ if RUBY_PLATFORM =~ /java/
+ require "java"
+ java.lang.System.gc
+ else
+ GC.start
+ end
+ sleep 0.05 unless @@count == count
+ end
+ @@count = 0
+ end
+ def self.finalizer
+ self.method(:release).to_proc
+ end
+ end
+
+ #
+ # String fixtures
+ #
+ module LibTest
+ attach_function :ptr_ret_pointer, [ :pointer, :int], :string
+ attach_function :string_equals, [ :string, :string ], :int
+ attach_function :string_dummy, [ :string ], :void
+ end
+
+ #
+ # Struct initialize fixtures
+ #
+ class StructWithInitialize < FFI::Struct
+ layout :string, :string
+ attr_accessor :magic
+ def initialize
+ super
+ self.magic = 42
+ end
+ end
+
+ #
+ # Struct fixtures
+ #
+ StructTypes = {
+ 's8' => :char,
+ 's16' => :short,
+ 's32' => :int,
+ 's64' => :long_long,
+ 'long' => :long,
+ 'f32' => :float,
+ 'f64' => :double
+ }
+
+ module LibTest
+ attach_function :ptr_ret_pointer, [ :pointer, :int], :string
+ attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int
+ attach_function :ptr_from_address, [ :ulong ], :pointer
+ attach_function :string_equals, [ :string, :string ], :int
+ [ 's8', 's16', 's32', 's64', 'f32', 'f64', 'long' ].each do |t|
+ attach_function "struct_align_#{t}", [ :pointer ], StructTypes[t]
+ end
+ end
+
+ class PointerMember < FFI::Struct
+ layout :pointer, :pointer
+ end
+
+ class StringMember < FFI::Struct
+ layout :string, :string
+ end
+
+ module CallbackMember
+ extend FFI::Library
+ ffi_lib LIBRARY
+ callback :add, [ :int, :int ], :int
+ callback :sub, [ :int, :int ], :int
+
+ class TestStruct < FFI::Struct
+ layout :add, :add,
+ :sub, :sub
+ end
+
+ attach_function :struct_call_add_cb, [TestStruct, :int, :int], :int
+ attach_function :struct_call_sub_cb, [TestStruct, :int, :int], :int
+ end
+
+ module LibTest
+ class NestedStruct < FFI::Struct
+ layout :i, :int
+ end
+
+ class ContainerStruct < FFI::Struct
+ layout :first, :char, :ns, NestedStruct
+ end
+
+ attach_function :struct_align_nested_struct, [ :pointer ], :int
+ attach_function :struct_make_container_struct, [ :int ], :pointer
+
+ class StructWithArray < FFI::Struct
+ layout :first, :char, :a, [:int, 5]
+ end
+
+ attach_function :struct_make_struct_with_array, [:int, :int, :int, :int, :int], :pointer
+ attach_function :struct_field_array, [:pointer], :pointer
+
+ class BuggedStruct < FFI::Struct
+ layout :visible, :uchar,
+ :x, :uint,
+ :y, :uint,
+ :rx, :short,
+ :ry, :short,
+ :order, :uchar,
+ :size, :uchar
+ end
+
+ attach_function :bugged_struct_size, [], :uint
+ end
+
+ module StructCustomTypedef
+ extend FFI::Library
+ ffi_lib LIBRARY
+ typedef :uint, :fubar3_t
+
+ class S < FFI::Struct
+ layout :a, :fubar3_t
+ end
+ end
+
+ #
+ # Union fixtures
+ #
+ module LibTest
+ Types = {
+ 's8' => [:char, :c, 1],
+ 's16' => [:short, :s, 0xff0],
+ 's32' => [:int, :i, 0xff00],
+ 's64' => [:long_long, :j, 0xffff00],
+ 'long' => [:long, :l, 0xffff],
+ 'f32' => [:float, :f, 1.0001],
+ 'f64' => [:double, :d, 1.000000001]
+ }
+
+ class TestUnion < FFI::Union
+ layout( :a, [:char, 10],
+ :i, :int,
+ :f, :float,
+ :d, :double,
+ :s, :short,
+ :l, :long,
+ :j, :long_long,
+ :c, :char )
+ end
+
+ Types.keys.each do |k|
+ attach_function "union_align_#{k}", [ :pointer ], Types[k][0]
+ attach_function "union_make_union_with_#{k}", [ Types[k][0] ], :pointer
+ end
+
+ attach_function :union_size, [], :uint
+ end
+
+ #
+ # Variadic fixtures
+ #
+ module LibTest
+ attach_function :pack_varargs, [ :buffer_out, :string, :varargs ], :void
+ end
+
+ module Varargs
+ PACK_VALUES = {
+ 'c' => [ 0x12 ],
+ 'C' => [ 0x34 ],
+ 's' => [ 0x5678 ],
+ 'S' => [ 0x9abc ],
+ 'i' => [ 0x7654321f ],
+ 'I' => [ 0xfee1babe ],
+ 'l' => [ 0x1f2e3d4c ],
+ 'L' => [ 0xf7e8d9ca ],
+ 'j' => [ 0x1eafdeadbeefa1b2 ],
+ 'f' => [ 1.23456789 ],
+ 'd' => [ 9.87654321 ]
+ }
+
+ TYPE_MAP = {
+ 'c' => :char, 'C' => :uchar, 's' => :short, 'S' => :ushort,
+ 'i' => :int, 'I' => :uint, 'j' => :long_long, 'J' => :ulong_long,
+ 'l' => :long, 'L' => :ulong, 'f' => :float, 'd' => :double
+ }
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/library_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/library_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/library_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,153 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+describe "FFI::Library" do
+ it "attach_function with no library specified" do
+ lambda {
+ new_module { attach_function :getpid, [ ], :uint }
+ }.should_not raise_error
+ end
+
+ it "attach_function :getpid from this process" do
+ lambda {
+ mod = new_module { attach_function :getpid, [ ], :uint }
+ mod.getpid.should == Process.pid
+ }.should_not raise_error
+ end
+
+ it "attach_function :getpid from [ 'c', 'libc.so.6'] " do
+ lambda {
+ mod = new_module('c', 'libc.so.6') { attach_function :getpid, [ ], :uint }
+ mod.getpid.should == Process.pid
+ }.should_not raise_error
+ end
+
+ it "attach_function :getpid from [ 'libc.so.6', 'c' ] " do
+ lambda {
+ mod = new_module('libc.so.6', 'c') { attach_function :getpid, [ ], :uint }
+ mod.getpid.should == Process.pid
+ }.should_not raise_error
+ end
+
+ it "attach_function :getpid from [ 'libfubar.so.0xdeadbeef', nil, 'c' ] " do
+ lambda {
+ mod = new_module('libfubar.so.0xdeadbeef', nil, 'c') { attach_function :getpid, [ ], :uint }
+ mod.getpid.should == Process.pid
+ }.should_not raise_error
+ end
+
+ it "attach_function :getpid from [ 'libfubar.so.0xdeadbeef' ] " do
+ lambda {
+ mod = new_module('libfubar.so.0xdeadbeef') { attach_function :getpid, [ ], :uint }
+ mod.getpid.should == Process.pid
+ }.should raise_error(LoadError)
+ end
+
+ it "Pointer variable" do
+ lib = gvar_lib("pointer", :pointer)
+ val = FFI::MemoryPointer.new :long
+ lib.set(val)
+ lib.gvar.should == val
+ lib.set(nil)
+ lib.gvar = val
+ lib.get.should == val
+ end
+
+ [ 0, 127, -128, -1 ].each do |i|
+ it ":char variable" do
+ gvar_test("s8", :char, i)
+ end
+ end
+
+ [ 0, 0x7f, 0x80, 0xff ].each do |i|
+ it ":uchar variable" do
+ gvar_test("u8", :uchar, i)
+ end
+ end
+
+ [ 0, 0x7fff, -0x8000, -1 ].each do |i|
+ it ":short variable" do
+ gvar_test("s16", :short, i)
+ end
+ end
+
+ [ 0, 0x7fff, 0x8000, 0xffff ].each do |i|
+ it ":ushort variable" do
+ gvar_test("u16", :ushort, i)
+ end
+ end
+
+ [ 0, 0x7fffffff, -0x80000000, -1 ].each do |i|
+ it ":int variable" do
+ gvar_test("s32", :int, i)
+ end
+ end
+
+ [ 0, 0x7fffffff, 0x80000000, 0xffffffff ].each do |i|
+ it ":uint variable" do
+ gvar_test("u32", :uint, i)
+ end
+ end
+
+ [ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ].each do |i|
+ it ":long_long variable" do
+ gvar_test("s64", :long_long, i)
+ end
+ end
+
+ [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ].each do |i|
+ it ":ulong_long variable" do
+ gvar_test("u64", :ulong_long, i)
+ end
+ end
+
+ if FFI::Platform::LONG_SIZE == 32
+ [ 0, 0x7fffffff, -0x80000000, -1 ].each do |i|
+ it ":long variable" do
+ gvar_test("long", :long, i)
+ end
+ end
+
+ [ 0, 0x7fffffff, 0x80000000, 0xffffffff ].each do |i|
+ it ":ulong variable" do
+ gvar_test("ulong", :ulong, i)
+ end
+ end
+ else
+ [ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ].each do |i|
+ it ":long variable" do
+ gvar_test("long", :long, i)
+ end
+ end
+
+ [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ].each do |i|
+ it ":ulong variable" do
+ gvar_test("ulong", :ulong, i)
+ end
+ end
+ end
+
+ def self.new_module(*libs, &block)
+ Module.new do
+ extend FFI::Library
+ ffi_lib(*libs) unless libs.empty?
+ module_eval(&block)
+ end
+ end
+
+ def self.gvar_lib(name, type)
+ new_module FFISpecs::LIBRARY do
+ attach_variable :gvar, "gvar_#{name}", type
+ attach_function :get, "gvar_#{name}_get", [], type
+ attach_function :set, "gvar_#{name}_set", [ type ], :void
+ end
+ end
+
+ def self.gvar_test(name, type, val)
+ lib = gvar_lib(name, type)
+ lib.set(val)
+ lib.gvar.should == val
+ lib.set(0)
+ lib.gvar = val
+ lib.get.should == val
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/managed_struct_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/managed_struct_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/managed_struct_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,26 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+describe "Managed Struct" do
+ it "should raise an error if release() is not defined" do
+ lambda {
+ FFISpecs::NoRelease.new(FFISpecs::LibTest.ptr_from_address(0x12345678))
+ }.should raise_error(NoMethodError)
+ end
+
+ it "should be the right class" do
+ ptr = FFISpecs::WhatClassAmI.new(FFISpecs::LibTest.ptr_from_address(0x12345678))
+ ptr.should be_kind_of(FFISpecs::WhatClassAmI)
+ end
+
+ it "should release memory properly" do
+ loop_count = 30
+ wiggle_room = 2
+
+ FFISpecs::PleaseReleaseMe.should_receive(:release).at_least(loop_count - wiggle_room).times
+ loop_count.times do
+ s = FFISpecs::PleaseReleaseMe.new(FFISpecs::LibTest.ptr_from_address(0x12345678))
+ end
+
+ FFISpecs::PleaseReleaseMe.wait_gc loop_count
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/number_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/number_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/number_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,201 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+describe "Function with primitive integer arguments" do
+ it "int8.size" do
+ FFISpecs::TYPE_INT8.size.should == 1
+ end
+
+ it "uint8.size" do
+ FFISpecs::TYPE_UINT8.size.should == 1
+ end
+
+ it "int16.size" do
+ FFISpecs::TYPE_INT16.size.should == 2
+ end
+
+ it "uint16.size" do
+ FFISpecs::TYPE_UINT16.size.should == 2
+ end
+
+ it "int32.size" do
+ FFISpecs::TYPE_INT32.size.should == 4
+ end
+
+ it "uint32.size" do
+ FFISpecs::TYPE_UINT32.size.should == 4
+ end
+
+ it "int64.size" do
+ FFISpecs::TYPE_INT64.size.should == 8
+ end
+
+ it "uint64.size" do
+ FFISpecs::TYPE_UINT64.size.should == 8
+ end
+
+ it "float.size" do
+ FFISpecs::TYPE_FLOAT32.size.should == 4
+ end
+
+ it "double.size" do
+ FFISpecs::TYPE_FLOAT64.size.should == 8
+ end
+
+ [ 0, 127, -128, -1 ].each do |i|
+ it ":char call(:char (#{i}))" do
+ FFISpecs::LibTest.ret_s8(i).should == i
+ end
+ end
+
+ [ 0, 0x7f, 0x80, 0xff ].each do |i|
+ it ":uchar call(:uchar (#{i}))" do
+ FFISpecs::LibTest.ret_u8(i).should == i
+ end
+ end
+
+ [ 0, 0x7fff, -0x8000, -1 ].each do |i|
+ it ":short call(:short (#{i}))" do
+ FFISpecs::LibTest.ret_s16(i).should == i
+ end
+ end
+
+ [ 0, 0x7fff, 0x8000, 0xffff ].each do |i|
+ it ":ushort call(:ushort (#{i}))" do
+ FFISpecs::LibTest.ret_u16(i).should == i
+ end
+ end
+
+ [ 0, 0x7fffffff, -0x80000000, -1 ].each do |i|
+ it ":int call(:int (#{i}))" do
+ FFISpecs::LibTest.ret_s32(i).should == i
+ end
+ end
+
+ [ 0, 0x7fffffff, 0x80000000, 0xffffffff ].each do |i|
+ it ":uint call(:uint (#{i}))" do
+ FFISpecs::LibTest.ret_u32(i).should == i
+ end
+ end
+
+ [ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ].each do |i|
+ it ":long_long call(:long_long (#{i}))" do
+ FFISpecs::LibTest.ret_s64(i).should == i
+ end
+ end
+
+ [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ].each do |i|
+ it ":ulong_long call(:ulong_long (#{i}))" do
+ FFISpecs::LibTest.ret_u64(i).should == i
+ end
+ end
+
+ if FFI::Platform::LONG_SIZE == 32
+ [ 0, 0x7fffffff, -0x80000000, -1 ].each do |i|
+ it ":long call(:long (#{i}))" do
+ FFISpecs::LibTest.ret_long(i).should == i
+ end
+ end
+
+ [ 0, 0x7fffffff, 0x80000000, 0xffffffff ].each do |i|
+ it ":ulong call(:ulong (#{i}))" do
+ FFISpecs::LibTest.ret_ulong(i).should == i
+ end
+ end
+ else
+ [ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ].each do |i|
+ it ":long call(:long (#{i}))" do
+ FFISpecs::LibTest.ret_long(i).should == i
+ end
+ end
+
+ [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ].each do |i|
+ it ":ulong call(:ulong (#{i}))" do
+ FFISpecs::LibTest.ret_ulong(i).should == i
+ end
+ end
+
+ [ 0.0, 0.1, 1.1, 1.23 ].each do |f|
+ it ":float call(:double (#{f}))" do
+ FFISpecs::LibTest.set_float(f)
+ (FFISpecs::LibTest.get_float - f).abs.should < 0.001
+ end
+ end
+
+ [ 0.0, 0.1, 1.1, 1.23 ].each do |f|
+ it ":double call(:double (#{f}))" do
+ FFISpecs::LibTest.set_double(f)
+ (FFISpecs::LibTest.get_double - f).abs.should < 0.001
+ end
+ end
+ end
+end
+
+describe "Integer parameter range checking" do
+ [ 128, -129 ].each do |i|
+ it ":char call(:char (#{i}))" do
+ lambda { FFISpecs::LibTest.ret_int8_t(i).should == i }.should raise_error
+ end
+ end
+
+ [ -1, 256 ].each do |i|
+ it ":uchar call(:uchar (#{i}))" do
+ lambda { FFISpecs::LibTest.ret_u_int8_t(i).should == i }.should raise_error
+ end
+ end
+
+ [ 0x8000, -0x8001 ].each do |i|
+ it ":short call(:short (#{i}))" do
+ lambda { FFISpecs::LibTest.ret_int16_t(i).should == i }.should raise_error
+ end
+ end
+
+ [ -1, 0x10000 ].each do |i|
+ it ":ushort call(:ushort (#{i}))" do
+ lambda { FFISpecs::LibTest.ret_u_int16_t(i).should == i }.should raise_error
+ end
+ end
+
+ [ 0x80000000, -0x80000001 ].each do |i|
+ it ":int call(:int (#{i}))" do
+ lambda { FFISpecs::LibTest.ret_int32_t(i).should == i }.should raise_error
+ end
+ end
+
+ [ -1, 0x100000000 ].each do |i|
+ it ":ushort call(:ushort (#{i}))" do
+ lambda { FFISpecs::LibTest.ret_u_int32_t(i).should == i }.should raise_error
+ end
+ end
+end
+
+describe "Three different size Integer arguments" do
+ def self.verify(p, off, t, v)
+ if t == 'f32'
+ p.get_float32(off).should == v
+ elsif t == 'f64'
+ p.get_float64(off).should == v
+ else
+ p.get_int64(off).should == v
+ end
+ end
+
+ FFISpecs::PACK_VALUES.keys.each do |t1|
+ FFISpecs::PACK_VALUES.keys.each do |t2|
+ FFISpecs::PACK_VALUES.keys.each do |t3|
+ FFISpecs::PACK_VALUES[t1].each do |v1|
+ FFISpecs::PACK_VALUES[t2].each do |v2|
+ FFISpecs::PACK_VALUES[t3].each do |v3|
+ it "call(#{FFISpecs::TYPE_MAP[t1]} (#{v1}), #{FFISpecs::TYPE_MAP[t2]} (#{v2}), #{FFISpecs::TYPE_MAP[t3]} (#{v3}))" do
+ p = FFI::Buffer.new :long_long, 3
+ FFISpecs::LibTest.send("pack_#{t1}#{t2}#{t3}_s64", v1, v2, v3, p)
+ verify(p, 0, t1, v1)
+ verify(p, 8, t2, v2)
+ verify(p, 16, t3, v3)
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/pointer_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/pointer_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/pointer_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,158 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+describe "Pointer" do
+ it "Any object implementing #to_ptr can be passed as a :pointer parameter" do
+ memory = FFI::MemoryPointer.new :long_long
+ magic = 0x12345678
+ memory.put_int32(0, magic)
+ tp = FFISpecs::ToPtrTest.new(memory)
+ FFISpecs::LibTest.ptr_ret_int32_t(tp, 0).should == magic
+ end
+
+ it "A DelegateClass(Pointer) can be passed as a :pointer parameter" do
+ memory = FFI::MemoryPointer.new :long_long
+ magic = 0x12345678
+ memory.put_int32(0, magic)
+ ptr = FFISpecs::PointerDelegate.new(memory)
+ FFISpecs::LibTest.ptr_ret_int32_t(ptr, 0).should == magic
+ end
+
+ it "Fixnum cannot be used as a Pointer argument" do
+ lambda { FFISpecs::LibTest.ptr_ret_int32(0, 0) }.should raise_error
+ end
+
+ it "Bignum cannot be used as a Pointer argument" do
+ lambda { FFISpecs::LibTest.ptr_ret_int32(0xfee1deadbeefcafebabe, 0) }.should raise_error
+ end
+
+ # TODO: Shouldn't these use #it ?
+ describe "pointer type methods" do
+ describe "#read_pointer" do
+ memory = FFI::MemoryPointer.new :pointer
+ FFISpecs::LibTest.ptr_set_pointer(memory, 0, FFISpecs::LibTest.ptr_from_address(0xdeadbeef))
+ memory.read_pointer.address.should == 0xdeadbeef
+ end
+
+ describe "#write_pointer" do
+ memory = FFI::MemoryPointer.new :pointer
+ memory.write_pointer(FFISpecs::LibTest.ptr_from_address(0xdeadbeef))
+
+ # TODO: Have to define this manually because setting it in the fixture
+ # classes will override it with different function definitions.
+
+ FFISpecs::LibTest.attach_function :ptr_ret_pointer, [ :pointer, :int ], :pointer
+ FFISpecs::LibTest.ptr_ret_pointer(memory, 0).address.should == 0xdeadbeef
+ end
+
+ describe "#read_array_of_pointer" do
+ values = [0x12345678, 0xfeedf00d, 0xdeadbeef]
+ memory = FFI::MemoryPointer.new :pointer, values.size
+ values.each_with_index do |address, j|
+ FFISpecs::LibTest.ptr_set_pointer(memory, j * FFI.type_size(:pointer), FFISpecs::LibTest.ptr_from_address(address))
+ end
+ array = memory.read_array_of_pointer(values.size)
+ values.each_with_index do |address, j|
+ array[j].address.should == address
+ end
+ end
+
+ describe "#write_array_of_pointer" do
+ values = [0x12345678, 0xfeedf00d, 0xdeadbeef]
+ memory = FFI::MemoryPointer.new :pointer, values.size
+ memory.write_array_of_pointer(values.map { |address| FFISpecs::LibTest.ptr_from_address(address) })
+ array = []
+ values.each_with_index do |address, j|
+ array << FFISpecs::LibTest.ptr_ret_pointer(memory, j * FFI.type_size(:pointer))
+ end
+ values.each_with_index do |address, j|
+ array[j].address.should == address
+ end
+ end
+ end
+
+ describe 'NULL' do
+ it 'should be obtained using Pointer::NULL constant' do
+ null_ptr = FFI::Pointer::NULL
+ null_ptr.null?.should be_true
+ end
+
+ it 'should be obtained passing address 0 to constructor' do
+ FFI::Pointer.new(0).null?.should be_true
+ end
+
+ it 'should raise an error when attempting read/write operations on it' do
+ null_ptr = FFI::Pointer::NULL
+ lambda { null_ptr.read_int }.should raise_error(FFI::NullPointerError)
+ lambda { null_ptr.write_int(0xff1) }.should raise_error(FFI::NullPointerError)
+ end
+ end
+end
+
+describe "AutoPointer" do
+ before :all do
+ @loop_count = 30
+ @wiggle_room = 2 # GC rarely cleans up all objects. we can get most of them, and that's enough to determine if the basic functionality is working.
+ @magic = 0x12345678
+ end
+
+ after :each do
+ FFISpecs::AutoPointerTestHelper.gc_everything @loop_count
+ end
+
+ it "cleanup via default release method" do
+ FFI::AutoPointer.should_receive(:release).at_least(@loop_count - @wiggle_room).times
+ FFISpecs::AutoPointerTestHelper.reset
+ @loop_count.times do
+ # note that if we called
+ # FFISpecs::AutoPointerTestHelper.method(:release).to_proc inline, we'd
+ # have a reference to the pointer and it would never get GC'd.
+ ap = FFI::AutoPointer.new(FFISpecs::LibTest.ptr_from_address(@magic))
+ end
+ end
+
+ it "cleanup when passed a proc" do
+ # NOTE: passing a proc is touchy, because it's so easy to create a memory leak.
+ #
+ # specifically, if we made an inline call to
+ #
+ # FFISpecs::AutoPointerTestHelper.method(:release).to_proc
+ #
+ # we'd have a reference to the pointer and it would
+ # never get GC'd.
+ FFISpecs::AutoPointerTestHelper.should_receive(:release).at_least(@loop_count - @wiggle_room).times
+ FFISpecs::AutoPointerTestHelper.reset
+ @loop_count.times do
+ ap = FFI::AutoPointer.new(FFISpecs::LibTest.ptr_from_address(@magic),
+ FFISpecs::AutoPointerTestHelper.finalizer)
+ end
+ end
+
+ it "cleanup when passed a method" do
+ FFISpecs::AutoPointerTestHelper.should_receive(:release).at_least(@loop_count - @wiggle_room).times
+ FFISpecs::AutoPointerTestHelper.reset
+ @loop_count.times do
+ ap = FFI::AutoPointer.new(FFISpecs::LibTest.ptr_from_address(@magic),
+ FFISpecs::AutoPointerTestHelper.method(:release))
+ end
+ end
+end
+
+describe "AutoPointer#new" do
+ it "MemoryPointer argument raises ArgumentError" do
+ lambda {
+ FFI::AutoPointer.new(FFI::MemoryPointer.new(:int))
+ }.should raise_error(ArgumentError)
+ end
+
+ it "AutoPointer argument raises ArgumentError" do
+ lambda {
+ FFI::AutoPointer.new(FFI::AutoPointer.new(FFISpecs::LibTest.ptr_from_address(0)))
+ }.should raise_error(ArgumentError)
+ end
+
+ it "Buffer argument raises ArgumentError" do
+ lambda {
+ FFI::AutoPointer.new(FFI::Buffer.new(:int))
+ }.should raise_error(ArgumentError)
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/rbx/attach_function_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/rbx/attach_function_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/rbx/attach_function_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,27 @@
+require File.expand_path('../../spec_helper', __FILE__)
+
+describe FFI::Library, "#attach_function" do
+ before :all do
+ @klass = Class.new(FFI::Struct)
+ @klass.layout :tv_sec, :ulong, 0, :tv_usec, :ulong, 4
+
+ @libc = Module.new do
+ extend FFI::Library
+ attach_function :gettimeofday, [:pointer, :pointer], :int
+ end
+ end
+
+ before :each do
+ @t = @klass.new
+ @time = @libc.gettimeofday(@t.pointer, nil)
+ end
+
+ it "correctly returns a value for gettimeofday" do
+ @time.should be_kind_of(Integer)
+ end
+
+ it "correctly populates a struct for gettimeofday" do
+ @t[:tv_sec].should be_kind_of(Numeric)
+ @t[:tv_usec].should be_kind_of(Numeric)
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/rbx/memory_pointer_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/rbx/memory_pointer_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/rbx/memory_pointer_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,105 @@
+require File.expand_path('../../spec_helper', __FILE__)
+
+# TODO: Why is this needed? Seems to work fine without it.
+# module CTest
+# extend FFI::Library
+# attach_function :strcat, [:pointer, :pointer], :pointer
+# end
+
+describe "MemoryPointer" do
+ it "makes a pointer from a string" do
+ m = FFI::MemoryPointer.from_string("FFI is Awesome")
+ m.type_size.should == 15
+ end
+
+ it "reads back a string" do
+ m = FFI::MemoryPointer.from_string("FFI is Awesome")
+ m.read_string.should == "FFI is Awesome"
+ end
+
+ it "makes a pointer for a certain number of bytes" do
+ m = FFI::MemoryPointer.new(8)
+ m.write_array_of_int([1,2])
+ m.read_array_of_int(2).should == [1,2]
+ end
+
+ it "allows access to an element of the pointer (as an array)" do
+ m = FFI::MemoryPointer.new(:int, 2)
+ m.write_array_of_int([1,2])
+ m[0].read_int.should == 1
+ m[1].read_int.should == 2
+ end
+
+ it "allows writing as an int" do
+ m = FFI::MemoryPointer.new(:int)
+ m.write_int(1)
+ m.read_int.should == 1
+ end
+
+ it "allows writing as a long" do
+ m = FFI::MemoryPointer.new(:long)
+ m.write_long(10)
+ m.read_long.should == 10
+ end
+
+ it "raises an error if you try putting a long into a pointer of size 1" do
+ m = FFI::MemoryPointer.new(1)
+ lambda { m.write_long(10) }.should raise_error
+ end
+
+ it "raises an error if you try putting an int into a pointer of size 1" do
+ m = FFI::MemoryPointer.new(1)
+ lambda { m.write_int(10) }.should raise_error
+ end
+
+ # it "does not raise IndexError for opaque pointers" do
+ # m = FFI::MemoryPointer.new(8)
+ # p2 = FFI::MemoryPointer.new(1024)
+ # m.write_long(p2.address)
+ # p = m.read_pointer
+ # lambda { p.write_int(10) }.should_not raise_error
+ # end
+
+ it "makes a pointer for a certain type" do
+ m = FFI::MemoryPointer.new(:int)
+ m.write_int(10)
+ m.read_int.should == 10
+ end
+
+ it "makes a memory pointer for a number of a certain type" do
+ m = FFI::MemoryPointer.new(:int, 2)
+ m.write_array_of_int([1,2])
+ m.read_array_of_int(2).should == [1,2]
+ end
+
+ it "makes a pointer for an object responding to #size" do
+ m = FFI::MemoryPointer.new(::Struct.new(:size).new(8))
+ m.write_array_of_int([1,2])
+ m.read_array_of_int(2).should == [1,2]
+ end
+
+ it "makes a pointer for a number of an object responding to #size" do
+ m = FFI::MemoryPointer.new(::Struct.new(:size).new(4), 2)
+ m.write_array_of_int([1,2])
+ m.read_array_of_int(2).should == [1,2]
+ end
+
+ it "MemoryPointer#address returns correct value" do
+ m = FFI::MemoryPointer.new(:long_long)
+ magic = 0x12345678
+ m.write_long(magic)
+ m.read_pointer.address.should == magic
+ end
+
+ it "MemoryPointer#null? returns true for zero value" do
+ m = FFI::MemoryPointer.new(:long_long)
+ m.write_long(0)
+ m.read_pointer.null?.should == true
+ end
+
+ it "MemoryPointer#null? returns false for non-zero value" do
+ m = FFI::MemoryPointer.new(:long_long)
+ m.write_long(0x12345678)
+ m.read_pointer.null?.should == false
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/rbx/struct_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/rbx/struct_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/rbx/struct_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,12 @@
+require File.expand_path('../../spec_helper', __FILE__)
+
+describe FFI::Struct do
+ it "allows setting fields" do
+ klass = Class.new(FFI::Struct)
+ klass.layout :tv_sec, :ulong, 0, :tv_usec, :ulong, 4
+
+ t = klass.new
+ t[:tv_sec] = 12
+ t[:tv_sec].should == 12
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/spec_helper.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/spec_helper.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/spec_helper.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,37 @@
+unless defined? FFI
+ begin
+ require "ffi"
+ rescue LoadError
+ require "rubygems"
+ require "ffi"
+ end
+end
+
+module FFISpecs
+ include FFI
+
+ LongSize = FFI::Platform::LONG_SIZE / 8
+
+ FIXTURE_DIR = File.expand_path("../fixtures", __FILE__)
+ LIBRARY = File.join(FIXTURE_DIR, "build/libtest/libtest.#{FFI::Platform::LIBSUFFIX}")
+
+ def self.need_to_compile_fixtures?
+ !File.exist?(LIBRARY) or Dir.glob(File.join(FIXTURE_DIR, "*.c")).any? { |f| File.mtime(f) > File.mtime(LIBRARY) }
+ end
+
+ if need_to_compile_fixtures?
+ puts "[!] Compiling Ruby-FFI fixtures"
+ Dir.chdir(File.dirname(FIXTURE_DIR)) do
+ unless system("make -f fixtures/GNUmakefile")
+ raise "Failed to compile Ruby-FFI fixtures"
+ end
+ end
+ end
+
+ module LibTest
+ extend FFI::Library
+ ffi_lib LIBRARY
+ end
+end
+
+require File.join(FFISpecs::FIXTURE_DIR, 'classes')
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/string_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/string_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/string_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,106 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+describe "String tests" do
+ it "FFI::MemoryPointer#get_string returns a tainted string" do
+ mp = FFI::MemoryPointer.new 1024
+ mp.put_string(0, "test\0")
+ str = mp.get_string(0)
+ str.tainted?.should == true
+ end
+
+ it "String returned by a method is tainted" do
+ mp = FFI::MemoryPointer.new :pointer
+ sp = FFI::MemoryPointer.new 1024
+ sp.put_string(0, "test")
+ mp.put_pointer(0, sp)
+
+ # TODO: Have to define this manually because setting it in the fixture
+ # classes will override it with different function definitions.
+ FFISpecs::LibTest.attach_function :ptr_ret_pointer, [ :pointer, :int], :string
+
+ str = FFISpecs::LibTest.ptr_ret_pointer(mp, 0)
+ str.should == "test"
+ str.tainted?.should == true
+ end
+
+ it "Poison null byte raises error" do
+ s = "123\0abc"
+ lambda { FFISpecs::LibTest.string_equals(s, s) }.should raise_error
+ end
+
+ it "Tainted String parameter should throw a SecurityError" do
+ $SAFE = 1
+ str = "test"
+ str.taint
+ begin
+ FFISpecs::LibTest.string_equals(str, str).should == false
+ rescue SecurityError => e
+ end
+ end if false
+
+ it "casts nil as NULL pointer" do
+ lambda { FFISpecs::LibTest.string_dummy(nil) }.should_not raise_error
+ end
+
+ it "reads an array of strings until encountering a NULL pointer" do
+ strings = ["foo", "bar", "baz", "testing", "ffi"]
+ ptrary = FFI::MemoryPointer.new(:pointer, 6)
+ ary = strings.inject([]) do |a, str|
+ f = FFI::MemoryPointer.new(1024)
+ f.put_string(0, str)
+ a << f
+ end
+ ary.insert(3, nil)
+ ptrary.write_array_of_pointer(ary)
+ ptrary.get_array_of_string(0).should == ["foo", "bar", "baz"]
+ end
+
+ it "reads an array of strings of the size specified, substituting nil when a pointer is NULL" do
+ strings = ["foo", "bar", "baz", "testing", "ffi"]
+ ptrary = FFI::MemoryPointer.new(:pointer, 6)
+ ary = strings.inject([]) do |a, str|
+ f = FFI::MemoryPointer.new(1024)
+ f.put_string(0, str)
+ a << f
+ end
+ ary.insert(2, nil)
+ ptrary.write_array_of_pointer(ary)
+ ptrary.get_array_of_string(0, 4).should == ["foo", "bar", nil, "baz"]
+ end
+
+ it "reads an array of strings, taking a memory offset parameter" do
+ strings = ["foo", "bar", "baz", "testing", "ffi"]
+ ptrary = FFI::MemoryPointer.new(:pointer, 5)
+ ary = strings.inject([]) do |a, str|
+ f = FFI::MemoryPointer.new(1024)
+ f.put_string(0, str)
+ a << f
+ end
+ ptrary.write_array_of_pointer(ary)
+ ptrary.get_array_of_string(2 * FFI.type_size(:pointer), 3).should == ["baz", "testing", "ffi"]
+ end
+
+ it "raises an IndexError when trying to read an array of strings out of bounds" do
+ strings = ["foo", "bar", "baz", "testing", "ffi"]
+ ptrary = FFI::MemoryPointer.new(:pointer, 5)
+ ary = strings.inject([]) do |a, str|
+ f = FFI::MemoryPointer.new(1024)
+ f.put_string(0, str)
+ a << f
+ end
+ ptrary.write_array_of_pointer(ary)
+ lambda { ptrary.get_array_of_string(0, 6) }.should raise_error
+ end
+
+ it "raises an IndexError when trying to read an array of strings using a negative offset" do
+ strings = ["foo", "bar", "baz", "testing", "ffi"]
+ ptrary = FFI::MemoryPointer.new(:pointer, 5)
+ ary = strings.inject([]) do |a, str|
+ f = FFI::MemoryPointer.new(1024)
+ f.put_string(0, str)
+ a << f
+ end
+ ptrary.write_array_of_pointer(ary)
+ lambda { ptrary.get_array_of_string(-1) }.should raise_error
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/struct_callback_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/struct_callback_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/struct_callback_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,21 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+describe FFI::Struct, ' with inline callback functions' do
+ it 'should be able to define inline callback field' do
+ lambda {
+ Module.new do
+ extend FFI::Library
+ ffi_lib FFISpecs::LIBRARY
+
+ struct = Class.new(FFI::Struct) do
+ layout \
+ :add, callback([ :int, :int ], :int),
+ :sub, callback([ :int, :int ], :int)
+ end
+
+ attach_function :struct_call_add_cb, [struct, :int, :int], :int
+ attach_function :struct_call_sub_cb, [struct, :int, :int], :int
+ end
+ }.should_not raise_error
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/struct_initialize_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/struct_initialize_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/struct_initialize_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,32 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+describe FFI::Struct, ' with an initialize function' do
+ it "should call the initialize function" do
+ struct_with_initialize = Class.new(FFI::Struct) do
+ layout :string, :string
+ attr_accessor :magic
+ def initialize
+ super
+ self.magic = 42
+ end
+ end
+
+ struct_with_initialize.new.magic.should == 42
+ end
+end
+
+describe FFI::ManagedStruct, ' with an initialize function' do
+ it "should call the initialize function" do
+ managed_struct_with_initialize = Class.new(FFI::ManagedStruct) do
+ layout :string, :string
+ attr_accessor :magic
+ def initialize
+ super FFI::MemoryPointer.new(:pointer).put_int(0, 0x1234).get_pointer(0)
+ self.magic = 42
+ end
+ def self.release;end
+ end
+
+ managed_struct_with_initialize.new.magic.should == 42
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/struct_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/struct_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/struct_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,476 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+describe "Struct tests" do
+ it "Struct#[:pointer]" do
+ magic = 0x12345678
+ mp = FFI::MemoryPointer.new :long
+ mp.put_long(0, magic)
+ smp = FFI::MemoryPointer.new :pointer
+ smp.put_pointer(0, mp)
+ s = FFISpecs::PointerMember.new smp
+ s[:pointer].should == mp
+ end
+
+ it "Struct#[:pointer].nil? for NULL value" do
+ magic = 0x12345678
+ mp = FFI::MemoryPointer.new :long
+ mp.put_long(0, magic)
+ smp = FFI::MemoryPointer.new :pointer
+ smp.put_pointer(0, nil)
+ s = FFISpecs::PointerMember.new smp
+ s[:pointer].null?.should == true
+ end
+
+ it "Struct#[:pointer]=" do
+ magic = 0x12345678
+ mp = FFI::MemoryPointer.new :long
+ mp.put_long(0, magic)
+ smp = FFI::MemoryPointer.new :pointer
+ s = FFISpecs::PointerMember.new smp
+ s[:pointer] = mp
+ smp.get_pointer(0).should == mp
+ end
+
+ it "Struct#[:pointer]=struct" do
+ magic = 0x12345678
+ smp = FFI::MemoryPointer.new :pointer
+ s = FFISpecs::PointerMember.new smp
+ lambda { s[:pointer] = s }.should_not raise_error
+ end
+
+ it "Struct#[:pointer]=nil" do
+ smp = FFI::MemoryPointer.new :pointer
+ s = FFISpecs::PointerMember.new smp
+ s[:pointer] = nil
+ smp.get_pointer(0).null?.should == true
+ end
+
+ it "Struct#[:string]" do
+ magic = "test"
+ mp = FFI::MemoryPointer.new 1024
+ mp.put_string(0, magic)
+ smp = FFI::MemoryPointer.new :pointer
+ smp.put_pointer(0, mp)
+ s = FFISpecs::StringMember.new smp
+ s[:string].should == magic
+ end
+
+ it "Struct#[:string].nil? for NULL value" do
+ smp = FFI::MemoryPointer.new :pointer
+ smp.put_pointer(0, nil)
+ s = FFISpecs::StringMember.new smp
+ s[:string].nil?.should == true
+ end
+
+ it "Struct#layout works with :name, :type pairs" do
+ pair_layout = Class.new(FFI::Struct) do
+ layout :a, :int, :b, :long_long
+ end
+
+ ll_off = (FFI::TYPE_UINT64.alignment == 4 ? 4 : 8)
+ pair_layout.size.should == (ll_off + 8)
+
+ mp = FFI::MemoryPointer.new(pair_layout.size)
+ s = pair_layout.new(mp)
+
+ s[:a] = 0x12345678
+ mp.get_int(0).should == 0x12345678
+
+ s[:b] = 0xfee1deadbeef
+ mp.get_int64(ll_off).should == 0xfee1deadbeef
+ end
+
+ it "Struct#layout works with :name, :type, offset tuples" do
+ pair_layout = Class.new(FFI::Struct) do
+ layout :a, :int, 0, :b, :long_long, 4
+ end
+
+ pair_layout.size.should == (FFI::TYPE_UINT64.alignment == 4 ? 12 : 16)
+
+ mp = FFI::MemoryPointer.new(pair_layout.size)
+ s = pair_layout.new(mp)
+
+ s[:a] = 0x12345678
+ mp.get_int(0).should == 0x12345678
+
+ s[:b] = 0xfee1deadbeef
+ mp.get_int64(4).should == 0xfee1deadbeef
+ end
+
+ it "Struct#layout works with mixed :name,:type and :name,:type,offset" do
+ mixed_layout = Class.new(FFI::Struct) do
+ layout :a, :int, :b, :long_long, 4
+ end
+
+ mixed_layout.size.should == (FFI::TYPE_UINT64.alignment == 4 ? 12 : 16)
+
+ mp = FFI::MemoryPointer.new(mixed_layout.size)
+ s = mixed_layout.new(mp)
+
+ s[:a] = 0x12345678
+ mp.get_int(0).should == 0x12345678
+
+ s[:b] = 0xfee1deadbeef
+ mp.get_int64(4).should == 0xfee1deadbeef
+ end
+
+ rb_maj, rb_min = RUBY_VERSION.split('.')
+ if rb_maj.to_i >= 1 && rb_min.to_i >= 9 || RUBY_PLATFORM =~ /java/
+ it "Struct#layout withs with a hash of :name => type" do
+ hash_layout = Class.new(FFI::Struct) do
+ layout :a => :int, :b => :long_long
+ end
+
+ ll_off = (FFI::TYPE_UINT64.alignment == 4? 4 : 8)
+ hash_layout.size.should == (ll_off + 8)
+
+ mp = FFI::MemoryPointer.new(hash_layout.size)
+ s = hash_layout.new(mp)
+
+ s[:a] = 0x12345678
+ mp.get_int(0).should == 0x12345678
+
+ s[:b] = 0xfee1deadbeef
+ mp.get_int64(ll_off).should == 0xfee1deadbeef
+ end
+ end
+
+ it "Can use Struct subclass as parameter type" do
+ lambda {
+ Module.new do
+ extend FFI::Library
+ ffi_lib FFISpecs::LIBRARY
+
+ struct = Class.new(FFI::Struct) { layout :c, :char }
+ attach_function :struct_field_s8, [ struct ], :char
+ end
+ }.should_not raise_error
+ end
+
+ it "Can use Struct subclass as IN parameter type" do
+ lambda {
+ Module.new do
+ extend FFI::Library
+ ffi_lib FFISpecs::LIBRARY
+
+ struct = Class.new(FFI::Struct) { layout :c, :char }
+ attach_function :struct_field_s8, [ struct.in ], :char
+ end
+ }.should_not raise_error
+ end
+
+ it "Can use Struct subclass as OUT parameter type" do
+ lambda {
+ Module.new do
+ extend FFI::Library
+ ffi_lib FFISpecs::LIBRARY
+
+ struct = Class.new(FFI::Struct) { layout :c, :char }
+ attach_function :struct_field_s8, [ struct.out ], :char
+ end
+ }.should_not raise_error
+ end
+
+ it "can be passed directly as a :pointer parameter" do
+ struct = Class.new(FFI::Struct) do
+ layout :i, :int
+ end
+
+ s = struct.new
+ s[:i] = 0x12
+ FFISpecs::LibTest.ptr_ret_int32_t(s, 0).should == 0x12
+ end
+
+ it ":char member aligned correctly" do
+ align_char = Class.new(FFI::Struct) do
+ layout :c, :char, :v, :char
+ end
+
+ s = align_char.new
+ s[:v] = 0x12
+ FFISpecs::LibTest.struct_align_s8(s.pointer).should == 0x12
+ end
+
+ it ":short member aligned correctly" do
+ align_short = Class.new(FFI::Struct) do
+ layout :c, :char, :v, :short
+ end
+
+ s = align_short.alloc_in
+ s[:v] = 0x1234
+ FFISpecs::LibTest.struct_align_s16(s.pointer).should == 0x1234
+ end
+
+ it ":int member aligned correctly" do
+ align_int = Class.new(FFI::Struct) do
+ layout :c, :char, :v, :int
+ end
+
+ s = align_int.alloc_in
+ s[:v] = 0x12345678
+ FFISpecs::LibTest.struct_align_s32(s.pointer).should == 0x12345678
+ end
+
+ it ":long_long member aligned correctly" do
+ align_long_long = Class.new(FFI::Struct) do
+ layout :c, :char, :v, :long_long
+ end
+
+ s = align_long_long.alloc_in
+ s[:v] = 0x123456789abcdef0
+ FFISpecs::LibTest.struct_align_s64(s.pointer).should == 0x123456789abcdef0
+ end
+
+ it ":long member aligned correctly" do
+ align_long = Class.new(FFI::Struct) do
+ layout :c, :char, :v, :long
+ end
+
+ s = align_long.alloc_in
+ s[:v] = 0x12345678
+ FFISpecs::LibTest.struct_align_long(s.pointer).should == 0x12345678
+ end
+
+ it ":float member aligned correctly" do
+ align_float = Class.new(FFI::Struct) do
+ layout :c, :char, :v, :float
+ end
+
+ s = align_float.alloc_in
+ s[:v] = 1.23456
+ (FFISpecs::LibTest.struct_align_f32(s.pointer) - 1.23456).abs.should < 0.00001
+ end
+
+ it ":double member aligned correctly" do
+ align_double = Class.new(FFI::Struct) do
+ layout :c, :char, :v, :double
+ end
+
+ s = align_double.alloc_in
+ s[:v] = 1.23456789
+ (FFISpecs::LibTest.struct_align_f64(s.pointer) - 1.23456789).abs.should < 0.00000001
+ end
+
+ it ":ulong, :pointer struct" do
+ ulp_struct = Class.new(FFI::Struct) do
+ layout :ul, :ulong, :p, :pointer
+ end
+
+ s = ulp_struct.alloc_in
+ s[:ul] = 0xdeadbeef
+ s[:p] = FFISpecs::LibTest.ptr_from_address(0x12345678)
+ s.pointer.get_ulong(0).should == 0xdeadbeef
+ end
+
+ def self.test_num_field(type, v)
+ klass = Class.new(FFI::Struct)
+ klass.layout :v, type, :dummy, :long
+
+ s = klass.new
+ s[:v] = v
+ s.pointer.send("get_#{type.to_s}", 0).should == v
+ s.pointer.send("put_#{type.to_s}", 0, 0)
+ s[:v].should == 0
+ end
+
+ def self.int_field_test(type, values)
+ values.each do |v|
+ it "#{type} field r/w (#{v.to_s(16)})" do
+ test_num_field(type, v)
+ end
+ end
+ end
+
+ int_field_test(:char, [ 0, 127, -128, -1 ])
+ int_field_test(:uchar, [ 0, 0x7f, 0x80, 0xff ])
+ int_field_test(:short, [ 0, 0x7fff, -0x8000, -1 ])
+ int_field_test(:ushort, [ 0, 0x7fff, 0x8000, 0xffff ])
+ int_field_test(:int, [ 0, 0x7fffffff, -0x80000000, -1 ])
+ int_field_test(:uint, [ 0, 0x7fffffff, 0x80000000, 0xffffffff ])
+ int_field_test(:long_long, [ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ])
+ int_field_test(:ulong_long, [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ])
+
+ if FFI::Platform::LONG_SIZE == 32
+ int_field_test(:long, [ 0, 0x7fffffff, -0x80000000, -1 ])
+ int_field_test(:ulong, [ 0, 0x7fffffff, 0x80000000, 0xffffffff ])
+ else
+ int_field_test(:long, [ 0, 0x7fffffffffffffff, -0x8000000000000000, -1 ])
+ int_field_test(:ulong, [ 0, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff ])
+ end
+
+ it ":float field r/w" do
+ klass = Class.new(FFI::Struct)
+ klass.layout :v, :float, :dummy, :long
+
+ s = klass.new
+ value = 1.23456
+ s[:v] = value
+ (s.pointer.get_float(0) - value).abs.should < 0.0001
+ end
+
+ it ":double field r/w" do
+ klass = Class.new(FFI::Struct)
+ klass.layout :v, :double, :dummy, :long
+
+ s = klass.new
+ value = 1.23456
+ s[:v] = value
+ (s.pointer.get_double(0) - value).abs.should < 0.0001
+ end
+
+ it "Can have CallbackInfo struct field" do
+ s = FFISpecs::CallbackMember::TestStruct.new
+ add_proc = lambda { |a, b| a+b }
+ sub_proc = lambda { |a, b| a-b }
+ s[:add] = add_proc
+ s[:sub] = sub_proc
+ FFISpecs::CallbackMember.struct_call_add_cb(s.pointer, 40, 2).should == 42
+ FFISpecs::CallbackMember.struct_call_sub_cb(s.pointer, 44, 2).should == 42
+ end
+
+ it "Can return its members as a list" do
+ klass = Class.new(FFI::Struct)
+ klass.layout :a, :int, :b, :int, :c, :int
+ klass.members.should include(:a, :b, :c)
+ end
+
+ it "Can return its instance members and values as lists" do
+ klass = Class.new(FFI::Struct)
+ klass.layout :a, :int, :b, :int, :c, :int
+
+ s = klass.new
+ s.members.should include(:a, :b, :c)
+ s[:a] = 1
+ s[:b] = 2
+ s[:c] = 3
+ s.values.should include(1, 2, 3)
+ end
+
+ it 'should return an ordered field/offset pairs array' do
+ klass = Class.new(FFI::Struct)
+ klass.layout :a, :int, :b, :int, :c, :int
+
+ s = klass.new
+ s.offsets.should == [[:a, 0], [:b, 4], [:c, 8]]
+ klass.offsets.should == [[:a, 0], [:b, 4], [:c, 8]]
+ end
+
+ it "Struct#offset_of returns offset of field within struct" do
+ klass = Class.new(FFI::Struct)
+ klass.layout :a, :int, :b, :int, :c, :int
+
+ klass.offset_of(:a).should == 0
+ klass.offset_of(:b).should == 4
+ klass.offset_of(:c).should == 8
+ end
+end
+
+describe FFI::Struct, ' with a nested struct field' do
+ before do
+ @cs = FFISpecs::LibTest::ContainerStruct.new
+ end
+
+ it 'should align correctly nested struct field' do
+ @cs[:ns][:i] = 123
+ FFISpecs::LibTest.struct_align_nested_struct(@cs.to_ptr).should == 123
+ end
+
+ it 'should correctly calculate Container size (in bytes)' do
+ FFISpecs::LibTest::ContainerStruct.size.should == 8
+ end
+
+ it 'should return a Struct object when the field is accessed' do
+ @cs[:ns].is_a?(FFI::Struct).should be_true
+ end
+
+ it 'should read a value from memory' do
+ @cs = FFISpecs::LibTest::ContainerStruct.new(FFISpecs::LibTest.struct_make_container_struct(123))
+ @cs[:ns][:i].should == 123
+ end
+
+ it 'should write a value to memory' do
+ @cs = FFISpecs::LibTest::ContainerStruct.new(FFISpecs::LibTest.struct_make_container_struct(123))
+ @cs[:ns][:i] = 456
+ FFISpecs::LibTest.struct_align_nested_struct(@cs.to_ptr).should == 456
+ end
+end
+
+describe FFI::Struct, ' with an array field' do
+ before do
+ @s = FFISpecs::LibTest::StructWithArray.new
+ end
+
+ it 'should correctly calculate StructWithArray size (in bytes)' do
+ FFISpecs::LibTest::StructWithArray.size.should == 24
+ end
+
+ it 'should read values from memory' do
+ @s = FFISpecs::LibTest::StructWithArray.new(FFISpecs::LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
+ @s[:a].to_a.should == [0, 1, 2, 3, 4]
+ end
+
+ it 'should cache array object for successive calls' do
+ @s[:a].object_id.should == @s[:a].object_id
+ end
+
+ it 'should return the size of the array field in bytes' do
+ @s = FFISpecs::LibTest::StructWithArray.new(FFISpecs::LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
+ @s[:a].size.should == 20
+ end
+
+ it 'should allow iteration through the array elements' do
+ @s = FFISpecs::LibTest::StructWithArray.new(FFISpecs::LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
+ @s[:a].each_with_index { |elem, i| elem.should == i }
+ end
+
+ it 'should return the pointer to the array' do
+ @s = FFISpecs::LibTest::StructWithArray.new(FFISpecs::LibTest.struct_make_struct_with_array(0, 1, 2, 3, 4))
+ @s[:a].to_ptr.should == FFISpecs::LibTest::struct_field_array(@s.to_ptr)
+ end
+end
+
+describe 'BuggedStruct' do
+ it 'should return its correct size' do
+ FFISpecs::LibTest::BuggedStruct.size.should == FFISpecs::LibTest.bugged_struct_size
+ end
+
+ it "offsets within struct should be correct" do
+ FFISpecs::LibTest::BuggedStruct.offset_of(:visible).should == 0
+ FFISpecs::LibTest::BuggedStruct.offset_of(:x).should == 4
+ FFISpecs::LibTest::BuggedStruct.offset_of(:y).should == 8
+ FFISpecs::LibTest::BuggedStruct.offset_of(:rx).should == 12
+ FFISpecs::LibTest::BuggedStruct.offset_of(:ry).should == 14
+ FFISpecs::LibTest::BuggedStruct.offset_of(:order).should == 16
+ FFISpecs::LibTest::BuggedStruct.offset_of(:size).should == 17
+ end
+
+ it 'should return correct field/offset pairs' do
+ FFISpecs::LibTest::BuggedStruct.offsets.sort do |a, b|
+ a[1] <=> b[1]
+ end.should == [[:visible, 0], [:x, 4], [:y, 8], [:rx, 12], [:ry, 14], [:order, 16], [:size, 17]]
+ end
+end
+
+describe "Struct allocation" do
+ before :all do
+ @klass = Class.new(FFI::Struct)
+ @klass.layout :i, :uint
+ end
+
+ it "MemoryPointer.new(Struct, 2)" do
+ p = FFI::MemoryPointer.new(@klass, 2)
+ p.total.should == 8
+ p.type_size.should == 4
+ p.put_uint(4, 0xdeadbeef)
+ @klass.new(p[1])[:i].should == 0xdeadbeef
+ p[1].address.should == (p[0].address + 4)
+ end
+
+ it "Buffer.new(Struct, 2)" do
+ p = FFI::Buffer.new(@klass, 2)
+ p.total.should == 8
+ p.type_size.should == 4
+ p.put_uint(4, 0xdeadbeef)
+ @klass.new(p[1])[:i].should == 0xdeadbeef
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/typedef_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/typedef_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/typedef_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,42 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+describe "Custom type definitions" do
+ before :each do
+ @mod = Module.new do
+ extend FFI::Library
+ ffi_lib FFISpecs::LIBRARY
+ end
+ end
+
+ it "attach_function with custom typedef" do
+ @mod.typedef :uint, :fubar_t
+ @mod.attach_function :ret_u32, [ :fubar_t ], :fubar_t
+
+ @mod.ret_u32(0x12345678).should == 0x12345678
+ end
+
+ it "variadic invoker with custom typedef" do
+ @mod.typedef :uint, :fubar_t
+ @mod.attach_function :pack_varargs, [ :buffer_out, :string, :varargs ], :void
+
+ buf = FFI::Buffer.new :uint, 10
+ @mod.pack_varargs(buf, "i", :fubar_t, 0x12345678)
+ buf.get_int64(0).should == 0x12345678
+ end
+
+ it "Callback with custom typedef parameter" do
+ @mod.typedef :uint, :fubar3_t
+ @mod.callback :cbIrV, [ :fubar3_t ], :void
+ @mod.attach_function :testCallbackU32rV, :testClosureIrV, [ :cbIrV, :fubar3_t ], :void
+
+ i = 0
+ @mod.testCallbackU32rV(0xdeadbeef) { |v| i = v }
+ i.should == 0xdeadbeef
+ end
+
+ it "Struct with custom typedef field" do
+ s = FFISpecs::StructCustomTypedef::S.new
+ s[:a] = 0x12345678
+ s.pointer.get_uint(0).should == 0x12345678
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/union_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/union_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/union_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,37 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+describe 'Union' do
+ before do
+ @u = FFISpecs::LibTest::TestUnion.new
+ end
+
+ it 'should place all the fields at offset 0' do
+ FFISpecs::LibTest::TestUnion.members.all? { |m| FFISpecs::LibTest::TestUnion.offset_of(m) == 0 }.should be_true
+ end
+
+ FFISpecs::LibTest::Types.each do |k, type|
+ it "should correctly align/write a #{type[0]} value" do
+ @u[type[1]] = type[2]
+ if k == 'f32' or k == 'f64'
+ (@u[type[1]] - FFISpecs::LibTest.send("union_align_#{k}", @u.to_ptr)).abs.should < 0.00001
+ else
+ @u[type[1]].should == FFISpecs::LibTest.send("union_align_#{k}", @u.to_ptr)
+ end
+ end
+ end
+
+ FFISpecs::LibTest::Types.each do |k, type|
+ it "should read a #{type[0]} value from memory" do
+ @u = FFISpecs::LibTest::TestUnion.new(FFISpecs::LibTest.send("union_make_union_with_#{k}", type[2]))
+ if k == 'f32' or k == 'f64'
+ (@u[type[1]] - type[2]).abs.should < 0.00001
+ else
+ @u[type[1]].should == type[2]
+ end
+ end
+ end
+
+ it 'should return a size equals to the size of the biggest field' do
+ FFISpecs::LibTest::TestUnion.size.should == FFISpecs::LibTest.union_size
+ end
+end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/optional/ffi/variadic_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/optional/ffi/variadic_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/optional/ffi/variadic_spec.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,65 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+describe "Function with variadic arguments" do
+ [ 0, 127, -128, -1 ].each do |i|
+ it "call variadic with (:char (#{i})) argument" do
+ buf = FFI::Buffer.new :long_long
+ FFISpecs::LibTest.pack_varargs(buf, "c", :char, i)
+ buf.get_int64(0).should == i
+ end
+ end
+
+ [ 0, 0x7f, 0x80, 0xff ].each do |i|
+ it "call variadic with (:uchar (#{i})) argument" do
+ buf = FFI::Buffer.new :long_long
+ FFISpecs::LibTest.pack_varargs(buf, "C", :uchar, i)
+ buf.get_int64(0).should == i
+ end
+ end
+
+ [ 0, 1.234567, 9.87654321 ].each do |v|
+ it "call variadic with (:float (#{v})) argument" do
+ buf = FFI::Buffer.new :long_long
+ FFISpecs::LibTest.pack_varargs(buf, "f", :float, v.to_f)
+ buf.get_float64(0).should == v
+ end
+ end
+
+ [ 0, 1.234567, 9.87654321 ].each do |v|
+ it "call variadic with (:double (#{v})) argument" do
+ buf = FFI::Buffer.new :long_long
+ FFISpecs::LibTest.pack_varargs(buf, "f", :double, v.to_f)
+ buf.get_float64(0).should == v
+ end
+ end
+
+ def self.verify(p, off, v)
+ if v.kind_of?(Float)
+ p.get_float64(off).should == v
+ else
+ p.get_int64(off).should == v
+ end
+ end
+
+ FFISpecs::Varargs::PACK_VALUES.keys.each do |t1|
+ FFISpecs::Varargs::PACK_VALUES.keys.each do |t2|
+ FFISpecs::Varargs::PACK_VALUES.keys.each do |t3|
+ FFISpecs::Varargs::PACK_VALUES[t1].each do |v1|
+ FFISpecs::Varargs::PACK_VALUES[t2].each do |v2|
+ FFISpecs::Varargs::PACK_VALUES[t3].each do |v3|
+ fmt = "#{t1}#{t2}#{t3}"
+ params = [ FFISpecs::Varargs::TYPE_MAP[t1], v1, FFISpecs::Varargs::TYPE_MAP[t2], v2, FFISpecs::Varargs::TYPE_MAP[t3], v3 ]
+ it "call(#{fmt}, #{params.join(',')})" do
+ buf = FFI::Buffer.new :long_long, 3
+ FFISpecs::LibTest.pack_varargs(buf, fmt, *params)
+ verify(buf, 0, v1)
+ verify(buf, 8, v2)
+ verify(buf, 16, v3)
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
Modified: MacRuby/branches/experimental/spec/frozen/ruby.1.8.mspec
===================================================================
--- MacRuby/branches/experimental/spec/frozen/ruby.1.8.mspec 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/ruby.1.8.mspec 2009-06-14 18:58:26 UTC (rev 1854)
@@ -36,6 +36,12 @@
# An ordered list of the directories containing specs to run
set :files, get(:language) + get(:core) + get(:library)
- # The default implementation to run the specs.
+ # Optional library specs
+ set :ffi, 'optional/ffi'
+
+ # A list of _all_ optional library specs
+ set :optional, [get(:ffi)]
+
+ # The default implementation to run the specs
set :target, 'ruby'
end
Modified: MacRuby/branches/experimental/spec/frozen/ruby.1.9.mspec
===================================================================
--- MacRuby/branches/experimental/spec/frozen/ruby.1.9.mspec 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/ruby.1.9.mspec 2009-06-14 18:58:26 UTC (rev 1854)
@@ -55,6 +55,12 @@
# This set of files is run by mspec ci
set :ci_files, get(:files)
+ # Optional library specs
+ set :ffi, 'optional/ffi'
+
+ # A list of _all_ optional library specs
+ set :optional, [get(:ffi)]
+
# The default implementation to run the specs.
# TODO: this needs to be more sophisticated since the
# executable is not consistently named.
Added: MacRuby/branches/experimental/spec/frozen/shared/kernel/method_missing.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/kernel/method_missing.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/kernel/method_missing.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,60 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/../../fixtures/kernel/classes'
+
+describe :method_missing, :shared => true do
+ it "is a private method" do
+ @object.should have_private_instance_method(:method_missing)
+ end
+
+ it "is not called when a defined method is called" do
+ KernelSpecs::MethodMissing.should_not_receive(:method_missing)
+ KernelSpecs::MethodMissingC.should_not_receive(:method_missing)
+ obj = KernelSpecs::MethodMissingC.new
+ obj.should_not_receive(:method_missing)
+
+ KernelSpecs::MethodMissing.existing.should == :existing
+ KernelSpecs::MethodMissingC.existing.should == :existing
+ obj.existing.should == :instance_existing
+ end
+
+ it "is called when an undefined method is called" do
+ KernelSpecs::MethodMissing.nonexistent.should == :method_missing
+ KernelSpecs::MethodMissingC.nonexistent.should == :method_missing
+ KernelSpecs::MethodMissingC.new.nonexistent.should == :instance_method_missing
+ end
+
+ it "is called when a private method is called" do
+ KernelSpecs::MethodMissing.private_method.should == :method_missing
+ KernelSpecs::MethodMissingC.private_method.should == :method_missing
+ KernelSpecs::MethodMissingC.new.private_method.should == :instance_method_missing
+ end
+
+ it "is called when a protected method is called" do
+ KernelSpecs::MethodMissingC.protected_method.should == :method_missing
+ KernelSpecs::MethodMissingC.new.protected_method.should == :instance_method_missing
+ end
+end
+
+describe :method_missing_undef, :shared => true do
+ it "a NoMethodError is raised when an undefined method is called" do
+ lambda { KernelSpecs::NoMethodMissing.nonexistent }.should raise_error(NoMethodError)
+ lambda { KernelSpecs::NoMethodMissingC.nonexistent }.should raise_error(NoMethodError)
+ lambda { KernelSpecs::NoMethodMissingC.new.nonexistent }.should raise_error(NoMethodError)
+ end
+
+ it "a NoMethodError is raised when a private method is called" do
+ lambda { KernelSpecs::NoMethodMissing.nonexistent }.should raise_error(NoMethodError)
+ lambda { KernelSpecs::NoMethodMissingC.nonexistent }.should raise_error(NoMethodError)
+ lambda { KernelSpecs::NoMethodMissingC.new.nonexistent }.should raise_error(NoMethodError)
+ end
+
+ it "a NoMethodError is raised when a protected method is called" do
+ lambda { KernelSpecs::NoMethodMissing.nonexistent }.should raise_error(NoMethodError)
+ lambda { KernelSpecs::NoMethodMissingC.nonexistent }.should raise_error(NoMethodError)
+ lambda { KernelSpecs::NoMethodMissingC.new.nonexistent }.should raise_error(NoMethodError)
+ end
+end
+
+describe :method_missing_class_method, :shared => true do
+ it "needs to be reviewed for spec completeness"
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/kernel/singleton_method_added.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/kernel/singleton_method_added.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/kernel/singleton_method_added.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe :singleton_method_added, :shared => true do
+ it "is a private method" do
+ @object.should have_private_instance_method(@method)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/kernel/singleton_method_removed.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/kernel/singleton_method_removed.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/kernel/singleton_method_removed.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe :singleton_method_removed, :shared => true do
+ it "is a private method" do
+ @object.should have_private_instance_method(@method)
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/shared/kernel/singleton_method_undefined.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/shared/kernel/singleton_method_undefined.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/shared/kernel/singleton_method_undefined.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe :singleton_method_undefined, :shared => true do
+ it "is a private method" do
+ @object.should have_private_instance_method(@method)
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/spec_helper.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/spec_helper.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/spec_helper.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -12,6 +12,14 @@
require 'mspec/matchers/equal_element'
require 'mspec/matchers/equal_utf16'
require 'mspec/matchers/match_yaml'
+ require 'mspec/matchers/have_class_variable'
+ require 'mspec/matchers/have_constant'
+ require 'mspec/matchers/have_instance_method'
+ require 'mspec/matchers/have_instance_variable'
+ require 'mspec/matchers/have_method'
+ require 'mspec/matchers/have_private_instance_method'
+ require 'mspec/matchers/have_protected_instance_method'
+ require 'mspec/matchers/have_public_instance_method'
# Code to setup HOME directory correctly on Windows
# This duplicates Ruby 1.9 semantics for defining HOME
@@ -40,7 +48,7 @@
end
end
-minimum_version = "1.5.10"
+minimum_version = "1.5.12"
unless MSpec::VERSION >= minimum_version
puts "Please install MSpec version >= #{minimum_version} to run the specs"
exit 1
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/closed_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/closed_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/closed_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:ARGF.closed? returns true if the current stream has been closed
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/each_line_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/each_line_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/each_line_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:ARGF.each_line reads each line of files
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/each_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/each_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/each_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:ARGF.each reads each line of files
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/eof_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/eof_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/eof_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,4 +0,0 @@
-fails:ARGF.eof returns true when reaching the end of a file
-fails:ARGF.eof raises IOError when called on a closed stream
-fails:ARGF.eof? returns true when reaching the end of a file
-fails:ARGF.eof? raises IOError when called on a closed stream
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/file_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/file_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/file_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:ARGF.file returns the current file object on each file
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/filename_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/filename_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/filename_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:ARGF.filename returns the current file name on each file
-fails:ARGF.filename it sets the $FILENAME global variable with the current file name on each file
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/fileno_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/fileno_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/fileno_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:ARGF.fileno returns the current file number on each file
-fails:ARGF.fileno raises an ArgumentError when called on a closed stream
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/getc_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/getc_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/getc_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:ARGF.getc reads each char of files
-fails:ARGF.getc returns nil when end of stream reached
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/gets_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/gets_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/gets_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,6 +0,0 @@
-fails:ARGF.gets reads one line of a file
-fails:ARGF.gets reads all lines of a file
-fails:ARGF.gets reads all lines of stdin
-fails:ARGF.gets reads all lines of two files
-fails:ARGF.gets sets $_ global variable with each line read
-fails:ARGF.gets returns nil when reaching end of files
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/path_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/path_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/path_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:ARGF.path returns the current file name on each file
-fails:ARGF.path it sets the $FILENAME global variable with the current file name on each file
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/pos_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/pos_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/pos_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,3 +0,0 @@
-fails:ARGF.pos gives the correct position for each read operation
-fails:ARGF.pos raises an ArgumentError when called on a closed stream
-fails:ARGF.pos= sets the correct position in files
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/read_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/read_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/read_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,14 +0,0 @@
-fails:ARGF.read reads the contents of a file
-fails:ARGF.read treats first nil argument as no length limit
-fails:ARGF.read treats second nil argument as no output buffer
-fails:ARGF.read treats second argument as an output buffer
-fails:ARGF.read reads a number of bytes from the first file
-fails:ARGF.read reads from a single file consecutively
-fails:ARGF.read reads the contents of two files
-fails:ARGF.read reads the contents of one file and some characters from the second
-fails:ARGF.read reads across two files consecutively
-fails:ARGF.read reads the contents of stdin
-fails:ARGF.read reads a number of bytes from stdin
-fails:ARGF.read reads the contents of one file and stdin
-fails:ARGF.read reads the contents of the same file twice
-fails:ARGF.read reads the contents of a special device file
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/readchar_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/readchar_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/readchar_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:ARGF.getc reads each char of files
-fails:ARGF.readchar raises EOFError when end of stream reached
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/readline_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/readline_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/readline_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,6 +0,0 @@
-fails:ARGF.readline reads one line of a file
-fails:ARGF.readline reads all lines of a file
-fails:ARGF.readline reads all lines of stdin
-fails:ARGF.readline reads all lines of two files
-fails:ARGF.readline sets $_ global variable with each line read
-fails:ARGF.readline raises an EOFError when reaching end of files
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/readlines_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/readlines_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/readlines_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:ARGF.readlines reads all lines of all files
-fails:ARGF.readlines returns nil when end of stream reached
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/rewind_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/rewind_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/rewind_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:ARGF.rewind goes back to beginning of current file
-fails:ARGF.rewind raises an ArgumentError when end of stream reached
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/seek_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/seek_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/seek_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,4 +0,0 @@
-fails:ARGF.seek sets the absolute position relative to beginning of file
-fails:ARGF.seek sets the position relative to current position in file
-fails:ARGF.seek sets the absolute position relative to end of file
-fails:ARGF.seek takes at least one argument (offset)
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/tell_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/tell_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/tell_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:ARGF.tell gives the correct position for each read operation
-fails:ARGF.tell raises an ArgumentError when called on a closed stream
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/to_a_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/to_a_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/to_a_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:ARGF.to_a reads all lines of all files
-fails:ARGF.to_a returns nil when end of stream reached
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/to_i_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/to_i_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/to_i_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:ARGF.to_i returns the current file number on each file
-fails:ARGF.to_i raises an ArgumentError when called on a closed stream
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/to_io_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/to_io_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/to_io_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:ARGF.to_io returns the IO of the current file
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/to_s_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/to_s_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/argf/to_s_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:ARGF.to_s returns 'ARGF'
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/continuation/continuation_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/continuation/continuation_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/continuation/continuation_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,7 +0,0 @@
-fails:Creating a Continuation object must be done through Kernel.callcc, no .new
-fails:Executing a Continuation using #call transfers execution to right after the Kernel.callcc block
-fails:Executing a Continuation arguments given to #call (or nil) are returned by the Kernel.callcc block (as Array unless only one object)
-fails:Executing a Continuation #[] is an alias for #call
-fails:Executing a Continuation closes over lexical environments
-fails:Executing a Continuation escapes an inner ensure block
-fails:Executing a Continuation executes an outer ensure block
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/dir/delete_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/dir/delete_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/dir/delete_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:Dir.delete raises a SystemCallError if lacking adequate permissions to remove the directory
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/dir/pwd_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/dir/pwd_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/dir/pwd_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:Dir.pwd correctly displays dirs with unicode characters in them
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/dir/rmdir_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/dir/rmdir_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/dir/rmdir_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:Dir.rmdir raises a SystemCallError if lacking adequate permissions to remove the directory
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/dir/unlink_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/dir/unlink_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/dir/unlink_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:Dir.unlink raises a SystemCallError if lacking adequate permissions to remove the directory
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/delete_if_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/delete_if_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/delete_if_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:ENV.delete_if returns an Enumerator if no block given
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/each_key_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/each_key_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/each_key_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:ENV.each_key returns an Enumerator if called without a block
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/each_pair_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/each_pair_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/each_pair_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:ENV.each_pair returns an Enumerator if called without a block
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/each_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/each_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/each_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:ENV.each returns an Enumerator if called without a block
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/each_value_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/each_value_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/each_value_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:ENV.each_value returns an Enumerator if called without a block
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/reject_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/reject_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/reject_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:ENV.reject! returns an Enumerator if called without a block
-fails:ENV.reject returns an Enumerator if called without a block
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/select_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/select_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/env/select_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:ENV.select returns the Hash for which block return true
-fails:ENV.select returns an Enumerator when no block is given
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/exception/standard_error_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/exception/standard_error_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/exception/standard_error_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:StandardError is a superclass of SecurityError
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/file/new_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/file/new_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/file/new_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,3 +0,0 @@
-fails:File.new raises an Errno::EINVAL error with File::APPEND
-fails:File.new raises an Errno::EINVAL error with File::RDONLY|File::APPEND
-fails:File.new can't alter mode or permissions when opening a file
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/float/induced_from_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/float/induced_from_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/float/induced_from_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,5 +0,0 @@
-fails:Float.induced_from returns the passed argument when passed a Float
-fails:Float.induced_from converts passed Fixnums or Bignums to Floats (using #to_f)
-fails:Float.induced_from does not try to convert non-Integers to Integers using #to_int
-fails:Float.induced_from does not try to convert non-Integers to Floats using #to_f
-fails:Float.induced_from raises a TypeError when passed a non-Integer
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/kernel/require_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/kernel/require_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/kernel/require_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,12 +0,0 @@
-fails:Kernel#require loads a .rb from a relative path and returns true
-fails:Kernel#require allows unqualified files to contain path information (just not in the beginning)
-fails:Kernel#require appends a file with no extension with .rb/.<ext> in that order to locate file
-fails:Kernel#require prefers to use .rb over .<ext> if given non-extensioned file and both exist
-fails:Kernel#require will load file.rb when given 'file' if it exists even if file.<ext> is loaded
-fails:Kernel#require produces __FILE__ as the given filename and __LINE__ as the source line number
-fails:Kernel#require stores the loaded file in $LOADED_FEATURES
-fails:Kernel#require stores a non-extensioned file with its located suffix
-fails:Kernel#require bases the filename in $LOADED_FEATURES on the path given, not just basename
-fails:Kernel#require will not load the same file twice, returns false instead
-fails:Kernel#require checks $LOADED_FEATURES to see whether file is already loaded
-fails:Kernel#require does not infinite loop on an rb file that requires itself
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/matchdata/select_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/matchdata/select_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/matchdata/select_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:MatchData#select yields the contents of the match array to a block
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/acosh_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/acosh_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/acosh_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.acosh raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.acosh accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/asin_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/asin_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/asin_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.asin raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.asin accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/asinh_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/asinh_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/asinh_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.asinh raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.asinh accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/atan2_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/atan2_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/atan2_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.atan2 raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.atan2 accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/atan_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/atan_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/atan_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.atan raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.atan accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/atanh_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/atanh_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/atanh_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,4 +0,0 @@
-fails:Math.atanh returns Infinity for 1.0
-fails:Math.atanh returns -Infinity for -1.0
-fails:Math.atanh raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.atanh accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/cos_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/cos_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/cos_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.cos raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.cos accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/cosh_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/cosh_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/cosh_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.cosh raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.cosh accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/erf_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/erf_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/erf_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.erf raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.erf accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/erfc_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/erfc_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/erfc_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.erfc raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.erfc accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/exp_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/exp_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/exp_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.exp raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.exp accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/frexp_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/frexp_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/frexp_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.frexp raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.frexp accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/hypot_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/hypot_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/hypot_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.hypot raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.hypot accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/ldexp_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/ldexp_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/ldexp_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.ldexp raises an ArgumentError if the first argument cannot be coerced with Float()
-fails:Math.ldexp accepts any first argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/log10_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/log10_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/log10_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.log10 raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.log10 accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/log_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/log_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/log_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.log raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.log accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/sin_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/sin_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/sin_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.sin raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.sin accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/sinh_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/sinh_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/sinh_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.sinh raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.sinh accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/sqrt_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/sqrt_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/sqrt_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,3 +0,0 @@
-fails:Math.sqrt raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.sqrt accepts any argument that can be coerced with Float()
-fails:Math.sqrt returns the square root of the argument
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/tan_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/tan_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/tan_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.tan raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.tan accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/tanh_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/tanh_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/math/tanh_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,2 +0,0 @@
-fails:Math.tanh raises an ArgumentError if the argument cannot be coerced with Float()
-fails:Math.tanh accepts any argument that can be coerced with Float()
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/object/match_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/object/match_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/object/match_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:Object =~ returns false matching any object
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/regexp/compile_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/regexp/compile_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/regexp/compile_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,7 +0,0 @@
-fails:Regexp.compile given a String does not enable multibyte support by default
-fails:Regexp.compile given a String enables EUC encoding if third argument is 'e' or 'euc' (case-insensitive)
-fails:Regexp.compile given a String enables SJIS encoding if third argument is 's' or 'sjis' (case-insensitive)
-fails:Regexp.compile given a String enables UTF-8 encoding if third argument is 'u' or 'utf8' (case-insensitive)
-fails:Regexp.compile given a String disables multibyte support if third argument is 'n' or 'none' (case insensitive)
-fails:Regexp.compile given a Regexp does not enable multibyte support by default
-fails:Regexp.compile given a Regexp enables multibyte support if given in the literal
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/regexp/kcode_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/regexp/kcode_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/regexp/kcode_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:Regexp#kcode returns the character set code
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/regexp/new_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/regexp/new_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/regexp/new_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,7 +0,0 @@
-fails:Regexp.new given a String does not enable multibyte support by default
-fails:Regexp.new given a String enables EUC encoding if third argument is 'e' or 'euc' (case-insensitive)
-fails:Regexp.new given a String enables SJIS encoding if third argument is 's' or 'sjis' (case-insensitive)
-fails:Regexp.new given a String enables UTF-8 encoding if third argument is 'u' or 'utf8' (case-insensitive)
-fails:Regexp.new given a String disables multibyte support if third argument is 'n' or 'none' (case insensitive)
-fails:Regexp.new given a Regexp does not enable multibyte support by default
-fails:Regexp.new given a Regexp enables multibyte support if given in the literal
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/struct/each_pair_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/struct/each_pair_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/struct/each_pair_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:Struct#each_pair returns an Enumerator if not passed a block
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/struct/each_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/struct/each_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/struct/each_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:Struct#each returns an Enumerator if not passed a block
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/struct/members_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/struct/members_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/struct/members_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +0,0 @@
-fails:Struct#members returns an array of attribute names
Deleted: MacRuby/branches/experimental/spec/frozen/tags/1.9/core/struct/new_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/1.9/core/struct/new_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/1.9/core/struct/new_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,7 +0,0 @@
-fails:Struct.new creates a new anonymous class with nil first argument
-fails:Struct.new creates a new anonymous class with symbol arguments
-fails:Struct.new accepts Fixnums as Symbols unless fixnum.to_sym.nil?
-fails:Struct.new raises an ArgumentError if fixnum#to_sym is nil
-fails:Struct.new instance_eval's a passed block
-fails:Struct.new creates reader methods
-fails:Struct.new creates writer methods
Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/throw_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/throw_tags.txt 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/kernel/throw_tags.txt 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,4 +1,5 @@
critical:Kernel.throw transfers control to the innermost catch block waiting for the same sympol
critical:Kernel.throw raises NameError if there is no catch block for the symbol
+critical:Kernel.throw raises an ArgumentError if there is no catch block for the symbol
fails:Kernel.throw raises TypeError if the first argument is not a symbol
fails:Kernel#throw is a private method
\ No newline at end of file
Modified: MacRuby/branches/experimental/spec/frozen/upstream
===================================================================
--- MacRuby/branches/experimental/spec/frozen/upstream 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/upstream 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1 +1 @@
-dbbd5f2ad63092b640b7b211a25dd913aee36422
\ No newline at end of file
+9c5b3ddd2703ce570abad92592764361e065703f
\ No newline at end of file
Modified: MacRuby/branches/experimental/spec/frozen/version.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/version.rb 2009-06-14 18:53:44 UTC (rev 1853)
+++ MacRuby/branches/experimental/spec/frozen/version.rb 2009-06-14 18:58:26 UTC (rev 1854)
@@ -1,3 +1,3 @@
module RubySpec
- VERSION = "0.7.5"
+ VERSION = "0.7.6"
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090614/3faebbf4/attachment-0001.html>
More information about the macruby-changes
mailing list