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: 4892ade624bb
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ab7b0a06e1c9
Choose a head ref
  • 6 commits
  • 6 files changed
  • 1 contributor

Commits on Mar 4, 2016

  1. Copy the full SHA
    1a10a9a View commit details
  2. Copy the full SHA
    b7dc414 View commit details
  3. Untag working -p spec.

    headius committed Mar 4, 2016
    Copy the full SHA
    e8ef0dd View commit details
  4. Untag passing -U spec.

    headius committed Mar 4, 2016
    Copy the full SHA
    fafad54 View commit details
  5. Copy the full SHA
    c766232 View commit details
  6. Bind methods for toplevel command line loop only when enabled.

    gsub was always binding at toplevel before, and the other methods
    weren't binding at all.
    headius committed Mar 4, 2016
    Copy the full SHA
    ab7b0a0 View commit details
5 changes: 3 additions & 2 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -702,14 +702,15 @@ private RootNode addGetsLoop(RootNode oldRoot, boolean printing, boolean process

if (processLineEndings) whileBody.add(new CallNode(pos, dollarUnderscore, "chop!", null, null));
if (split) whileBody.add(new GlobalAsgnNode(pos, "$F", new CallNode(pos, dollarUnderscore, "split", null, null)));
if (printing) whileBody.add(new FCallNode(pos, "puts", new ArrayNode(pos, dollarUnderscore), null));

if (oldRoot.getBodyNode() instanceof BlockNode) { // common case n stmts
whileBody.addAll(oldRoot.getBodyNode());
whileBody.addAll(((BlockNode) oldRoot.getBodyNode()));
} else { // single expr script
whileBody.add(oldRoot.getBodyNode());
}

if (printing) whileBody.add(new FCallNode(pos, "puts", new ArrayNode(pos, dollarUnderscore), null));

return new RootNode(pos, oldRoot.getScope(), newBody, oldRoot.getFile());
}

111 changes: 89 additions & 22 deletions core/src/main/java/org/jruby/RubyKernel.java
Original file line number Diff line number Diff line change
@@ -128,6 +128,10 @@ public static RubyModule createKernelModule(Ruby runtime) {
runtime.setSuperMethodMissing(new MethodMissingMethod(module, PUBLIC, CallType.SUPER));
runtime.setNormalMethodMissing(new MethodMissingMethod(module, PUBLIC, CallType.NORMAL));

if (runtime.getInstanceConfig().isAssumeLoop()) {
module.defineAnnotatedMethods(LoopMethods.class);
}

recacheBuiltinMethods(runtime);

return module;
@@ -1734,28 +1738,6 @@ public static IRubyObject fork19(ThreadContext context, IRubyObject recv, Block
throw runtime.newNotImplementedError("fork is not available on this platform");
}

@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject gsub(ThreadContext context, IRubyObject recv, IRubyObject arg0, Block block) {
RubyString str = (RubyString) getLastlineString(context, context.runtime).dup();

if (!str.gsub_bang(context, arg0, block).isNil()) {
context.setLastLine(str);
}

return str;
}

@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject gsub(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, Block block) {
RubyString str = (RubyString) getLastlineString(context, context.runtime).dup();

if (!str.gsub_bang(context, arg0, arg1, block).isNil()) {
context.setLastLine(str);
}

return str;
}

@JRubyMethod(module = true)
public static IRubyObject tap(ThreadContext context, IRubyObject recv, Block block) {
block.yield(context, recv);
@@ -2061,6 +2043,91 @@ public static RubyArray instance_variables19(ThreadContext context, IRubyObject
}
/* end delegated bindings */

public static IRubyObject gsub(ThreadContext context, IRubyObject recv, IRubyObject arg0, Block block) {
RubyString str = (RubyString) getLastlineString(context, context.runtime).dup();

if (!str.gsub_bang(context, arg0, block).isNil()) {
context.setLastLine(str);
}

return str;
}

public static IRubyObject gsub(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, Block block) {
RubyString str = (RubyString) getLastlineString(context, context.runtime).dup();

if (!str.gsub_bang(context, arg0, arg1, block).isNil()) {
context.setLastLine(str);
}

return str;
}

public static class LoopMethods {
@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject gsub(ThreadContext context, IRubyObject recv, IRubyObject arg0, Block block) {
RubyString str = getLastlineString(context, context.runtime);

context.setLastLine(str.gsub(context, arg0, block));

return str;
}

@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject gsub(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, Block block) {
RubyString str = getLastlineString(context, context.runtime);

context.setLastLine(str.gsub(context, arg0, arg1, block));

return str;
}

@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject sub(ThreadContext context, IRubyObject recv, IRubyObject arg0, Block block) {
RubyString str = getLastlineString(context, context.runtime);

context.setLastLine(str.sub(context, arg0, block));

return str;
}

@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject sub(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, Block block) {
RubyString str = getLastlineString(context, context.runtime);

context.setLastLine(str.sub(context, arg0, arg1, block));

return str;
}

@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject chop(ThreadContext context, IRubyObject recv) {
RubyString str = getLastlineString(context, context.runtime);

context.setLastLine(str.chop(context));

return str;
}

@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject chomp(ThreadContext context, IRubyObject recv) {
RubyString str = getLastlineString(context, context.runtime);

context.setLastLine(str.chomp(context));

return str;
}

@JRubyMethod(module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE)
public static IRubyObject chomp(ThreadContext context, IRubyObject recv, IRubyObject arg0) {
RubyString str = getLastlineString(context, context.runtime);

context.setLastLine(str.chomp(context, arg0));

return str;
}
}

@Deprecated
public static IRubyObject methodMissing(ThreadContext context, IRubyObject recv, String name, Visibility lastVis, CallType lastCallType, IRubyObject[] args, Block block) {
return methodMissing(context, recv, name, lastVis, lastCallType, args);
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ public IRubyObject invoke(ThreadContext context, IRubyObject caller, IRubyObject

updateInvocationTarget(mh, self, selfClass, method, switchPoint);

return ((RubyHash) self).fastARef(args[0]);
return ((RubyHash) self).op_aref(context, args[0]);
} else {
// slow path follows normal invoke logic with a strDup for the key
SwitchPoint switchPoint = (SwitchPoint) selfClass.getInvalidator().getData();
1 change: 0 additions & 1 deletion spec/tags/ruby/command_line/dash_p_tags.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
fails:The -p command line option runs the code in loop conditional on Kernel.gets() and prints $_
fails:The -p command line option sets $-p
1 change: 0 additions & 1 deletion spec/tags/ruby/command_line/dash_upper_u_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
fails(compiler):ruby -U does not affect the source encoding
fails(compiler):ruby -U raises a RuntimeError if used with -Eext:int
fails(compiler):ruby -U raises a RuntimeError if used with -E:int
10 changes: 1 addition & 9 deletions test/mri/excludes/TestRubyOptions.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# These all error out, so it may be a simple fix
exclude :test_DATA, "needs investigation"
exclude :test_assignment_in_conditional, "needs investigation"
exclude :test_chdir, "needs investigation"
exclude :test_copyright, "needs investigation"
@@ -14,28 +12,22 @@
exclude :test_invalid_option, "needs investigation"
exclude :test_kanji, "needs investigation"
exclude :test_notfound, "needs investigation"
exclude :test_option_variables, "needs investigation"
exclude :test_program_name, "needs investigation"
exclude :test_require, "needs investigation"
exclude :test_rubyopt, "needs investigation"
exclude :test_safe_level, "needs investigation"
exclude :test_script_from_stdin, "uses io/console in ways we don't support yet"
exclude :test_script_is_directory, "uses io/console in ways we don't support yet"
exclude :test_search, "needs investigation"
exclude :test_segv_loaded_features, "needs investigation"
exclude :test_segv_setproctitle, "needs investigation"
exclude :test_segv_test, "needs investigation"
exclude :test_separator, "needs investigation"
exclude :test_sflag, "needs investigation"
exclude :test_shadowing_variable, "needs investigation"
exclude :test_shebang, "needs investigation"
exclude :test_usage_long, "needs investigation"
exclude :test_unmatching_glob, "needs investigation"
exclude :test_unused_variable, "needs investigation"
exclude :test_usage, "needs investigation"
exclude :test_usage_long, "needs investigation"
exclude :test_verbose, "needs investigation"
exclude :test_version, "needs investigation"
exclude :test_warning, "needs investigation"
exclude :test_yydebug, "needs investigation"
exclude :test_pflag_gsub, "needs investigation"
exclude :test_pflag_sub, "needs investigation"