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: 94505082ee25
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9b16c5c618c4
Choose a head ref

Commits on Dec 22, 2017

  1. Copy the full SHA
    6598675 View commit details
  2. Tag 'j' pack specs.

    headius committed Dec 22, 2017
    Copy the full SHA
    6932b2b View commit details
  3. Tag syslog failures.

    headius committed Dec 22, 2017
    Copy the full SHA
    9ea9cbd View commit details
  4. Tag missing sprintf flags.

    headius committed Dec 22, 2017
    Copy the full SHA
    2932cdf View commit details
  5. Tag ruby_bug for 2.4.

    headius committed Dec 22, 2017
    Copy the full SHA
    0b041c3 View commit details
  6. Copy the full SHA
    853ddd4 View commit details
  7. Copy the full SHA
    8331fa7 View commit details
  8. Get call site once.

    headius committed Dec 22, 2017
    Copy the full SHA
    6cae35f View commit details
  9. Copy the full SHA
    b243239 View commit details
  10. Copy the full SHA
    fb754ed View commit details
  11. Copy the full SHA
    773f134 View commit details
  12. Spelling.

    headius committed Dec 22, 2017
    Copy the full SHA
    3b3e92e View commit details
  13. Copy the full SHA
    fdaaacd View commit details
  14. Copy the full SHA
    771ddc4 View commit details
  15. Copy the full SHA
    e356081 View commit details
  16. Copy the full SHA
    dd49bee View commit details
  17. Copy the full SHA
    b00db81 View commit details
  18. Typo.

    headius committed Dec 22, 2017
    Copy the full SHA
    f2ec3df View commit details
  19. Copy the full SHA
    d556f22 View commit details
  20. Copy the full SHA
    3662d7c View commit details
  21. For consistency.

    headius committed Dec 22, 2017
    Copy the full SHA
    9b16c5c View commit details
Showing with 327 additions and 34 deletions.
  1. +28 −0 core/src/main/java/org/jruby/RubyArgsFile.java
  2. +1 −1 core/src/main/java/org/jruby/RubyHash.java
  3. +4 −1 core/src/main/java/org/jruby/RubyIO.java
  4. +3 −3 core/src/main/java/org/jruby/anno/TypePopulator.java
  5. +40 −26 core/src/main/java/org/jruby/ext/tracepoint/TracePoint.java
  6. +1 −1 core/src/main/java/org/jruby/ir/persistence/IRDumper.java
  7. +10 −0 core/src/main/java/org/jruby/runtime/JavaSites.java
  8. +2 −1 core/src/main/java/org/jruby/util/io/Getline.java
  9. +1 −1 core/src/main/java/org/jruby/util/io/OpenFile.java
  10. +1 −0 rakelib/commands.rake
  11. BIN spec/tags/ruby/core/array/pack/buffer_tags.txt
  12. +27 −0 spec/tags/ruby/core/file/printf_tags.txt
  13. +54 −0 spec/tags/ruby/core/kernel/printf_tags.txt
  14. +54 −0 spec/tags/ruby/core/kernel/sprintf_tags.txt
  15. +6 −0 spec/tags/ruby/core/module/refine_tags.txt
  16. +1 −0 spec/tags/ruby/core/string/capitalize_tags.txt
  17. +2 −0 spec/tags/ruby/core/string/casecmp_tags.txt
  18. +1 −0 spec/tags/ruby/core/string/downcase_tags.txt
  19. +1 −0 spec/tags/ruby/core/string/intern_tags.txt
  20. +27 −0 spec/tags/ruby/core/string/percent_tags.txt
  21. +1 −0 spec/tags/ruby/core/string/swapcase_tags.txt
  22. +1 −0 spec/tags/ruby/core/string/to_sym_tags.txt
  23. +1 −0 spec/tags/ruby/core/string/upcase_tags.txt
  24. +1 −0 spec/tags/ruby/core/symbol/capitalize_tags.txt
  25. +4 −0 spec/tags/ruby/core/symbol/casecmp_tags.txt
  26. +1 −0 spec/tags/ruby/core/symbol/downcase_tags.txt
  27. +1 −0 spec/tags/ruby/core/symbol/swapcase_tags.txt
  28. +1 −0 spec/tags/ruby/core/symbol/upcase_tags.txt
  29. +1 −0 spec/tags/ruby/core/thread/report_on_exception_tags.txt
  30. +1 −0 spec/tags/ruby/core/tracepoint/callee_id_tags.txt
  31. +1 −0 spec/tags/ruby/core/tracepoint/defined_class_tags.txt
  32. +1 −0 spec/tags/ruby/core/tracepoint/event_tags.txt
  33. +1 −0 spec/tags/ruby/core/tracepoint/lineno_tags.txt
  34. +1 −0 spec/tags/ruby/core/tracepoint/method_id_tags.txt
  35. +2 −0 spec/tags/ruby/core/tracepoint/new_tags.txt
  36. +1 −0 spec/tags/ruby/core/tracepoint/return_value_tags.txt
  37. +27 −0 spec/tags/ruby/library/stringio/printf_tags.txt
  38. +5 −0 spec/tags/ruby/library/syslog/open_tags.txt
  39. +3 −0 spec/tags/ruby/library/syslog/opened_tags.txt
  40. +4 −0 spec/tags/ruby/library/syslog/options_tags.txt
  41. +4 −0 spec/tags/ruby/library/syslog/reopen_tags.txt
28 changes: 28 additions & 0 deletions core/src/main/java/org/jruby/RubyArgsFile.java
Original file line number Diff line number Diff line change
@@ -46,7 +46,9 @@
import org.jruby.exceptions.RaiseException;
import org.jruby.internal.runtime.GlobalVariable;
import org.jruby.runtime.Block;
import org.jruby.runtime.CallSite;
import org.jruby.runtime.IAccessor;
import org.jruby.runtime.JavaSites;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
@@ -444,6 +446,28 @@ public static IRubyObject each_charCommon(ThreadContext context, IRubyObject rec
return recv;
}

@JRubyMethod
public static IRubyObject each_codepoint(ThreadContext context, IRubyObject recv, Block block) {
if (!block.isGiven()) return RubyEnumerator.enumeratorize(context.runtime, recv, "each_line");
ArgsFileData data = ArgsFileData.getArgsFileData(context.runtime);

CallSite each_codepoint = sites(context).each_codepoint;
while (data.next_argv(context)) {
each_codepoint.call(context, recv, data.currentFile, block);
}

return context.nil;
}

@JRubyMethod
public static IRubyObject codepoints(ThreadContext context, IRubyObject recv, Block block) {
context.runtime.getWarnings().warn("ARGF#codepoints is deprecated; use #each_codepoint instead");

if (!block.isGiven()) return RubyEnumerator.enumeratorize(context.runtime, recv, "each_line");

return each_codepoint(context, recv, block);
}

/** Invoke a block for each line.
*
*/
@@ -809,4 +833,8 @@ private static RubyIO getCurrentDataFile(ThreadContext context, String errorMess

return (RubyIO) data.currentFile;
}

private static JavaSites.ArgfSites sites(ThreadContext context) {
return context.sites.Argf;
}
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyHash.java
Original file line number Diff line number Diff line change
@@ -1432,7 +1432,7 @@ public IRubyObject each_key(final ThreadContext context, final Block block) {

@JRubyMethod(name = "transform_values")
public IRubyObject transform_values(final ThreadContext context, final Block block) {
return ((RubyHash)dup()).transform_values_bang(context, block);
return (new RubyHash(context.runtime, context.runtime.getHash(), this)).transform_values_bang(context, block);
}

@JRubyMethod(name = "transform_values!")
5 changes: 4 additions & 1 deletion core/src/main/java/org/jruby/RubyIO.java
Original file line number Diff line number Diff line change
@@ -3813,7 +3813,10 @@ public static IRubyObject readlines(ThreadContext context, IRubyObject recv, IRu
IRubyObject io = openKeyArgs(context, recv, args, opt);
if (io.isNil()) return io;

IRubyObject[] methodArguments = processReadlinesMethodArguments(context, args);
IRubyObject[] methodArguments = Arrays.copyOfRange(args, 1, args.length);

// replace with coerced, so we don't coerce again later
if (!opt.isNil()) methodArguments[methodArguments.length - 1] = opt;

return readlinesCommon(context, (RubyIO) io, methodArguments);
}
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/anno/TypePopulator.java
Original file line number Diff line number Diff line change
@@ -95,18 +95,18 @@ public void populate(final RubyModule target, final Class clazz) {
final String name = entry.getKey();
final List<JavaMethodDescriptor> methods = entry.getValue();
target.defineAnnotatedMethod(name, methods, methodFactory);
addBoundMethodsUnlessOmited(runtime, name, methods);
addBoundMethodsUnlessOmitted(runtime, name, methods);
}

for (Map.Entry<String, List<JavaMethodDescriptor>> entry : clumper.getAnnotatedMethods().entrySet()) {
final String name = entry.getKey();
final List<JavaMethodDescriptor> methods = entry.getValue();
target.defineAnnotatedMethod(name, methods, methodFactory);
addBoundMethodsUnlessOmited(runtime, name, methods);
addBoundMethodsUnlessOmitted(runtime, name, methods);
}
}

private static void addBoundMethodsUnlessOmited(final Ruby runtime, final String name, final List<JavaMethodDescriptor> methods) {
private static void addBoundMethodsUnlessOmitted(final Ruby runtime, final String name, final List<JavaMethodDescriptor> methods) {
final int size = methods.size();
if ( size == 1 ) {
final JavaMethodDescriptor desc = methods.get(0);
66 changes: 40 additions & 26 deletions core/src/main/java/org/jruby/ext/tracepoint/TracePoint.java
Original file line number Diff line number Diff line change
@@ -12,12 +12,14 @@
import org.jruby.exceptions.RaiseException;
import org.jruby.runtime.Block;
import org.jruby.runtime.EventHook;
import org.jruby.runtime.JavaSites;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.RubyEvent;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.Visibility;
import org.jruby.util.TypeConverter;

public class TracePoint extends RubyObject {
public static void createTracePointClass(Ruby runtime) {
@@ -47,40 +49,39 @@ public TracePoint(Ruby runtime, RubyClass klass) {
public IRubyObject initialize(ThreadContext context, IRubyObject[] _events, final Block block) {
final Ruby runtime = context.runtime;

if (!block.isGiven()) throw runtime.newThreadError("must be called with a block");
if (!block.isGiven()) throw runtime.newArgumentError("must be called with a block");

ArrayList<RubyEvent> events = new ArrayList<RubyEvent>(_events.length);
for (int i = 0; i < _events.length; i++) {
IRubyObject _event = _events[i];
if (_event instanceof RubySymbol || _event instanceof RubyString) {
String eventName = _event.asJavaString().toUpperCase();
RubyEvent event = null;
try {
event = RubyEvent.valueOf(eventName);
} catch (IllegalArgumentException iae) {}

if (event == null) throw runtime.newArgumentError("unknown event: " + eventName);

// a_call is call | b_call | c_call, and same as a_return.
if (event == RubyEvent.A_CALL) {
events.add(RubyEvent.CALL);
events.add(RubyEvent.B_CALL);
events.add(RubyEvent.C_CALL);
} else if (event == RubyEvent.A_RETURN) {
events.add(RubyEvent.RETURN);
events.add(RubyEvent.B_RETURN);
events.add(RubyEvent.C_RETURN);
} else {
events.add(event);
}
RubySymbol _event = (RubySymbol) TypeConverter.convertToType(context, _events[i], runtime.getSymbol(), sites(context).to_sym);

String eventName = _event.asJavaString().toUpperCase();
RubyEvent event = null;
try {
event = RubyEvent.valueOf(eventName);
} catch (IllegalArgumentException iae) {}

if (event == null) throw runtime.newArgumentError("unknown event: " + eventName);

// a_call is call | b_call | c_call, and same as a_return.
if (event == RubyEvent.A_CALL) {
events.add(RubyEvent.CALL);
events.add(RubyEvent.B_CALL);
events.add(RubyEvent.C_CALL);
} else if (event == RubyEvent.A_RETURN) {
events.add(RubyEvent.RETURN);
events.add(RubyEvent.B_RETURN);
events.add(RubyEvent.C_RETURN);
} else {
events.add(event);
}
}

EnumSet<RubyEvent> _eventSet;
if (events.size() > 0) {
_eventSet = EnumSet.copyOf(events);
} else {
_eventSet = EnumSet.allOf(RubyEvent.class);
_eventSet = EnumSet.of(RubyEvent.LINE);
}

final EnumSet<RubyEvent> eventSet = _eventSet;
@@ -133,7 +134,7 @@ public boolean isInterestedInEvent(RubyEvent event) {
public IRubyObject binding(ThreadContext context) {
checkInside(context);

return context.nil;
return binding == null ? context.nil : binding;
}

@JRubyMethod
@@ -186,7 +187,16 @@ public IRubyObject lineno(ThreadContext context) {
public IRubyObject method_id(ThreadContext context) {
checkInside(context);

return name == null ? context.nil : context.runtime.newString(name);
return name == null ? context.nil : context.runtime.newSymbol(name);
}

@JRubyMethod
public IRubyObject callee_id(ThreadContext context) {
checkInside(context);

// TODO: actually get called name, requires modifying trace handling in bindings

return name == null ? context.nil : context.runtime.newSymbol(name);
}

@JRubyMethod
@@ -268,6 +278,10 @@ public void updateEnabled(ThreadContext context, boolean toggle) {
private void checkInside(ThreadContext context) throws RaiseException {
if (!inside) throw context.runtime.newRuntimeError("access from outside");
}

private static JavaSites.TracePointSites sites(ThreadContext context) {
return context.sites.TracePoint;
}

private EventHook hook;
private volatile boolean enabled = false;
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ir/persistence/IRDumper.java
Original file line number Diff line number Diff line change
@@ -372,7 +372,7 @@ private void printAnsiOp(String c, String pre, Operand op) {
}

private void print(Object obj) {
if (obj.getClass().isArray()) {
if (obj != null && obj.getClass().isArray()) {
if (obj.getClass().getComponentType().isPrimitive()) {
switch (obj.getClass().getName().charAt(0)) {
case 'B': stream.print(Arrays.toString((boolean[]) obj)); break;
10 changes: 10 additions & 0 deletions core/src/main/java/org/jruby/runtime/JavaSites.java
Original file line number Diff line number Diff line change
@@ -40,6 +40,8 @@ public class JavaSites {
public final WarningSites Warning = new WarningSites();
public final ZlibSites Zlib = new ZlibSites();
public final TimeoutSites Timeout = new TimeoutSites();
public final ArgfSites Argf = new ArgfSites();
public final TracePointSites TracePoint = new TracePointSites();

public static class BasicObjectSites {
public final CallSite respond_to = new FunctionalCachingCallSite("respond_to?");
@@ -409,6 +411,14 @@ public static class TimeoutSites {
public final CallSite timeout = new FunctionalCachingCallSite("timeout");
}

public static class ArgfSites {
public final CallSite each_codepoint = new FunctionalCachingCallSite("each_codepoint");
}

public static class TracePointSites {
public final CheckedSites to_sym = new CheckedSites("to_sym");
}

public static class CheckedSites {
public final RespondToCallSite respond_to_X;
public final CachingCallSite respond_to_missing = new FunctionalCachingCallSite("respond_to_missing?");
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/util/io/Getline.java
Original file line number Diff line number Diff line change
@@ -68,6 +68,7 @@ public static <Self, Return extends IRubyObject> Return getlineCall(ThreadContex
sepArg = arg0;
limArg = arg1;
optArg = arg2;
break;
}

opt = ArgsUtil.getOptionsArg(context.runtime, optArg);
@@ -79,7 +80,7 @@ public static <Self, Return extends IRubyObject> Return getlineCall(ThreadContex
limArg = arg1;
}
} else {
IRubyObject chompKwarg = ArgsUtil.extractKeywordArg(context, "chomp", optArg);
IRubyObject chompKwarg = ArgsUtil.extractKeywordArg(context, "chomp", opt);
if (chompKwarg != null) {
chomp = chompKwarg.isTrue();
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/io/OpenFile.java
Original file line number Diff line number Diff line change
@@ -1586,7 +1586,7 @@ public IRubyObject getlineFast(ThreadContext context, Encoding enc, RubyIO io, b
if (e != -1) {
pending = (int) (e - p + 1);
if (chomp) {
chomplen = ((pending > 1 && pBytes[e - 1] == '\r')?1:0) + 1;
chomplen = ((pending > 1 && pBytes[e - 1] == '\r')?1:0) + 1;
}
}
if (str == null) {
1 change: 1 addition & 0 deletions rakelib/commands.rake
Original file line number Diff line number Diff line change
@@ -114,6 +114,7 @@ def mspec(mspec_options = {}, java_options = {}, &code)
arg :line => "-T -J-Demma.verbosity.level=silent"
arg :line => "-T -J#{JVM_MODEL}" if JVM_MODEL
arg :line => "-T -J-XX:MaxPermSize=512M" if ENV_JAVA["java.version"] !~ /\A1\.8/
arg :line => "-T --debug'"
arg :line => "-f #{ms[:format]}"
arg :line => "-B #{ms[:spec_config]}" if ms[:spec_config]
arg :line => "#{ms[:spec_target]}" if ms[:spec_target]
Binary file added spec/tags/ruby/core/array/pack/buffer_tags.txt
Binary file not shown.
27 changes: 27 additions & 0 deletions spec/tags/ruby/core/file/printf_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
fails:File#printf integer formats u converts argument as a decimal number
fails:File#printf float formats g otherwise cuts fraction part to have only 6 digits at all
fails:File#printf float formats G otherwise cuts fraction part to have only 6 digits at all
fails:File#printf float formats a converts floating point argument as [-]0xh.hhhhp[+-]dd
fails:File#printf float formats a displays Float::INFINITY as Inf
fails:File#printf float formats a displays Float::NAN as NaN
fails:File#printf float formats A converts floating point argument as [-]0xh.hhhhp[+-]dd and use uppercase X and P
fails:File#printf float formats A displays Float::INFINITY as Inf
fails:File#printf float formats A displays Float::NAN as NaN
fails:File#printf flags space applies to numeric formats bBdiouxXeEfgGaA leaves a space at the start of non-negative numbers
fails:File#printf flags space applies to numeric formats bBdiouxXeEfgGaA does not leave a space at the start of negative numbers
fails:File#printf flags space applies to numeric formats bBdiouxXeEfgGaA treats several white spaces as one
fails:File#printf flags (digit)$ specifies the absolute argument number for this field
fails:File#printf flags # applies to format o does nothing for negative argument
fails:File#printf flags # applies to formats aAeEfgG forces a decimal point to be added, even if no digits follow
fails:File#printf flags # applies to gG does not remove trailing zeros
fails:File#printf flags + applies to numeric formats bBdiouxXaAeEfgG adds a leading plus sign to non-negative numbers
fails:File#printf flags - left-justifies the result of conversion if width is specified
fails:File#printf flags 0 (zero) applies to numeric formats bBdiouxXaAeEfgG and width is specified pads with zeros, not spaces
fails:File#printf flags * uses the previous argument as the field width
fails:File#printf flags * left-justifies the result if width is negative
fails:File#printf flags * uses the specified argument as the width if * is followed by a number and $
fails:File#printf flags * left-justifies the result if specified with $ argument is negative
fails:File#printf flags * raises ArgumentError when is mixed with width
fails:File#printf width specifies the minimum number of characters that will be written to the result
fails:File#printf precision float types controls the number of decimal places displayed in fraction part
fails:File#printf reference by name %{name} style supports flags, width and precision
Loading