Skip to content

Commit

Permalink
Showing 73 changed files with 670 additions and 366 deletions.
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -265,6 +265,7 @@ public class Options {
public static final Option<Boolean> TRUFFLE_EXCEPTIONS_PRINT_UNCAUGHT_JAVA = bool(TRUFFLE, "truffle.exceptions.print_uncaught_java", false, "Print uncaught Java exceptions at the point of translating them to Ruby exceptions.");
public static final Option<Boolean> TRUFFLE_BACKTRACES_HIDE_CORE_FILES = bool(TRUFFLE, "truffle.backtraces.hide_core_files", true, "Hide core source files in backtraces, like MRI does.");
public static final Option<Integer> TRUFFLE_BACKTRACES_LIMIT = integer(TRUFFLE, "truffle.backtraces.limit", 9999, "Limit the size of Ruby backtraces.");
public static final Option<Boolean> TRUFFLE_BACKTRACES_OMIT_UNUSED = bool(TRUFFLE, "truffle.backtraces.omit_unused", true, "Omit backtraces that should be unused as they have pure rescue expressions.");
public static final Option<Boolean> TRUFFLE_INCLUDE_CORE_FILE_CALLERS_IN_SET_TRACE_FUNC = bool(TRUFFLE, "truffle.set_trace_func.include_core_file_callers", false, "Include internal core library calls in set_trace_func output.");

public static final Option<Boolean> TRUFFLE_METRICS_TIME = bool(TRUFFLE, "truffle.metrics.time", false, "Print the time at various stages of VM operation.");
1 change: 1 addition & 0 deletions spec/mspec/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sudo: false
language: ruby
script:
- bundle exec rspec
21 changes: 15 additions & 6 deletions spec/mspec/lib/mspec/matchers/raise_error.rb
Original file line number Diff line number Diff line change
@@ -9,17 +9,26 @@ def matches?(proc)
@result = proc.call
return false
rescue Exception => @actual
return false unless @exception === @actual
if matching_exception?(@actual)
return true
else
raise @actual
end
end

def matching_exception?(exc)
return false unless @exception === exc
if @message then
case @message
when String then
return false if @message != @actual.message
when Regexp then
return false if @message !~ @actual.message
when String
return false if @message != exc.message
when Regexp
return false if @message !~ exc.message
end
end

@block[@actual] if @block
# The block has its own expectations and will throw an exception if it fails
@block[exc] if @block

return true
end
8 changes: 4 additions & 4 deletions spec/mspec/lib/mspec/runner/evaluate.rb
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ def self.desc
end

def initialize(ruby, desc)
@ruby = ruby
@ruby = ruby.rstrip
@desc = desc || self.class.desc
end

@@ -18,8 +18,8 @@ def initialize(ruby, desc)
# the source does contain newline characters, sets the indent level to four
# characters.
def format(ruby, newline=true)
if /\n/ =~ ruby
lines = ruby.rstrip.each_line.to_a
if ruby.include?("\n")
lines = ruby.each_line.to_a
if /( *)/ =~ lines.first
if $1.size > 4
dedent = $1.size - 4
@@ -31,7 +31,7 @@ def format(ruby, newline=true)
end
"\n#{ruby}"
else
"'#{ruby}'"
"'#{ruby.lstrip}'"
end
end

2 changes: 1 addition & 1 deletion spec/mspec/lib/mspec/utils/name_map.rb
Original file line number Diff line number Diff line change
@@ -110,7 +110,7 @@ def map(hash, constants, mod=nil)
ms.map! { |x| x.to_s }
hash["#{name}#"] = ms.sort unless ms.empty?

map hash, m.constants, name
map hash, m.constants(false), name
end

hash
2 changes: 1 addition & 1 deletion spec/mspec/lib/mspec/utils/options.rb
Original file line number Diff line number Diff line change
@@ -150,7 +150,7 @@ def parse(argv=ARGV)
opt, arg, rest = split rest, 1
opt = "-" + opt
option = process argv, opt, opt, arg
break if option.arg?
break if !option or option.arg?
end
end

41 changes: 32 additions & 9 deletions spec/mspec/spec/matchers/raise_error_spec.rb
Original file line number Diff line number Diff line change
@@ -8,7 +8,8 @@ class UnexpectedException < Exception; end
describe RaiseErrorMatcher do
it "matches when the proc raises the expected exception" do
proc = Proc.new { raise ExpectedException }
RaiseErrorMatcher.new(ExpectedException, nil).matches?(proc).should == true
matcher = RaiseErrorMatcher.new(ExpectedException, nil)
matcher.matches?(proc).should == true
end

it "executes it's optional block if matched" do
@@ -25,28 +26,50 @@ class UnexpectedException < Exception; end

it "matches when the proc raises the expected exception with the expected message" do
proc = Proc.new { raise ExpectedException, "message" }
RaiseErrorMatcher.new(ExpectedException, "message").matches?(proc).should == true
matcher = RaiseErrorMatcher.new(ExpectedException, "message")
matcher.matches?(proc).should == true
end

it "matches when the proc raises the expected exception with a matching message" do
proc = Proc.new { raise ExpectedException, "some message" }
matcher = RaiseErrorMatcher.new(ExpectedException, /some/)
matcher.matches?(proc).should == true
end

it "does not match when the proc does not raise the expected exception" do
proc = Proc.new { raise UnexpectedException }
RaiseErrorMatcher.new(ExpectedException, nil).matches?(proc).should == false
exc = UnexpectedException.new
matcher = RaiseErrorMatcher.new(ExpectedException, nil)

matcher.matching_exception?(exc).should == false
lambda {
matcher.matches?(Proc.new { raise exc })
}.should raise_error(UnexpectedException)
end

it "does not match when the proc raises the expected exception with an unexpected message" do
proc = Proc.new { raise ExpectedException, "unexpected" }
RaiseErrorMatcher.new(ExpectedException, "expected").matches?(proc).should == false
exc = ExpectedException.new("unexpected")
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")

matcher.matching_exception?(exc).should == false
lambda {
matcher.matches?(Proc.new { raise exc })
}.should raise_error(ExpectedException)
end

it "does not match when the proc does not raise an exception" do
proc = Proc.new {}
RaiseErrorMatcher.new(ExpectedException, "expected").matches?(proc).should == false
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
matcher.matches?(proc).should == false
end

it "provides a useful failure message" do
proc = Proc.new { raise UnexpectedException, "unexpected" }
exc = UnexpectedException.new("unexpected")
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
matcher.matches?(proc)

matcher.matching_exception?(exc).should == false
lambda {
matcher.matches?(Proc.new { raise exc })
}.should raise_error(UnexpectedException)
matcher.failure_message.should ==
["Expected ExpectedException (expected)", "but got UnexpectedException (unexpected)"]
end
74 changes: 2 additions & 72 deletions spec/mspec/spec/matchers/raise_exception_spec.rb
Original file line number Diff line number Diff line change
@@ -6,77 +6,7 @@ class ExpectedException < Exception; end
class UnexpectedException < Exception; end

describe RaiseExceptionMatcher do
it "matches when the proc raises the expected exception" do
proc = Proc.new { raise ExpectedException }
RaiseErrorMatcher.new(ExpectedException, nil).matches?(proc).should == true
end

it "executes it's optional block if matched" do
run = false
proc = Proc.new { raise ExpectedException }
matcher = RaiseErrorMatcher.new(ExpectedException, nil) { |error|
run = true
error.class.should == ExpectedException
}

matcher.matches?(proc).should == true
run.should == true
end

it "matches when the proc raises the expected exception with the expected message" do
proc = Proc.new { raise ExpectedException, "message" }
RaiseErrorMatcher.new(ExpectedException, "message").matches?(proc).should == true
end

it "does not match when the proc does not raise the expected exception" do
proc = Proc.new { raise UnexpectedException }
RaiseErrorMatcher.new(ExpectedException, nil).matches?(proc).should == false
end

it "does not match when the proc raises the expected exception with an unexpected message" do
proc = Proc.new { raise ExpectedException, "unexpected" }
RaiseErrorMatcher.new(ExpectedException, "expected").matches?(proc).should == false
end

it "does not match when the proc does not raise an exception" do
proc = Proc.new {}
RaiseErrorMatcher.new(ExpectedException, "expected").matches?(proc).should == false
end

it "does not match when the raised exception is not an instance of the expected exception" do
proc = Proc.new { raise Exception }
RaiseErrorMatcher.new(ExpectedException, nil).matches?(proc).should == false
end

it "provides a useful failure message" do
proc = Proc.new { raise UnexpectedException, "unexpected" }
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
matcher.matches?(proc)
matcher.failure_message.should ==
["Expected ExpectedException (expected)", "but got UnexpectedException (unexpected)"]
end

it "provides a useful failure message when no exception is raised" do
proc = Proc.new { 120 }
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
matcher.matches?(proc)
matcher.failure_message.should ==
["Expected ExpectedException (expected)", "but no exception was raised (120 was returned)"]
end

it "provides a useful negative failure message" do
proc = Proc.new { raise ExpectedException, "expected" }
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
matcher.matches?(proc)
matcher.negative_failure_message.should ==
["Expected to not get ExpectedException (expected)", ""]
end

it "provides a useful negative failure message for strict subclasses of the matched exception class" do
proc = Proc.new { raise UnexpectedException, "unexpected" }
matcher = RaiseErrorMatcher.new(Exception, nil)
matcher.matches?(proc)
matcher.negative_failure_message.should ==
["Expected to not get Exception", "but got UnexpectedException (unexpected)"]
it "is a legac alias of RaiseErrorMatcher" do
RaiseExceptionMatcher.should equal(RaiseErrorMatcher)
end
end
1 change: 1 addition & 0 deletions spec/tags/ruby/core/dir/pwd_tags.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
fails:Dir.pwd returns a String with Encoding.default_external encoding
fails:Dir.pwd does not transcode to Encoding.default_internal
fails:Dir.pwd correctly handles dirs with unicode characters in them
3 changes: 3 additions & 0 deletions spec/tags/ruby/core/exception/name_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:NameError#name returns a class variable name as a symbol
fails:NameError#name always returns a symbol when a NameError is raised from #instance_variable_get
fails:NameError#name always returns a symbol when a NameError is raised from #class_variable_get
1 change: 1 addition & 0 deletions spec/tags/ruby/core/float/constants_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Float constant MIN is 2.2250738585072014e-308
28 changes: 28 additions & 0 deletions spec/tags/ruby/core/kernel/Float_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
errors:Kernel.Float for hexadecimal literals with binary exponent interprets the fractional part (on the left side of 'p') in hexadecimal
errors:Kernel.Float for hexadecimal literals with binary exponent interprets the exponent (on the right of 'p') in decimal
errors:Kernel.Float for hexadecimal literals with binary exponent returns Infinity for '0x1p10000'
errors:Kernel.Float for hexadecimal literals with binary exponent interprets the fractional part
fails:Kernel.Float for hexadecimal literals with binary exponent interprets the fractional part (on the left side of 'p') in hexadecimal
fails:Kernel.Float for hexadecimal literals with binary exponent interprets the exponent (on the right of 'p') in decimal
fails:Kernel.Float for hexadecimal literals with binary exponent returns Infinity for '0x1p10000'
fails:Kernel.Float for hexadecimal literals with binary exponent returns 0 for '0x1p-10000'
fails:Kernel.Float for hexadecimal literals with binary exponent allows embedded _ in a number on either side of the p
fails:Kernel.Float for hexadecimal literals with binary exponent allows hexadecimal points on the left side of the 'p'
fails:Kernel.Float for hexadecimal literals with binary exponent interprets the fractional part (on the left side of 'P') in hexadecimal
fails:Kernel.Float for hexadecimal literals with binary exponent interprets the exponent (on the right of 'P') in decimal
fails:Kernel.Float for hexadecimal literals with binary exponent returns Infinity for '0x1P10000'
fails:Kernel.Float for hexadecimal literals with binary exponent returns 0 for '0x1P-10000'
fails:Kernel.Float for hexadecimal literals with binary exponent allows embedded _ in a number on either side of the P
fails:Kernel.Float for hexadecimal literals with binary exponent allows hexadecimal points on the left side of the 'P'
fails:Kernel#Float for hexadecimal literals with binary exponent interprets the fractional part (on the left side of 'p') in hexadecimal
fails:Kernel#Float for hexadecimal literals with binary exponent interprets the exponent (on the right of 'p') in decimal
fails:Kernel#Float for hexadecimal literals with binary exponent returns Infinity for '0x1p10000'
fails:Kernel#Float for hexadecimal literals with binary exponent returns 0 for '0x1p-10000'
fails:Kernel#Float for hexadecimal literals with binary exponent allows embedded _ in a number on either side of the p
fails:Kernel#Float for hexadecimal literals with binary exponent allows hexadecimal points on the left side of the 'p'
fails:Kernel#Float for hexadecimal literals with binary exponent interprets the fractional part (on the left side of 'P') in hexadecimal
fails:Kernel#Float for hexadecimal literals with binary exponent interprets the exponent (on the right of 'P') in decimal
fails:Kernel#Float for hexadecimal literals with binary exponent returns Infinity for '0x1P10000'
fails:Kernel#Float for hexadecimal literals with binary exponent returns 0 for '0x1P-10000'
fails:Kernel#Float for hexadecimal literals with binary exponent allows embedded _ in a number on either side of the P
fails:Kernel#Float for hexadecimal literals with binary exponent allows hexadecimal points on the left side of the 'P'
2 changes: 2 additions & 0 deletions spec/tags/ruby/core/module/autoload_tags.txt
Original file line number Diff line number Diff line change
@@ -2,3 +2,5 @@ fails:Module#autoload does not load the file when refering to the constant in de
fails:Module#autoload shares the autoload request across dup'ed copies of modules
fails:Module#autoload returns 'constant' on refering the constant with defined?()
fails(ruby-10741):Module#autoload does not load the file when accessing the constants table of the module
fails:Module#autoload does not load the file when referring to the constant in defined?
fails:Module#autoload returns 'constant' on referring the constant with defined?()
2 changes: 2 additions & 0 deletions spec/tags/ruby/core/range/inspect_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:Range#inspect returns a tainted string if either end is tainted
fails:Range#inspect returns a untrusted string if either end is untrusted
2 changes: 2 additions & 0 deletions spec/tags/ruby/core/range/to_s_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:Range#to_s returns a tainted string if either end is tainted
fails:Range#to_s returns a untrusted string if either end is untrusted
26 changes: 13 additions & 13 deletions spec/tags/ruby/language/method_tags.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
fails:"A method assigns local variables from method parameters for definition \n def m(*a, b: 1) [a, b] end"
fails:"A method assigns local variables from method parameters for definition \n def m(*a, **) a end"
fails:"A method assigns local variables from method parameters for definition \n def m(*, **k) k end"
fails:"A method assigns local variables from method parameters for definition \n def m(a = nil, **k) [a, k] end"
fails:"A method assigns local variables from method parameters for definition \n def m(*a, **k) [a, k] end"
fails:"A method assigns local variables from method parameters for definition \n def m(a=1, b:) [a, b] end"
fails:"A method assigns local variables from method parameters for definition \n def m(a=1, b: 2) [a, b] end"
fails:"A method assigns local variables from method parameters for definition \n def m(a=1, **) a end"
fails:"A method assigns local variables from method parameters for definition \n def m(*, a:) a end"
fails:"A method assigns local variables from method parameters for definition \n def m(*a, b:) [a, b] end"
fails:"A method assigns local variables from method parameters for definition \n def m(*, a: 1) a end"
fails:"A method assigns local variables from method parameters for definition \n def m(a:, **) a end"
fails:"A method assigns local variables from method parameters for definition \n def m(a:, **k) [a, k] end"
fails:A method assigns local variables from method parameters for definition 'def m(a=1, b:) [a, b] end'
fails:A method assigns local variables from method parameters for definition 'def m(a=1, b: 2) [a, b] end'
fails:A method assigns local variables from method parameters for definition 'def m(a=1, **) a end'
fails:A method assigns local variables from method parameters for definition 'def m(*, a:) a end'
fails:A method assigns local variables from method parameters for definition 'def m(*a, b:) [a, b] end'
fails:A method assigns local variables from method parameters for definition 'def m(*, a: 1) a end'
fails:A method assigns local variables from method parameters for definition 'def m(*a, b: 1) [a, b] end'
fails:A method assigns local variables from method parameters for definition 'def m(*a, **) a end'
fails:A method assigns local variables from method parameters for definition 'def m(*, **k) k end'
fails:A method assigns local variables from method parameters for definition 'def m(a = nil, **k) [a, k] end'
fails:A method assigns local variables from method parameters for definition 'def m(*a, **k) [a, k] end'
fails:A method assigns local variables from method parameters for definition 'def m(a:, **) a end'
fails:A method assigns local variables from method parameters for definition 'def m(a:, **k) [a, k] end'
1 change: 1 addition & 0 deletions spec/tags/ruby/library/bigdecimal/infinite_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:BigDecimal#infinite? returns not true otherwise
1 change: 1 addition & 0 deletions spec/tags/ruby/library/bigdecimal/nonzero_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:BigDecimal#nonzero? returns nil otherwise
1 change: 1 addition & 0 deletions spec/tags/ruby/library/bigdecimal/round_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:BigDecimal#round raise exception, if self is special value
1 change: 1 addition & 0 deletions spec/tags/ruby/library/bigdecimal/zero_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:BigDecimal#zero? returns true if self does equal zero
1 change: 1 addition & 0 deletions spec/tags/ruby/library/fiber/transfer_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
critical(hangs):Fiber#transfer can be invoked from the same Fiber it transfers control to
critical(hangs):Fiber#transfer raises a FiberError when transferring to a Fiber which resumes itself
unstable(intermittent):Fiber#transfer raises a LocalJumpError if the block includes a return statement
fails:Fiber#transfer can be invoked from the same Fiber it transfers control to
7 changes: 7 additions & 0 deletions spec/tags/ruby/library/zlib/deflate/deflate_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fails:Zlib::Deflate.deflate deflates chunked data
fails:Zlib::Deflate#deflate without break deflates chunked data
fails:Zlib::Deflate#deflate without break deflates chunked data with final chunk
fails:Zlib::Deflate#deflate without break deflates chunked data without errors
fails:Zlib::Deflate#deflate with break deflates only first chunk
fails:Zlib::Deflate#deflate with break deflates chunked data with final chunk
fails:Zlib::Deflate#deflate with break deflates chunked data without errors
1 change: 1 addition & 0 deletions spec/tags/ruby/library/zlib/inflate/finish_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Zlib::Inflate#finish inflates chunked data
1 change: 1 addition & 0 deletions spec/tags/ruby/library/zlib/inflate/inflate_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Zlib::Inflate#inflate without break inflates chunked data
1 change: 1 addition & 0 deletions spec/truffle/tags/core/io/sync_tags.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
fails:IO#sync is false by default for STDOUT
fails:IO#sync is true by default for STDERR
3 changes: 3 additions & 0 deletions test/truffle/integration/backtraces.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

ruby -X+T test/truffle/integration/backtraces/backtraces.rb
Loading

0 comments on commit 8cb9a6a

Please sign in to comment.