Skip to content

Commit

Permalink
Showing 16 changed files with 94 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -76,6 +76,11 @@ matrix:
jdk: oraclejdk8
- env: COMMAND=test/truffle/integration-tests.sh
jdk: oraclejdk8
- env: PHASE='-Pmain'
sudo: required
dist: trusty
group: edge
jdk: oraclejdk9

branches:
only:
3 changes: 2 additions & 1 deletion bin/jruby+truffle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
#!/usr/bin/env bash
"exec" "`dirname $BASH_SOURCE[0]`/jruby" "$0" "$@"

require File.join(JRuby.runtime.instance_config.jruby_home, 'lib/ruby/truffle/jruby+truffle/runner')

11 changes: 6 additions & 5 deletions core/src/main/java/org/jruby/RubyHash.java
Original file line number Diff line number Diff line change
@@ -703,13 +703,15 @@ public IRubyObject default_value_get(ThreadContext context, IRubyObject[] args)
throw context.runtime.newArgumentError(args.length, 1);
}
}

@JRubyMethod(name = "default")
public IRubyObject default_value_get(ThreadContext context) {
if ((flags & PROCDEFAULT_HASH_F) != 0) {
return getRuntime().getNil();
return context.nil;
}
return ifNone;
}

@JRubyMethod(name = "default")
public IRubyObject default_value_get(ThreadContext context, IRubyObject arg) {
if ((flags & PROCDEFAULT_HASH_F) != 0) {
@@ -1533,16 +1535,15 @@ public IRubyObject shift(ThreadContext context) {

RubyHashEntry entry = head.nextAdded;
if (entry != head) {
RubyArray result = RubyArray.newArray(getRuntime(), entry.key, entry.value);
RubyArray result = RubyArray.newArray(context.runtime, entry.key, entry.value);
internalDeleteEntry(entry);
return result;
}

if ((flags & PROCDEFAULT_HASH_F) != 0) {
return Helpers.invoke(context, ifNone, "call", this, getRuntime().getNil());
} else {
return ifNone;
return this.callMethod(context, "default", context.nil);
}
return ifNone;
}

public final boolean fastDelete(IRubyObject key) {
10 changes: 10 additions & 0 deletions core/src/main/java/org/jruby/RubyObjectSpace.java
Original file line number Diff line number Diff line change
@@ -151,6 +151,16 @@ public Object apply(IRubyObject arg1) {
for (IRubyObject arg : modules) {
block.yield(context, arg);
}
} else if (args[0].getClass() == MetaClass.class) {
// each_object(Cls.singleton_class) is basically a walk of Cls and all descendants of Cls.
// In other words, this is walking all instances of Cls's singleton class and its subclasses.
IRubyObject attached = ((MetaClass)args[0]).getAttached();
block.yield(context, attached);
if (attached instanceof RubyClass) {
for (RubyClass child : ((RubyClass)attached).subclasses(true)) {
block.yield(context, child);
}
}
} else {
if (!runtime.isObjectSpaceEnabled()) {
throw runtime.newRuntimeError("ObjectSpace is disabled; each_object will only work with Class, pass -X+O to enable");
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/IterNode.java
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ public IterNode(ISourcePosition position, ArgsNode args, Node body, StaticScope
super(position, args != null && args.containsVariableAssignment || body != null && body.containsVariableAssignment);

this.varNode = args;
this.bodyNode = body;
this.bodyNode = body == null ? NilImplicitNode.NIL : body;
this.scope = scope;
}

Original file line number Diff line number Diff line change
@@ -9,6 +9,35 @@
def Minitest.load_plugins
end
require 'active_support/testing/isolation'
module ActiveSupport
module Testing
module Isolation
def run
with_info_handler do
time_it do
capture_exceptions do
before_setup; setup; after_setup
skip 'isolation not supported'
end
%w{ before_teardown teardown after_teardown }.each do |hook|
capture_exceptions do
self.send hook
end
end
end
end
return self # per contract
end
end
end
end
# Work around a bug in ActiveSupport whereby it tries to pass an env hash with Symbol keys. This only
# works on JRuby 1.7. The following will allow the Symbol keys to coerce to Strings.
class Symbol
8 changes: 6 additions & 2 deletions lib/ruby/truffle/jruby+truffle/runner.rb
Original file line number Diff line number Diff line change
@@ -28,7 +28,10 @@ class JRubyTruffleRunner
merge_hash = -> ((k, v), old) { old.merge k => v }
apply_pattern = -> (pattern, old) do
Dir.glob(pattern) do |file|
next if @options[:run][:exclude_pattern].any? { |p| /#{p}/ =~ file }
if @options[:run][:exclude_pattern].any? { |p| /#{p}/ =~ file }
puts "skipped: #{file}" if @options[:global][:verbose]
next
end
@options[:run][:require] << File.expand_path(file)
end
old
@@ -219,9 +222,10 @@ def load_local_configuration
end

def apply_yaml_to_configuration(yaml_path)
if File.exist?(yaml_path)
if yaml_path && File.exist?(yaml_path)
yaml_data = YAML.load_file(yaml_path)
@options = deep_merge @options, yaml_data
puts "loading #{yaml_path}"
end
end

2 changes: 1 addition & 1 deletion maven/jruby-complete/src/it/integrity/verify.bsh
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ if ( !file.exists() )
throw new RuntimeException( "file '" + file + "' does not exists" );
}

expected = "uri:classloader:/META-INF/jruby.home";
expected = "uri:classloader://META-INF/jruby.home";
if ( !log.contains( expected ) ) throw new RuntimeException( "log file does not contain '" + expected + "'" );

expected = "jruby home is a file: falsefalse";
2 changes: 1 addition & 1 deletion maven/jruby-dist/src/it/integrity/verify.bsh
Original file line number Diff line number Diff line change
@@ -49,5 +49,5 @@ if ( !log.contains( expected ) )
throw new RuntimeException( "log file does not contain '" + expected + "'" );
}

String unexpected = "uri:classloader:/META-INF/jruby.home";
String unexpected = "uri:classloader://META-INF/jruby.home";
if ( log.contains( unexpected ) ) throw new RuntimeException( "log file does contain unexpected '" + unexpected + "'" );
2 changes: 1 addition & 1 deletion maven/jruby-jars/src/it/integrity/verify.bsh
Original file line number Diff line number Diff line change
@@ -49,5 +49,5 @@ if ( !log.contains( expected ) )
throw new RuntimeException( "log file does not contain '" + expected + "'" );
}

expected = "uri:classloader:/META-INF/jruby.home";
expected = "uri:classloader://META-INF/jruby.home";
if ( !log.contains( expected ) ) throw new RuntimeException( "log file does not contain '" + expected + "'" );
2 changes: 1 addition & 1 deletion maven/jruby/src/it/integrity/verify.bsh
Original file line number Diff line number Diff line change
@@ -67,5 +67,5 @@ if ( !log.contains( expected ) ) throw new RuntimeException( "log file does not
expected = "maven/jruby/target/it/integrity/target/classes/hello.rb";
if ( !log.contains( expected ) ) throw new RuntimeException( "log file does not contain '" + expected + "'" );

expected = "uri:classloader:/META-INF/jruby.home";
expected = "uri:classloader://META-INF/jruby.home";
if ( !log.contains( expected ) ) throw new RuntimeException( "log file does not contain '" + expected + "'" );
17 changes: 17 additions & 0 deletions test/jruby/test_objectspace.rb
Original file line number Diff line number Diff line change
@@ -93,4 +93,21 @@ def test_finalization
assert_equal "finalizing #{results[0]}", results[1]
end
end

# See rails/rails#22376.
def test_each_object_singleton_class
# disable objectspace; we want this to always work
old_objectspace = JRuby.objectspace
JRuby.objectspace = false

a = Class.new
b = Class.new(a)
c = Class.new(a)
d = Class.new(b)

classes = ObjectSpace.each_object(a.singleton_class).to_a
assert_equal(classes.sort_by(&:name), [a, b, c, d].sort_by(&:name))
ensure
JRuby.objectspace = old_objectspace
end
end
2 changes: 1 addition & 1 deletion test/mri/excludes/TestHash.rb
Original file line number Diff line number Diff line change
@@ -12,5 +12,5 @@
exclude :test_NEWHASH_fstring_key, "needs investigation"
exclude :test_recursive_hash_value_struct, "needs investigation"
exclude :test_reject, "needs investigation"
exclude :test_shift_none, "needs investigation"
exclude :test_AREF_fstring_key, "Depends on MRI-specific GC.stat key"
exclude :test_ASET_fstring_key, "due https://github.com/jruby/jruby/commit/f3f0091da7d98c5df285"
1 change: 1 addition & 0 deletions test/mri/excludes/TestHash/TestSubHash.rb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
exclude :test_AREF_fstring_key, "Depends on MRI-specific GC.stat key"
exclude :test_ASET_fstring_key, "due https://github.com/jruby/jruby/commit/f3f0091da7d98c5df285"
16 changes: 11 additions & 5 deletions test/mri/ruby/test_hash.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: us-ascii -*-
require 'test/unit'
require 'continuation'
require_relative 'envutil'
EnvUtil.suppress_warning {require 'continuation'}

class TestHash < Test::Unit::TestCase

@@ -1265,8 +1265,14 @@ def eql?(other)
end
end

hash = {5 => bug9381}
assert_equal(bug9381, hash[wrapper.new(5)])
bad = [
5, true, false, nil,
0.0, 1.72723e-77,
].select do |x|
hash = {x => bug9381}
hash[wrapper.new(x)] != bug9381
end
assert_empty(bad, bug9381)
end

def test_label_syntax
@@ -1275,9 +1281,9 @@ def test_label_syntax
feature4935 = '[ruby-core:37553] [Feature #4935]'
x = 'world'
hash = assert_nothing_raised(SyntaxError) do
break eval(%q({foo: 1, "foo-bar": 2, "hello-#{x}": 3, 'hello-#{x}': 4}))
break eval(%q({foo: 1, "foo-bar": 2, "hello-#{x}": 3, 'hello-#{x}': 4, 'bar': {}}))
end
assert_equal({:foo => 1, :'foo-bar' => 2, :'hello-world' => 3, :'hello-#{x}' => 4}, hash)
assert_equal({:foo => 1, :'foo-bar' => 2, :'hello-world' => 3, :'hello-#{x}' => 4, :bar => {}}, hash)
end

class TestSubHash < TestHash
2 changes: 1 addition & 1 deletion truffle/src/main/ruby/core/method.rb
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ class Method
def inspect
file, line = source_location

if file and line
if file && line
"#<#{self.class}: #{receiver.class}(#{owner})##{name} #{file}:#{line}>"
else
"#<#{self.class}: #{receiver.class}(#{owner})##{name}>"

0 comments on commit 080d30a

Please sign in to comment.