From 9dc121cc577ae7a010bca7efedb79088e3cf7331 Mon Sep 17 00:00:00 2001 From: eregon Date: Wed, 27 Jun 2018 12:30:05 +0000 Subject: Update to ruby/spec@a454137 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/ruby/.rubocop.yml | 5 + spec/ruby/.rubocop_todo.yml | 2 - spec/ruby/command_line/rubylib_spec.rb | 67 +++++++++++ spec/ruby/command_line/rubyopt_spec.rb | 4 +- spec/ruby/core/class/inherited_spec.rb | 1 - spec/ruby/core/enumerable/zip_spec.rb | 1 - spec/ruby/core/env/shared/key.rb | 2 - .../core/exception/uncaught_throw_error_spec.rb | 1 - .../float/shared/arithmetic_exception_in_coerce.rb | 1 - .../float/shared/comparison_exception_in_coerce.rb | 1 - spec/ruby/core/hash/clone_spec.rb | 1 - spec/ruby/core/hash/has_key_spec.rb | 1 - spec/ruby/core/hash/has_value_spec.rb | 1 - spec/ruby/core/hash/value_spec.rb | 1 - spec/ruby/core/integer/abs_spec.rb | 1 - spec/ruby/core/integer/divide_spec.rb | 1 - spec/ruby/core/integer/equal_value_spec.rb | 1 - spec/ruby/core/integer/gt_spec.rb | 1 - spec/ruby/core/integer/gte_spec.rb | 1 - spec/ruby/core/integer/lt_spec.rb | 1 - spec/ruby/core/integer/lte_spec.rb | 1 - spec/ruby/core/integer/magnitude_spec.rb | 1 - spec/ruby/core/integer/minus_spec.rb | 1 - spec/ruby/core/integer/multiply_spec.rb | 1 - spec/ruby/core/integer/plus_spec.rb | 1 - spec/ruby/core/io/pos_spec.rb | 1 - spec/ruby/core/io/print_spec.rb | 1 - spec/ruby/core/io/shared/write.rb | 21 ++++ spec/ruby/core/kernel/eql_spec.rb | 1 - spec/ruby/core/kernel/eval_spec.rb | 128 +++++++++++++++++++++ spec/ruby/core/kernel/lambda_spec.rb | 1 - spec/ruby/core/kernel/printf_spec.rb | 1 - spec/ruby/core/module/protected_spec.rb | 1 - spec/ruby/core/string/clone_spec.rb | 1 - spec/ruby/core/string/percent_spec.rb | 1 - spec/ruby/core/systemexit/initialize_spec.rb | 1 - spec/ruby/core/thread/run_spec.rb | 1 - spec/ruby/core/time/_dump_spec.rb | 1 - spec/ruby/core/tracepoint/callee_id_spec.rb | 1 - spec/ruby/language/fixtures/metaclass.rb | 1 - spec/ruby/library/bigdecimal/finite_spec.rb | 1 - spec/ruby/library/bigdecimal/precs_spec.rb | 1 - spec/ruby/library/bigdecimal/quo_spec.rb | 1 - spec/ruby/library/bigdecimal/sign_spec.rb | 1 - spec/ruby/library/bigdecimal/split_spec.rb | 2 - spec/ruby/library/bigdecimal/to_f_spec.rb | 1 - spec/ruby/library/bigdecimal/to_s_spec.rb | 1 - spec/ruby/library/bigdecimal/uplus_spec.rb | 3 - spec/ruby/library/bigdecimal/zero_spec.rb | 1 - spec/ruby/library/date/commercial_spec.rb | 1 - spec/ruby/library/date/gregorian_leap_spec.rb | 1 - spec/ruby/library/date/ordinal_spec.rb | 1 - spec/ruby/library/date/valid_civil_spec.rb | 1 - spec/ruby/library/date/valid_commercial_spec.rb | 2 - spec/ruby/library/date/valid_jd_spec.rb | 1 - spec/ruby/library/date/valid_ordinal_spec.rb | 1 - spec/ruby/library/digest/md5/block_length_spec.rb | 1 - spec/ruby/library/digest/md5/digest_length_spec.rb | 1 - spec/ruby/library/digest/md5/equal_spec.rb | 1 - spec/ruby/library/digest/md5/inspect_spec.rb | 1 - spec/ruby/library/digest/md5/length_spec.rb | 1 - spec/ruby/library/digest/md5/reset_spec.rb | 1 - spec/ruby/library/digest/md5/size_spec.rb | 1 - .../library/digest/sha256/block_length_spec.rb | 1 - .../library/digest/sha256/digest_length_spec.rb | 1 - spec/ruby/library/digest/sha256/equal_spec.rb | 1 - spec/ruby/library/digest/sha256/inspect_spec.rb | 1 - spec/ruby/library/digest/sha256/length_spec.rb | 1 - spec/ruby/library/digest/sha256/reset_spec.rb | 1 - spec/ruby/library/digest/sha256/size_spec.rb | 1 - .../library/digest/sha384/block_length_spec.rb | 1 - .../library/digest/sha384/digest_length_spec.rb | 1 - spec/ruby/library/digest/sha384/equal_spec.rb | 1 - spec/ruby/library/digest/sha384/inspect_spec.rb | 1 - spec/ruby/library/digest/sha384/length_spec.rb | 1 - spec/ruby/library/digest/sha384/reset_spec.rb | 1 - spec/ruby/library/digest/sha384/size_spec.rb | 1 - .../library/digest/sha512/block_length_spec.rb | 1 - .../library/digest/sha512/digest_length_spec.rb | 1 - spec/ruby/library/digest/sha512/equal_spec.rb | 1 - spec/ruby/library/digest/sha512/inspect_spec.rb | 1 - spec/ruby/library/digest/sha512/length_spec.rb | 1 - spec/ruby/library/digest/sha512/reset_spec.rb | 1 - spec/ruby/library/digest/sha512/size_spec.rb | 1 - spec/ruby/library/erb/run_spec.rb | 1 - spec/ruby/library/erb/util/html_escape_spec.rb | 1 - spec/ruby/library/erb/util/u_spec.rb | 1 - spec/ruby/library/ipaddr/ipv4_conversion_spec.rb | 2 - spec/ruby/library/net/http/http/head2_spec.rb | 1 - spec/ruby/library/net/http/http/post_spec.rb | 1 - .../net/http/httpheader/each_capitalized_spec.rb | 1 - .../net/http/httpresponse/read_body_spec.rb | 1 - spec/ruby/library/pathname/absolute_spec.rb | 1 - spec/ruby/library/pathname/equal_value_spec.rb | 1 - spec/ruby/library/pathname/hash_spec.rb | 1 - spec/ruby/library/pathname/parent_spec.rb | 1 - spec/ruby/library/pathname/relative_spec.rb | 1 - spec/ruby/library/pathname/root_spec.rb | 1 - spec/ruby/library/pathname/sub_spec.rb | 1 - spec/ruby/library/rbconfig/rbconfig_spec.rb | 11 ++ spec/ruby/library/rexml/attribute/inspect_spec.rb | 1 - .../ruby/library/rexml/attribute/to_string_spec.rb | 1 - spec/ruby/library/rexml/attribute/value_spec.rb | 1 - spec/ruby/library/rexml/attribute/xpath_spec.rb | 1 - .../rexml/attributes/each_attribute_spec.rb | 3 - spec/ruby/library/rexml/attributes/each_spec.rb | 2 - .../rexml/attributes/element_reference_spec.rb | 1 - .../library/rexml/attributes/element_set_spec.rb | 1 - spec/ruby/library/rexml/attributes/to_a_spec.rb | 1 - .../library/rexml/element/add_namespace_spec.rb | 1 - spec/ruby/library/rexml/element/document_spec.rb | 2 - spec/ruby/library/rexml/node/parent_spec.rb | 1 - spec/ruby/library/rexml/text/indent_text_spec.rb | 1 - spec/ruby/library/rexml/text/new_spec.rb | 1 - .../rexml/text/read_with_substitution_spec.rb | 1 - spec/ruby/library/rexml/text/to_s_spec.rb | 1 - spec/ruby/library/rexml/text/wrap_spec.rb | 1 - spec/ruby/library/set/case_compare_spec.rb | 1 - .../ruby/library/socket/socket/getaddrinfo_spec.rb | 2 +- spec/ruby/library/stringio/each_codepoint_spec.rb | 1 - spec/ruby/library/stringio/open_spec.rb | 1 - spec/ruby/library/stringio/printf_spec.rb | 1 - spec/ruby/library/stringio/stringio_spec.rb | 1 - .../stringscanner/element_reference_spec.rb | 1 - spec/ruby/library/stringscanner/peek_spec.rb | 1 - spec/ruby/library/tempfile/open_spec.rb | 1 - spec/ruby/library/uri/set_component_spec.rb | 2 - .../library/zlib/deflate/set_dictionary_spec.rb | 1 - spec/ruby/library/zlib/gzipfile/close_spec.rb | 1 - spec/ruby/library/zlib/gzipfile/closed_spec.rb | 1 - spec/ruby/library/zlib/gzipfile/comment_spec.rb | 1 - spec/ruby/library/zlib/gzipfile/orig_name_spec.rb | 1 - spec/ruby/library/zlib/gzipreader/pos_spec.rb | 1 - .../library/zlib/inflate/set_dictionary_spec.rb | 1 - .../library/zlib/zstream/flush_next_out_spec.rb | 2 - spec/ruby/optional/capi/enumerator_spec.rb | 27 +++++ spec/ruby/optional/capi/ext/enumerator_spec.c | 15 +++ spec/ruby/optional/capi/ext/kernel_spec.c | 11 ++ spec/ruby/optional/capi/ext/rubyspec.h | 3 + spec/ruby/optional/capi/ext/string_spec.c | 12 +- spec/ruby/optional/capi/kernel_spec.rb | 7 ++ spec/ruby/optional/capi/rake_helper.rb | 1 - spec/ruby/optional/capi/string_spec.rb | 19 +++ 143 files changed, 328 insertions(+), 146 deletions(-) create mode 100644 spec/ruby/command_line/rubylib_spec.rb create mode 100644 spec/ruby/library/rbconfig/rbconfig_spec.rb diff --git a/spec/ruby/.rubocop.yml b/spec/ruby/.rubocop.yml index cec5309dc8..c544fa5fd0 100644 --- a/spec/ruby/.rubocop.yml +++ b/spec/ruby/.rubocop.yml @@ -10,6 +10,11 @@ AllCops: Layout/TrailingWhitespace: Enabled: true +Layout/TrailingBlankLines: + Enabled: true + Exclude: + - library/coverage/fixtures/some_class.rb + Lint: Enabled: true diff --git a/spec/ruby/.rubocop_todo.yml b/spec/ruby/.rubocop_todo.yml index 9484078c8e..289471dde6 100644 --- a/spec/ruby/.rubocop_todo.yml +++ b/spec/ruby/.rubocop_todo.yml @@ -87,12 +87,10 @@ Lint/MultipleCompare: # Offense count: 12 Lint/ParenthesesAsGroupedExpression: Exclude: - - 'command_line/rubyopt_spec.rb' - 'core/string/fixtures/freeze_magic_comment.rb' - 'language/block_spec.rb' - 'language/fixtures/send.rb' - 'language/method_spec.rb' - - 'library/socket/socket/getaddrinfo_spec.rb' # Offense count: 1 # Cop supports --auto-correct. diff --git a/spec/ruby/command_line/rubylib_spec.rb b/spec/ruby/command_line/rubylib_spec.rb new file mode 100644 index 0000000000..93184f446d --- /dev/null +++ b/spec/ruby/command_line/rubylib_spec.rb @@ -0,0 +1,67 @@ +require_relative '../spec_helper' + +describe "The RUBYLIB environment variable" do + before :each do + @rubylib, ENV["RUBYLIB"] = ENV["RUBYLIB"], nil + end + + after :each do + ENV["RUBYLIB"] = @rubylib + end + + it "adds a directory to $LOAD_PATH" do + dir = tmp("rubylib/incl") + ENV["RUBYLIB"] = dir + paths = ruby_exe("puts $LOAD_PATH").lines.map(&:chomp) + paths.should include(dir) + end + + it "adds a colon-separated list of directories to $LOAD_PATH" do + dir1, dir2 = tmp("rubylib/incl1"), tmp("rubylib/incl2") + ENV["RUBYLIB"] = "#{dir1}:#{dir2}" + paths = ruby_exe("puts $LOAD_PATH").lines.map(&:chomp) + paths.should include(dir1) + paths.should include(dir2) + paths.index(dir1).should < paths.index(dir2) + end + + it "adds the directory at the front of $LOAD_PATH" do + dir = tmp("rubylib/incl_front") + ENV["RUBYLIB"] = dir + paths = ruby_exe("puts $LOAD_PATH").lines.map(&:chomp) + if PlatformGuard.implementation? :ruby + # In a MRI checkout, $PWD and some extra -I entries end up as + # the first entries in $LOAD_PATH. So just assert that it's not last. + idx = paths.index(dir) + idx.should < paths.size-1 + else + paths[0].should == dir + end + end + + it "adds the directory after directories added by -I" do + dash_i_dir = tmp("dash_I_include") + rubylib_dir = tmp("rubylib_include") + ENV["RUBYLIB"] = rubylib_dir + paths = ruby_exe("puts $LOAD_PATH", options: "-I #{dash_i_dir}").lines.map(&:chomp) + paths.should include(dash_i_dir) + paths.should include(rubylib_dir) + paths.index(dash_i_dir).should < paths.index(rubylib_dir) + end + + it "adds the directory after directories added by -I within RUBYOPT" do + rubyopt_dir = tmp("rubyopt_include") + rubylib_dir = tmp("rubylib_include") + ENV["RUBYLIB"] = rubylib_dir + paths = ruby_exe("puts $LOAD_PATH", env: { "RUBYOPT" => "-I#{rubyopt_dir}" }).lines.map(&:chomp) + paths.should include(rubyopt_dir) + paths.should include(rubylib_dir) + paths.index(rubyopt_dir).should < paths.index(rubylib_dir) + end + + it "keeps spaces in the value" do + ENV["RUBYLIB"] = " rubylib/incl " + out = ruby_exe("puts $LOAD_PATH") + out.should include(" rubylib/incl ") + end +end diff --git a/spec/ruby/command_line/rubyopt_spec.rb b/spec/ruby/command_line/rubyopt_spec.rb index 81a57f97c3..50f5d5d0a8 100644 --- a/spec/ruby/command_line/rubyopt_spec.rb +++ b/spec/ruby/command_line/rubyopt_spec.rb @@ -1,11 +1,11 @@ require_relative '../spec_helper' describe "Processing RUBYOPT" do - before (:each) do + before :each do @rubyopt, ENV["RUBYOPT"] = ENV["RUBYOPT"], nil end - after (:each) do + after :each do ENV["RUBYOPT"] = @rubyopt end diff --git a/spec/ruby/core/class/inherited_spec.rb b/spec/ruby/core/class/inherited_spec.rb index 0ec0d84f6e..fb7fb8e75a 100644 --- a/spec/ruby/core/class/inherited_spec.rb +++ b/spec/ruby/core/class/inherited_spec.rb @@ -99,4 +99,3 @@ describe "Class.inherited" do end end - diff --git a/spec/ruby/core/enumerable/zip_spec.rb b/spec/ruby/core/enumerable/zip_spec.rb index d5a059bc5d..1212911697 100644 --- a/spec/ruby/core/enumerable/zip_spec.rb +++ b/spec/ruby/core/enumerable/zip_spec.rb @@ -39,4 +39,3 @@ describe "Enumerable#zip" do end end - diff --git a/spec/ruby/core/env/shared/key.rb b/spec/ruby/core/env/shared/key.rb index 5e6c21840f..c40a56093e 100644 --- a/spec/ruby/core/env/shared/key.rb +++ b/spec/ruby/core/env/shared/key.rb @@ -11,5 +11,3 @@ describe :env_key, shared: true do ENV.send(@method, "should_never_be_set").should be_nil end end - - diff --git a/spec/ruby/core/exception/uncaught_throw_error_spec.rb b/spec/ruby/core/exception/uncaught_throw_error_spec.rb index f4300441a5..57f391d755 100644 --- a/spec/ruby/core/exception/uncaught_throw_error_spec.rb +++ b/spec/ruby/core/exception/uncaught_throw_error_spec.rb @@ -16,4 +16,3 @@ describe "UncaughtThrowError#tag" do end end end - diff --git a/spec/ruby/core/float/shared/arithmetic_exception_in_coerce.rb b/spec/ruby/core/float/shared/arithmetic_exception_in_coerce.rb index 71b540f752..19a02572d8 100644 --- a/spec/ruby/core/float/shared/arithmetic_exception_in_coerce.rb +++ b/spec/ruby/core/float/shared/arithmetic_exception_in_coerce.rb @@ -31,4 +31,3 @@ describe :float_arithmetic_exception_in_coerce, shared: true do end end end - diff --git a/spec/ruby/core/float/shared/comparison_exception_in_coerce.rb b/spec/ruby/core/float/shared/comparison_exception_in_coerce.rb index 6d6f14da30..f8ded53644 100644 --- a/spec/ruby/core/float/shared/comparison_exception_in_coerce.rb +++ b/spec/ruby/core/float/shared/comparison_exception_in_coerce.rb @@ -33,4 +33,3 @@ describe :float_comparison_exception_in_coerce, shared: true do end end end - diff --git a/spec/ruby/core/hash/clone_spec.rb b/spec/ruby/core/hash/clone_spec.rb index bb726e3ec4..6c96fc0c67 100644 --- a/spec/ruby/core/hash/clone_spec.rb +++ b/spec/ruby/core/hash/clone_spec.rb @@ -10,4 +10,3 @@ describe "Hash#clone" do clone.should_not equal hash end end - diff --git a/spec/ruby/core/hash/has_key_spec.rb b/spec/ruby/core/hash/has_key_spec.rb index 55f17d9ccb..4af53579e5 100644 --- a/spec/ruby/core/hash/has_key_spec.rb +++ b/spec/ruby/core/hash/has_key_spec.rb @@ -5,4 +5,3 @@ require_relative 'shared/key' describe "Hash#has_key?" do it_behaves_like :hash_key_p, :has_key? end - diff --git a/spec/ruby/core/hash/has_value_spec.rb b/spec/ruby/core/hash/has_value_spec.rb index 72663d0806..39f1627fd3 100644 --- a/spec/ruby/core/hash/has_value_spec.rb +++ b/spec/ruby/core/hash/has_value_spec.rb @@ -5,4 +5,3 @@ require_relative 'shared/value' describe "Hash#has_value?" do it_behaves_like :hash_value_p, :has_value? end - diff --git a/spec/ruby/core/hash/value_spec.rb b/spec/ruby/core/hash/value_spec.rb index f8cb72bb4a..0ab16a5d1b 100644 --- a/spec/ruby/core/hash/value_spec.rb +++ b/spec/ruby/core/hash/value_spec.rb @@ -5,4 +5,3 @@ require_relative 'shared/value' describe "Hash#value?" do it_behaves_like :hash_value_p, :value? end - diff --git a/spec/ruby/core/integer/abs_spec.rb b/spec/ruby/core/integer/abs_spec.rb index 7509a83a7e..c40356db12 100644 --- a/spec/ruby/core/integer/abs_spec.rb +++ b/spec/ruby/core/integer/abs_spec.rb @@ -4,4 +4,3 @@ require_relative 'shared/abs' describe "Integer#abs" do it_behaves_like :integer_abs, :abs end - diff --git a/spec/ruby/core/integer/divide_spec.rb b/spec/ruby/core/integer/divide_spec.rb index 6fe509b62c..2d49307628 100644 --- a/spec/ruby/core/integer/divide_spec.rb +++ b/spec/ruby/core/integer/divide_spec.rb @@ -93,4 +93,3 @@ describe "Integer#/" do end end end - diff --git a/spec/ruby/core/integer/equal_value_spec.rb b/spec/ruby/core/integer/equal_value_spec.rb index b527f16b1e..67a73713af 100644 --- a/spec/ruby/core/integer/equal_value_spec.rb +++ b/spec/ruby/core/integer/equal_value_spec.rb @@ -4,4 +4,3 @@ require_relative 'shared/equal' describe "Integer#==" do it_behaves_like :integer_equal, :== end - diff --git a/spec/ruby/core/integer/gt_spec.rb b/spec/ruby/core/integer/gt_spec.rb index 2a3488cb49..14c51c9acc 100644 --- a/spec/ruby/core/integer/gt_spec.rb +++ b/spec/ruby/core/integer/gt_spec.rb @@ -47,4 +47,3 @@ describe "Integer#>" do end end end - diff --git a/spec/ruby/core/integer/gte_spec.rb b/spec/ruby/core/integer/gte_spec.rb index ce379a07e3..3d5c48faa5 100644 --- a/spec/ruby/core/integer/gte_spec.rb +++ b/spec/ruby/core/integer/gte_spec.rb @@ -47,4 +47,3 @@ describe "Integer#>=" do end end end - diff --git a/spec/ruby/core/integer/lt_spec.rb b/spec/ruby/core/integer/lt_spec.rb index f687e0381f..a33a297d8b 100644 --- a/spec/ruby/core/integer/lt_spec.rb +++ b/spec/ruby/core/integer/lt_spec.rb @@ -49,4 +49,3 @@ describe "Integer#<" do end end end - diff --git a/spec/ruby/core/integer/lte_spec.rb b/spec/ruby/core/integer/lte_spec.rb index f9fc417640..1d3ecea2ac 100644 --- a/spec/ruby/core/integer/lte_spec.rb +++ b/spec/ruby/core/integer/lte_spec.rb @@ -52,4 +52,3 @@ describe "Integer#<=" do end end end - diff --git a/spec/ruby/core/integer/magnitude_spec.rb b/spec/ruby/core/integer/magnitude_spec.rb index 8820c83891..48cf1a8534 100644 --- a/spec/ruby/core/integer/magnitude_spec.rb +++ b/spec/ruby/core/integer/magnitude_spec.rb @@ -4,4 +4,3 @@ require_relative 'shared/abs' describe "Integer#magnitude" do it_behaves_like :integer_abs, :magnitude end - diff --git a/spec/ruby/core/integer/minus_spec.rb b/spec/ruby/core/integer/minus_spec.rb index ff933b974f..84db427172 100644 --- a/spec/ruby/core/integer/minus_spec.rb +++ b/spec/ruby/core/integer/minus_spec.rb @@ -47,4 +47,3 @@ describe "Integer#-" do end end end - diff --git a/spec/ruby/core/integer/multiply_spec.rb b/spec/ruby/core/integer/multiply_spec.rb index 68e7dd8fae..1683b0c96e 100644 --- a/spec/ruby/core/integer/multiply_spec.rb +++ b/spec/ruby/core/integer/multiply_spec.rb @@ -49,4 +49,3 @@ describe "Integer#*" do end end end - diff --git a/spec/ruby/core/integer/plus_spec.rb b/spec/ruby/core/integer/plus_spec.rb index d41077450d..2880840bc1 100644 --- a/spec/ruby/core/integer/plus_spec.rb +++ b/spec/ruby/core/integer/plus_spec.rb @@ -47,4 +47,3 @@ describe "Integer#+" do end end end - diff --git a/spec/ruby/core/io/pos_spec.rb b/spec/ruby/core/io/pos_spec.rb index ca0a761c8f..e6cda2643d 100644 --- a/spec/ruby/core/io/pos_spec.rb +++ b/spec/ruby/core/io/pos_spec.rb @@ -9,4 +9,3 @@ end describe "IO#pos=" do it_behaves_like :io_set_pos, :pos= end - diff --git a/spec/ruby/core/io/print_spec.rb b/spec/ruby/core/io/print_spec.rb index a4a069361e..0dd48344ce 100644 --- a/spec/ruby/core/io/print_spec.rb +++ b/spec/ruby/core/io/print_spec.rb @@ -51,4 +51,3 @@ describe IO, "#print" do lambda { IOSpecs.closed_io.print("stuff") }.should raise_error(IOError) end end - diff --git a/spec/ruby/core/io/shared/write.rb b/spec/ruby/core/io/shared/write.rb index 9490a848d7..bca96da81c 100644 --- a/spec/ruby/core/io/shared/write.rb +++ b/spec/ruby/core/io/shared/write.rb @@ -69,4 +69,25 @@ describe :io_write, shared: true do lambda { IOSpecs.closed_io.send(@method, "hello") }.should raise_error(IOError) end + describe "on a pipe" do + before :each do + @r, @w = IO.pipe + end + + after :each do + @r.close + @w.close + end + + it "writes the given String to the pipe" do + @w.send(@method, "foo") + @w.close + @r.read.should == "foo" + end + + it "raises Errno::EPIPE if the read end is closed" do + @r.close + -> { @w.send(@method, "foo") }.should raise_error(Errno::EPIPE, "Broken pipe") + end + end end diff --git a/spec/ruby/core/kernel/eql_spec.rb b/spec/ruby/core/kernel/eql_spec.rb index 83185b824a..e62a601a79 100644 --- a/spec/ruby/core/kernel/eql_spec.rb +++ b/spec/ruby/core/kernel/eql_spec.rb @@ -8,4 +8,3 @@ describe "Kernel#eql?" do it_behaves_like :object_equal, :eql? end - diff --git a/spec/ruby/core/kernel/eval_spec.rb b/spec/ruby/core/kernel/eval_spec.rb index ad06af7b05..fbae8ff3c7 100644 --- a/spec/ruby/core/kernel/eval_spec.rb +++ b/spec/ruby/core/kernel/eval_spec.rb @@ -213,4 +213,132 @@ describe "Kernel#eval" do code = fixture __FILE__, "eval_return_without_lambda.rb" ruby_exe(code).chomp.should == "a,b,c,e,LocalJumpError,f" end + + describe "with a magic encoding comment" do + it "uses the magic comment encoding for the encoding of literal strings" do + code = "# encoding: UTF-8\n'é'.encoding".b + code.encoding.should == Encoding::BINARY + eval(code).should == Encoding::UTF_8 + end + + it "uses the magic comment encoding for parsing constants" do + code = < [input] do sh build_cmd end - diff --git a/spec/ruby/optional/capi/string_spec.rb b/spec/ruby/optional/capi/string_spec.rb index cc6ac2e0cb..2344dd37d7 100644 --- a/spec/ruby/optional/capi/string_spec.rb +++ b/spec/ruby/optional/capi/string_spec.rb @@ -865,4 +865,23 @@ describe "C-API String function" do @s.rb_String({"bar" => "foo"}).should == '{"bar"=>"foo"}' end end + + describe "rb_string_value_cstr" do + it "returns a non-null pointer for a simple string" do + @s.rb_string_value_cstr("Hello").should == true + end + + it "returns a non-null pointer for a UTF-16 string" do + @s.rb_string_value_cstr("Hello".encode('UTF-16BE')).should == true + end + + it "raises an error if a string contains a null" do + lambda { @s.rb_string_value_cstr("Hello\0 with a null.") }.should raise_error(ArgumentError) + end + + it "raises an error if a UTF-16 string contains a null" do + lambda { @s.rb_string_value_cstr("Hello\0 with a null.".encode('UTF-16BE')) }.should raise_error(ArgumentError) + end + + end end -- cgit v1.2.3