Skip to content

Commit

Permalink
Showing 25 changed files with 197 additions and 113 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 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"
35 changes: 35 additions & 0 deletions test/truffle/pe/core/frozen_pe.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 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?"

example "false.frozen?"

# int
example "3.frozen?"

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

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

# float
example "3.5.frozen?"

# double
example "(2**62).to_f.frozen?"

example ":symbol.frozen?"

example "nil.frozen?"

example "'abc'.frozen?"

example "'abc'.freeze.frozen?"
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
8 changes: 4 additions & 4 deletions test/truffle/pe/language/super_pe.rb
Original file line number Diff line number Diff line change
@@ -30,8 +30,8 @@ def call_zsuper(n)
INSTANCE = Child.new
end

example "SuperFixtures::INSTANCE.call_super(42)"
example "SuperFixtures::INSTANCE.call_zsuper(24)"
example "SuperFixtures::INSTANCE.call_super(42)", 84
example "SuperFixtures::INSTANCE.call_zsuper(24)", 72

example "SuperFixtures::Child.new.call_super(42)"
example "SuperFixtures::Child.new.call_zsuper(24)"
example "SuperFixtures::Child.new.call_super(42)", 84
example "SuperFixtures::Child.new.call_zsuper(24)", 72
2 changes: 1 addition & 1 deletion test/truffle/pe/macro/pushing_pixels_pe.rb
Original file line number Diff line number Diff line change
@@ -35,4 +35,4 @@ def method_missing(method, *args)

end

example "PushingPixelsFixtures::Bar.new.foo(14, 8, 6)"
example "PushingPixelsFixtures::Bar.new.foo(14, 8, 6)", 22
Loading

0 comments on commit 6d25089

Please sign in to comment.