Skip to content

Commit 9a1b347

Browse files
committed
Improve Polyglot::ForeignException specs
1 parent 6e1c02c commit 9a1b347

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

spec/truffle/interop/polyglot/foreign_exception_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
@foreign = Truffle::Debug.foreign_exception("exception message")
1414
end
1515

16+
it "subclasses Exception" do
17+
@foreign.class.should == Polyglot::ForeignException
18+
@foreign.class.superclass.should == Exception
19+
end
20+
1621
it "supports #message" do
1722
@foreign.message.should == "exception message"
1823
end
@@ -21,6 +26,15 @@
2126
@foreign.cause.should == nil
2227
end
2328

29+
it "supports #full_message" do
30+
-> {
31+
raise @foreign
32+
}.should raise_error(Polyglot::ForeignException) {
33+
full_message = @foreign.full_message(highlight: false, order: :top).lines
34+
full_message[0].should == "#{__FILE__}:#{__LINE__-3}:in `Kernel#raise': exception message (Polyglot::ForeignException)\n"
35+
}
36+
end
37+
2438
it "supports rescue Polyglot::ForeignException" do
2539
begin
2640
raise @foreign
@@ -29,6 +43,14 @@
2943
end
3044
end
3145

46+
it "supports rescue Exception" do
47+
begin
48+
raise @foreign
49+
rescue Exception => e # rubocop:disable Lint/RescueException
50+
e.should.equal?(@foreign)
51+
end
52+
end
53+
3254
it "supports rescue Object" do
3355
begin
3456
raise @foreign

0 commit comments

Comments
 (0)