Skip to content

Commit d3a9d30

Browse files
committed
Fix formatting and code style in specs
1 parent 27451b5 commit d3a9d30

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

spec/ruby/core/exception/case_compare_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@
2626
end
2727

2828
it "returns true if receiver is generic and arg is kind of SystemCallError" do
29-
unknown_error_number = Errno.constants.size
3029
e = SystemCallError.new('foo', @example_errno)
3130
SystemCallError.===(e).should == true
3231
end
3332

3433
it "returns false if receiver is generic and arg is not kind of SystemCallError" do
35-
unknown_error_number = Errno.constants.size
3634
e = Object.new
3735
SystemCallError.===(e).should == false
3836
end

spec/ruby/optional/capi/exception_spec.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
end
102102

103103
describe "rb_syserr_new" do
104-
it "returns system error with nil message" do
104+
it "returns system error with default message when passed message is NULL" do
105105
exception = @s.rb_syserr_new(Errno::ENOENT::Errno, nil)
106106
exception.class.should == Errno::ENOENT
107107
exception.message.should include("No such file or directory")
@@ -110,16 +110,17 @@
110110

111111
it "returns system error with custom message" do
112112
exception = @s.rb_syserr_new(Errno::ENOENT::Errno, "custom message")
113+
113114
exception.message.should include("custom message")
114115
exception.class.should == Errno::ENOENT
115116
exception.should.is_a?(SystemCallError)
116117
end
117118
end
118119

119120
describe "rb_syserr_new_str" do
120-
it "returns system error with nil message" do
121-
const = Errno::ENOENT
122-
exception = @s.rb_syserr_new_str(const::Errno, nil)
121+
it "returns system error with default message when passed message is nil" do
122+
exception = @s.rb_syserr_new_str(Errno::ENOENT::Errno, nil)
123+
123124
exception.message.should include("No such file or directory")
124125
exception.class.should == Errno::ENOENT
125126
exception.should.is_a?(SystemCallError)

spec/ruby/optional/capi/ext/exception_spec.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ VALUE exception_spec_rb_set_errinfo(VALUE self, VALUE exc) {
3737
}
3838

3939
VALUE exception_spec_rb_syserr_new(VALUE self, VALUE num, VALUE msg) {
40-
char *cstr;
41-
if(msg != Qnil) {
40+
int n = NUM2INT(num);
41+
char *cstr = NULL;
42+
43+
if (msg != Qnil) {
4244
cstr = StringValuePtr(msg);
4345
}
44-
int n = NUM2INT(num);
46+
4547
return rb_syserr_new(n, cstr);
4648
}
4749

src/main/java/org/truffleruby/core/exception/ErrnoErrorNode.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ protected RubySystemCallError errnoError(RubyClass rubyClass, int errno, Object
4242

4343
final Object errnoDescription;
4444
final RubyClass errnoClass;
45+
4546
if (errnoName == null) {
4647
errnoClass = getContext().getCoreLibrary().systemCallErrorClass;
4748
errnoDescription = nil;
@@ -52,12 +53,10 @@ protected RubySystemCallError errnoError(RubyClass rubyClass, int errno, Object
5253
errnoClass = getContext().getCoreLibrary().getErrnoClass(errnoName);
5354
}
5455

55-
5656
errnoDescription = createString(fromJavaStringNode, ErrnoDescriptions.getDescription(errnoName),
5757
Encodings.UTF_8);
5858
}
5959

60-
6160
final RubyString errorMessage = formatMessage(errnoDescription, errno, extraMessage);
6261

6362
return ExceptionOperations
@@ -66,10 +65,12 @@ protected RubySystemCallError errnoError(RubyClass rubyClass, int errno, Object
6665

6766
private RubyString formatMessage(Object errnoDescription, int errno, Object extraMessage) {
6867
assert extraMessage instanceof RubyString || extraMessage instanceof ImmutableRubyString;
68+
6969
if (formatMessageNode == null) {
7070
CompilerDirectives.transferToInterpreterAndInvalidate();
7171
formatMessageNode = insert(DispatchNode.create());
7272
}
73+
7374
return (RubyString) formatMessageNode.call(
7475
getContext().getCoreLibrary().truffleExceptionOperationsModule,
7576
"format_errno_error_message",

0 commit comments

Comments
 (0)