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: 0516e2fa666c
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3a46dc146c60
Choose a head ref
  • 2 commits
  • 8 files changed
  • 1 contributor

Commits on Oct 13, 2014

  1. Copy the full SHA
    735be4a View commit details
  2. Copy the full SHA
    3a46dc1 View commit details
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyContext;

@NodeChild("body")
@NodeChild("value")
public abstract class AssertCompilationConstantNode extends RubyNode {

public AssertCompilationConstantNode(RubyContext context, SourceSection sourceSection) {
@@ -30,27 +30,32 @@ public AssertCompilationConstantNode(AssertCompilationConstantNode prev) {

@Specialization
public boolean assertCompilationConstant(boolean value) {
return CompilerAsserts.compilationConstant(value);
CompilerAsserts.compilationConstant(value);
return value;
}

@Specialization
public int assertCompilationConstant(int value) {
return CompilerAsserts.compilationConstant(value);
CompilerAsserts.compilationConstant(value);
return value;
}

@Specialization
public long assertCompilationConstant(long value) {
return CompilerAsserts.compilationConstant(value);
CompilerAsserts.compilationConstant(value);
return value;
}

@Specialization
public double assertCompilationConstant(double value) {
return CompilerAsserts.compilationConstant(value);
CompilerAsserts.compilationConstant(value);
return value;
}

@Specialization
public Object assertCompilationConstant(Object value) {
return CompilerAsserts.compilationConstant(value);
CompilerAsserts.compilationConstant(value);
return value;
}

}
2 changes: 1 addition & 1 deletion test/pom.rb
Original file line number Diff line number Diff line change
@@ -243,7 +243,7 @@
'<exec dir="${jruby.home}" executable="${jruby.home}/bin/jruby" failonerror="true">' +
'<arg value="-J-server" />' +
'<arg value="-J-G:-TruffleBackgroundCompilation" />' +
'<arg value="-J-G:+TruffleCompilationExceptionsAreThrown" />' +
'<arg value="-J-G:+TruffleCompilationExceptionsAreFatal" />' +
'<arg value="-X+T" />' +
'<arg value="-Xtruffle.debug.enable_assert_constant=true" />' +
'<arg value="test/truffle/pe/pe.rb" />' +
2 changes: 1 addition & 1 deletion test/pom.xml
Original file line number Diff line number Diff line change
@@ -407,7 +407,7 @@
<exec dir="${jruby.home}" executable="${jruby.home}/bin/jruby" failonerror="true">
<arg value="-J-server" />
<arg value="-J-G:-TruffleBackgroundCompilation" />
<arg value="-J-G:+TruffleCompilationExceptionsAreThrown" />
<arg value="-J-G:+TruffleCompilationExceptionsAreFatal" />
<arg value="-X+T" />
<arg value="-Xtruffle.debug.enable_assert_constant=true" />
<arg value="test/truffle/pe/pe.rb" />
14 changes: 11 additions & 3 deletions test/truffle/pe/core/fixnum_pe.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Literals
PETests.tests do

example { truffle_assert_constant 14 }
example { truffle_assert_constant 0xffffffffffff }
describe "A Fixnum" do

example "literal" do
truffle_assert_constant 14
truffle_assert_constant 0xffffffffffff
end

end

end
12 changes: 10 additions & 2 deletions test/truffle/pe/core/float_pe.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Literals
PETests.tests do

example { truffle_assert_constant 14.2 }
describe "A Fixnum" do

example "literal" do
truffle_assert_constant 14.2
end

end

end
12 changes: 10 additions & 2 deletions test/truffle/pe/core/symbol_pe.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Literals
PETests.tests do

example { truffle_assert_constant :foo }
describe "A Symbol" do

example "literal" do
truffle_assert_constant :foo
end

end

end
17 changes: 14 additions & 3 deletions test/truffle/pe/core/truefalse_pe.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# Literals
PETests.tests do

example { truffle_assert_constant true }
example { truffle_assert_constant false }
describe "A boolean" do

example "true literal" do
truffle_assert_constant true
end

example "false literal" do
truffle_assert_constant false
end

end

end
109 changes: 88 additions & 21 deletions test/truffle/pe/pe.rb
Original file line number Diff line number Diff line change
@@ -12,34 +12,101 @@
# helper method. truffle_assert_constant looks like a method but is replaced
# in the parser with a specific node.

$failures = 0
# Definition of the DSL

def example
1_000_000.times do
yield
module PETests

def self.start
@description_stack = []
@failures = []
@successes = []
@dots = 0
end

print "."
rescue RubyTruffleError
$failures += 1
print "E"
end
def self.tests(&block)
instance_eval &block
end

def self.describe(description)
@description_stack.push description

begin
yield
ensure
@description_stack.pop
end
end

def self.example(description)
describe "#{description} is constant" do
inner_example do
yield
end
end
end

def self.counter_example(description)
puts "warning: counter examples not run"
#describe "#{description} is not constant" do
# inner_example do
# yield
# end
#end
end

def self.finish
print "\n"

if @failures.empty?
puts "success - #{@successes.length} passed"
true
else
puts "failure - #{@failures.length} failed, #{@successes.length} passed"

@failures.each do |message|
puts "failed: #{message}"
end

def counter_example
1_000_000.times do
yield
false
end
end

def self.inner_example
1_000_000.times do
yield
end

@successes.push @description_stack.join(" ")
print "."
rescue RubyTruffleError
@failures.push @description_stack.join(" ")
print "E"
ensure
@dots += 1
puts if @dots == 80
end

$failures += 1
print "E"
rescue RubyTruffleError
print "."
end

# Two simple tests to check we're working
PETests.start

# Test we're working

PETests.tests do

describe "For example" do

example { truffle_assert_constant 14 }
#counter_example { truffle_assert_constant rand }
example "a fixnum literal" do
truffle_assert_constant 14
end

counter_example "a call to #rand" do
truffle_assert_constant rand
end

end

end

# Tests organised by class

@@ -50,6 +117,6 @@ def counter_example
require "core/float_pe.rb"
require "core/symbol_pe.rb"

print "\n"
# Finished

exit 1 unless $failures.zero?
exit 1 unless PETests.finish