Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: fd44e62cdeaf
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f0c1124a3e77
Choose a head ref
  • 5 commits
  • 3 files changed
  • 1 contributor

Commits on Dec 13, 2016

  1. Copy the full SHA
    18e992f View commit details
  2. Copy the full SHA
    7fccf8c View commit details
  3. Fixes #4383. warn with array should behave like puts with array.

    Also fixes two other problems:
    1. we do not dynamic dispatch to puts.  MRI always uses builtin.
    2. as part of switching from two writes to builtin puts we also emit
       an extra newline which fixes our last broken spec.
    
    Next commit will add spec for this issue so we have coverage.
    enebo committed Dec 13, 2016
    2
    Copy the full SHA
    4b83350 View commit details
  4. Copy the full SHA
    8ee58af View commit details
  5. Copy the full SHA
    f0c1124 View commit details
Showing with 11 additions and 11 deletions.
  1. +4 −7 core/src/main/java/org/jruby/RubyKernel.java
  2. +7 −0 spec/ruby/core/kernel/warn_spec.rb
  3. +0 −4 spec/tags/ruby/core/kernel/warn_tags.txt
11 changes: 4 additions & 7 deletions core/src/main/java/org/jruby/RubyKernel.java
Original file line number Diff line number Diff line change
@@ -621,7 +621,7 @@ public static IRubyObject respond_to_missing_p(ThreadContext context, IRubyObjec

/** Returns value of $_.
*
* @throws TypeError if $_ is not a String or nil.
* @throws RaiseException TypeError if $_ is not a String or nil.
* @return value of $_ as String.
*/
private static RubyString getLastlineString(ThreadContext context, Ruby runtime) {
@@ -1174,15 +1174,12 @@ private static RaiseException uncaughtThrow(Ruby runtime, IRubyObject tag, IRuby
public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObject message) {
final Ruby runtime = context.runtime;

if (runtime.warningsEnabled()) {
IRubyObject out = runtime.getGlobalVariables().get("$stderr");
sites(context).write.call(context, out, out, message);
sites(context).write.call(context, out, out, runtime.getGlobalVariables().getDefaultSeparator());
}
if (runtime.warningsEnabled()) RubyIO.puts1(context, runtime.getGlobalVariables().get("$stderr"), message);

return context.nil;
}

@JRubyMethod(module = true, required = 1, rest = true, visibility = PRIVATE)
@JRubyMethod(module = true, rest = true, visibility = PRIVATE)
public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObject... messages) {
for (IRubyObject message : messages) warn(context, recv, message);
return context.nil;
7 changes: 7 additions & 0 deletions spec/ruby/core/kernel/warn_spec.rb
Original file line number Diff line number Diff line change
@@ -55,6 +55,13 @@
}.should output(nil, "line 1\nline 2\n")
end

it "writes each array element on a line when passes an array" do
lambda {
$VERBOSE = true
warn(["line 1", "line 2"])
}.should output(nil, "line 1\nline 2\n")
end

it "does not write strings when passed no arguments" do
lambda {
$VERBOSE = true
4 changes: 0 additions & 4 deletions spec/tags/ruby/core/kernel/warn_tags.txt

This file was deleted.