Skip to content

Commit e7a4962

Browse files
Add specs for WinError
1 parent b1c7b28 commit e7a4962

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

spec/std/system_error_spec.cr

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,22 @@ describe SystemError do
2222
error.os_error.should eq Errno::ENOENT
2323
end
2424
end
25+
26+
{% if flag?(:win32) %}
27+
describe ".from_winerror" do
28+
it "avoid reset from message" do
29+
WinError.value = :ERROR_FILE_NOT_FOUND
30+
error = ::RuntimeError.from_winerror(message: "foobar".tap { WinError.value = :ERROR_ACCESS_DENIED })
31+
error.os_error.should eq WinError::ERROR_ACCESS_DENIED # This should be ERROR_FILE_NOT_FOUND
32+
end
33+
end
34+
35+
describe ".from_wsa_error" do
36+
it "avoid reset from message" do
37+
WinError.wsa_value = :ERROR_FILE_NOT_FOUND
38+
error = ::RuntimeError.from_wsa_error(message: "foobar".tap { WinError.wsa_value = :ERROR_ACCESS_DENIED })
39+
error.os_error.should eq WinError::ERROR_ACCESS_DENIED # This should be ERROR_FILE_NOT_FOUND
40+
end
41+
end
42+
{% end %}
2543
end

0 commit comments

Comments
 (0)