Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add StandardError##raise:

  • Loading branch information...
commit af9669bd61d2d44f499215b8c85b326e1b494066 1 parent ed8e66f
@bakkdoor authored
Showing with 24 additions and 0 deletions.
  1. +1 −0  lib/boot.fy
  2. +16 −0 lib/exception.fy
  3. +7 −0 tests/exception.fy
View
1  lib/boot.fy
@@ -18,6 +18,7 @@ require: "class"
require: "true_class"
require: "nil_class"
require: "false_class"
+require: "exception"
require: "number"
require: "enumerable"
require: "string"
View
16 lib/exception.fy
@@ -0,0 +1,16 @@
+class StandardError {
+ def self raise: message {
+ """
+ Raises new @Exception@ with @message.
+
+ Example:
+ StandardError raise: \"Error!\"
+ ArgumentError raise: \"Missing argument!\"
+ # is the same as:
+ StandardError new: \"Error!\” . raise!
+ ArgumentError new: \"Missing argument!\" . raise!
+ """
+
+ new: message . raise!
+ }
+}
View
7 tests/exception.fy
@@ -157,4 +157,11 @@ FancySpec describe: StdError with: {
{ do_something } raises: IOError
@ran_finally? is: true
}
+
+ it: "raises an exception" with: 'raise: when: {
+ { StandardError raise: "error" } raises: Exception with: @{ message is: "error" }
+ { StandardError raise: "error" } raises: StandardError with: @{ message is: "error" }
+ { ArgumentError raise: "error2" } raises: ArgumentError with: @{ message is: "error2" }
+ { IOError raise: "bar" } raises: IOError with: @{ message is: "bar" }
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.