Skip to content

Commit

Permalink
Merge branch 'master' into truffle-yaml
Browse files Browse the repository at this point in the history
Conflicts:
	truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
  • Loading branch information
chrisseaton committed Sep 25, 2015
2 parents 758404f + 2fe2232 commit 7633e99
Showing 31 changed files with 316 additions and 163 deletions.
4 changes: 2 additions & 2 deletions core/pom.rb
Original file line number Diff line number Diff line change
@@ -45,9 +45,9 @@
jar 'com.github.jnr:jnr-enxio:0.9', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-x86asm:1.0.2', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-unixsocket:0.8', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.15', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.18-SNAPSHOT', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-constants:0.9.0', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-ffi:2.0.4-SNAPSHOT'
jar 'com.github.jnr:jnr-ffi:2.0.4'
jar 'com.github.jnr:jffi:${jffi.version}'
jar 'com.github.jnr:jffi:${jffi.version}:native'

4 changes: 2 additions & 2 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -136,7 +136,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-posix</artifactId>
<version>3.0.15</version>
<version>3.0.18-SNAPSHOT</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
@@ -158,7 +158,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-ffi</artifactId>
<version>2.0.4-SNAPSHOT</version>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
18 changes: 17 additions & 1 deletion maven/jruby-dist/pom.rb
Original file line number Diff line number Diff line change
@@ -47,6 +47,8 @@
end

execute :pack200 do |ctx|
require 'open3'

jruby_home = Dir[ File.join( ctx.project.build.directory.to_pathname,
'META-INF/jruby.home/**/*.jar' ) ]
gem_home = Dir[ File.join( ctx.project.build.directory.to_pathname,
@@ -58,7 +60,21 @@
file = f.sub /.jar$/, ''
unless File.exists?( file + '.pack.gz' )
puts "pack200 #{f.sub(/.*jruby.home./, '').sub(/.*rubygems-provided./, '')}"
`pack200 #{file}.pack.gz #{file}.jar`

Open3.popen3('pack200', "#{file}.pack.gz", "#{file}.jar") do |stdin, stdout, stderr, wait_thread|
stdio_threads = []

stdio_threads << Thread.new(stdout) do |stdout|
stdout.each { |line| $stdout.puts line }
end

stdio_threads << Thread.new(stderr) do |stderr|
stderr.each { |line| $stderr.puts line }
end

stdio_threads.each(&:join)
wait_thread.value
end
end
end
end
32 changes: 32 additions & 0 deletions spec/ruby/core/binding/local_variable_get_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

ruby_version_is "2.1" do
describe "Binding#local_variable_get" do
it "reads local variables captured in the binding" do
a = 42
bind = binding
bind.local_variable_get(:a).should == 42
end

it "raises a NameError for missing variables" do
bind = BindingSpecs::Demo.new(1).get_empty_binding

lambda {
bind.local_variable_get(:no_such_variable)
}.should raise_error(NameError)
end

it "reads variables added later to the binding" do
bind = BindingSpecs::Demo.new(1).get_empty_binding

lambda {
bind.local_variable_get(:a)
}.should raise_error(NameError)

bind.local_variable_set(:a, 42)

bind.local_variable_get(:a).should == 42
end
end
end
4 changes: 2 additions & 2 deletions spec/truffle/specs/truffle/primitive/assert_constant_spec.rb
Original file line number Diff line number Diff line change
@@ -15,8 +15,8 @@
end

unless Truffle.graal?
it "returns nil" do
Truffle::Primitive.assert_constant(14 + 2).should be_nil
it "returns the value of the argument" do
Truffle::Primitive.assert_constant(14 + 2).should == 16
end
end

8 changes: 4 additions & 4 deletions test/truffle/pe/core/array_pe.rb
Original file line number Diff line number Diff line change
@@ -6,11 +6,11 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

example "[3, 1, 2][1]"
example "[3, 1, 2][1]", 1

example "[3, 1, 2].sort[1]"
example "[3, 1, 2].sort[1]", 2

# why does this fail but the next one work?
tagged_example "[14].pack('C').getbyte(0)"
tagged_example "[14].pack('C').getbyte(0)", 14

example "[14].pack('C').getbyte(0) * 2"
example "[14].pack('C').getbyte(0) * 2", 28
28 changes: 26 additions & 2 deletions test/truffle/pe/core/binding_pe.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
# Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

example "x = 14; p = Proc.new { }; p.binding.local_variable_get(:x)"
# why do the tagged_example fail? identity of boxing?

# Kernel#binding
tagged_example "x = 14; binding.local_variable_get(:x)", 14
example "x = 14; binding.local_variable_get(:x) * 2", 28

# Proc#binding
tagged_example "x = 14; p = Proc.new { }; p.binding.local_variable_get(:x)", 14
example "x = 14; p = Proc.new { }; p.binding.local_variable_get(:x) * 2", 28

# set + get
tagged_example "b = binding; b.local_variable_set(:x, 14); b.local_variable_get(:x)", 14
example "b = binding; b.local_variable_set(:x, 14); b.local_variable_get(:x) * 2", 28

# get (2 levels)
tagged_example "x = 14; y = nil; 1.times { y = binding.local_variable_get(:x) }; y", 14
example "x = 14; y = nil; 1.times { y = binding.local_variable_get(:x) }; y * 2", 28

# set (2 levels)
tagged_example "x = 14; 1.times { binding.local_variable_set(:x, 15) }; x", 15
example "x = 14; 1.times { binding.local_variable_set(:x, 15) }; x * 2", 30

# get + set (2 levels)
tagged_example "x = 14; y = nil; 1.times { binding.local_variable_set(:x, 15); y = binding.local_variable_get(:x) }; y", 15
example "x = 14; y = nil; 1.times { binding.local_variable_set(:x, 15); y = binding.local_variable_get(:x) }; y * 2", 30
8 changes: 4 additions & 4 deletions test/truffle/pe/core/eval_pe.rb
Original file line number Diff line number Diff line change
@@ -6,12 +6,12 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

example "eval('14')"
example "eval('14')", 14

example "eval('14 + 2')"
example "eval('14 + 2')", 16

example "eval('[1, 2, 3]')[1]"
example "eval('[1, 2, 3]')[1]", 2

example "eval([1, 2, 3].inspect)[1]"
example "eval([1, 2, 3].inspect)[1]", 2

counter_example "eval(rand.to_s)"
20 changes: 10 additions & 10 deletions test/truffle/pe/core/fixnum_pe.rb
Original file line number Diff line number Diff line change
@@ -6,21 +6,21 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

example "14"
example "14", 14

example "14 + 2"
counter_example "14 + 0xfffffffffffffffffffffffffffffff"
example "14 + 2.0"
example "14 + 2", 16
tagged_counter_example "14 + 0xfffffffffffffffffffffffffffffff" # Graal error
example "14 + 2.0", 16.0
counter_example "14 + rand"

example "14 * 2"
example "14 * 2", 28
counter_example "14 * 0xfffffffffffffffffffffffffffffff"
example "14 * 2.0"
example "14 * 2.0", 28.0
counter_example "14 * rand"

example "14 / 2"
example "14 / 0xfffffffffffffffffffffffffffffff"
example "14 / 2.0"
example "14 / 2", 7
example "14 / 0xfffffffffffffffffffffffffffffff", 0
example "14 / 2.0", 7.0
counter_example "14 / rand"

example "14 <=> 2"
example "14 <=> 2", 1
14 changes: 7 additions & 7 deletions test/truffle/pe/core/float_pe.rb
Original file line number Diff line number Diff line change
@@ -6,19 +6,19 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

example "14.2"
example "14.2", 14.2

example "14.0 + 2"
example "14.0 + 2", 16.0
counter_example "14.0 + 0xfffffffffffffffffffffffffffffff"
example "14.0 + 2.0"
example "14.0 + 2.0", 16.0
counter_example "14.0 + rand"

example "14.0 * 2"
example "14.0 * 2", 28.0
counter_example "14.0 * 0xfffffffffffffffffffffffffffffff"
example "14.0 * 2.0"
example "14.0 * 2.0", 28.0
counter_example "14.0 * rand"

example "14.0 / 2"
example "14.0 / 2", 7.0
counter_example "14.0 / 0xfffffffffffffffffffffffffffffff"
example "14.0 / 2.0"
example "14.0 / 2.0", 7.0
counter_example "14.0 / rand"
29 changes: 29 additions & 0 deletions test/truffle/pe/core/frozen_pe.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

example "true.frozen?", true
example "nil.frozen?", true

# int
example "3.frozen?", true

# long
example "(2**62).frozen?", true

# Bignum
example "(10 ** 100).frozen?", true

# double
example "3.5.frozen?", true

# Symbols are always frozen
example ":symbol.frozen?", true

# Object
example "'abc'.frozen?", false
example "'abc'.freeze.frozen?", true
4 changes: 2 additions & 2 deletions test/truffle/pe/core/hash_pe.rb
Original file line number Diff line number Diff line change
@@ -6,6 +6,6 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

example "({a: 0, b: 1, c: 2})[:b]"
example "({a: 0, b: 1, c: 2})[:b]", 1

example "({a: 0, b: 1, c: 2}).map{ |k, v| v }[0]"
example "({a: 0, b: 1, c: 2}).map{ |k, v| v }[0]", 0
9 changes: 2 additions & 7 deletions test/truffle/pe/core/method_pe.rb
Original file line number Diff line number Diff line change
@@ -6,10 +6,5 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

example "1.method(:abs).call"
example "1.method(:abs).unbind.bind(-2).call"

# These 3 are not constant currently since they produce new objects
tagged_example "1.method(:abs)"
tagged_example "1.method(:abs).unbind"
tagged_example "1.method(:abs).unbind.bind(-2)"
example "1.method(:abs).call", 1
example "1.method(:abs).unbind.bind(-2).call", 2
10 changes: 5 additions & 5 deletions test/truffle/pe/core/objectid_pe.rb
Original file line number Diff line number Diff line change
@@ -6,12 +6,12 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

example "nil.object_id"
example "nil.object_id", 4

example "true.object_id"
example "true.object_id", 2

example "false.object_id"
example "false.object_id", 0

example "14.object_id"
example "14.object_id", 29

example "(14 + 2).object_id"
example "(14 + 2).object_id", 33
6 changes: 3 additions & 3 deletions test/truffle/pe/core/send_pe.rb
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

example "14.send(:*, 2)"
example "14.send(:*, 2)", 28

example "14.send('*', 2)"
example "14.send('*', 2)", 28

example "14.send((')'.ord + 1).chr, 2)"
example "14.send((')'.ord + 1).chr, 2)", 28
6 changes: 3 additions & 3 deletions test/truffle/pe/core/symbol_pe.rb
Original file line number Diff line number Diff line change
@@ -6,6 +6,6 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

example ":foo"
example ":foo == :foo"
example ":foo != :bar"
example ":foo", :foo
example ":foo == :foo", true
example ":foo != :bar", true
4 changes: 2 additions & 2 deletions test/truffle/pe/core/truefalse_pe.rb
Original file line number Diff line number Diff line change
@@ -6,5 +6,5 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

example "true"
example "false"
example "true", true
example "false", false
2 changes: 1 addition & 1 deletion test/truffle/pe/language/closures_pe.rb
Original file line number Diff line number Diff line change
@@ -14,4 +14,4 @@ def self.yielder

end

example "x = 14; ClosureFixtures.yielder { x } + 2"
example "x = 14; ClosureFixtures.yielder { x } + 2", 16
14 changes: 7 additions & 7 deletions test/truffle/pe/language/constant_pe.rb
Original file line number Diff line number Diff line change
@@ -48,14 +48,14 @@ def self.const_missing(const)
end
end

example "ConstantFixtures.get_existing"
example "ConstantFixtures.get"
example "ConstantFixtures.get_const_get(:A)"
example "ConstantFixtures.get_existing", Proc
example "ConstantFixtures.get", 1
example "ConstantFixtures.get_const_get(:A)", 1

# Internal Graal compiler error
tagged_example "ConstantFixtures.get_const_get('A')"
tagged_example "ConstantFixtures.get_const_get('A')", 1

example "ConstantFixtures::Nested.get_nested"
example "ConstantFixtures::Child.get_inherited"
example "ConstantFixtures::Nested.get_nested", 1
example "ConstantFixtures::Child.get_inherited", 2

example "ConstantFixtures::ConstMissing.get_missing"
example "ConstantFixtures::ConstMissing.get_missing", :NO_SUCH_NAMED_CONSTANT
2 changes: 1 addition & 1 deletion test/truffle/pe/language/controlflow_pe.rb
Original file line number Diff line number Diff line change
@@ -6,5 +6,5 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

example "rand < 0.5 ? 14 : 16 - 2"
example "rand < 0.5 ? 14 : 16 - 2", 14
counter_example "rand < 0.5 ? 14 : 16 + 2"
8 changes: 4 additions & 4 deletions test/truffle/pe/language/ivar_pe.rb
Original file line number Diff line number Diff line change
@@ -26,8 +26,8 @@ def reset_b(b)
end
end

example "IVarFixtures::Foo.new(1,2).a"
example "IVarFixtures::Foo.new(1,2).b"
example "IVarFixtures::Foo.new(1,2).a", 1
example "IVarFixtures::Foo.new(1,2).b", 2

example "IVarFixtures::Foo.new(1,2).reset_b(42).b"
example "IVarFixtures::Foo.new(1,2).reset_b([]).b.empty?"
example "IVarFixtures::Foo.new(1,2).reset_b(42).b", 42
example "IVarFixtures::Foo.new(1,2).reset_b([]).b.empty?", true
6 changes: 3 additions & 3 deletions test/truffle/pe/language/metaprogramming_pe.rb
Original file line number Diff line number Diff line change
@@ -26,6 +26,6 @@ def existing_method(a)

end

example "MetaprogrammingFixtures::MethodMissing.new.does_not_exist"
example "MetaprogrammingFixtures::ClassWithExistingMethod.new.respond_to?(:existing_method)"
example "MetaprogrammingFixtures::ClassWithExistingMethod.new.send(:existing_method, 14)"
example "MetaprogrammingFixtures::MethodMissing.new.does_not_exist", 14
example "MetaprogrammingFixtures::ClassWithExistingMethod.new.respond_to?(:existing_method)", true
example "MetaprogrammingFixtures::ClassWithExistingMethod.new.send(:existing_method, 15)", 15
Loading

0 comments on commit 7633e99

Please sign in to comment.