diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-04-26 11:06:53 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-04-26 11:06:53 +0900 |
| commit | b1b3ee4547ec1cda4157ea92af85942f3384c101 (patch) | |
| tree | 2c30b4b5e5b16d91942dc4115da6aa86e3065687 | |
| parent | 0584551eb971f4f78820d3038cf8e7ba62a59374 (diff) | |
| download | mruby-b1b3ee4547ec1cda4157ea92af85942f3384c101.tar.gz mruby-b1b3ee4547ec1cda4157ea92af85942f3384c101.zip | |
revert 3644f1b temporary since it caused SEGV only on Travis-CI
| -rw-r--r-- | mrblib/compar.rb | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/mrblib/compar.rb b/mrblib/compar.rb index 84b962598..44595974a 100644 --- a/mrblib/compar.rb +++ b/mrblib/compar.rb @@ -14,8 +14,11 @@ module Comparable cmp = self <=> other if cmp.nil? raise ArgumentError, "comparison of #{self.class} with #{other.class} failed" + elsif cmp < 0 + true + else + false end - cmp < 0 end ## @@ -28,8 +31,11 @@ module Comparable cmp = self <=> other if cmp.nil? raise ArgumentError, "comparison of #{self.class} with #{other.class} failed" + elsif cmp <= 0 + true + else + false end - cmp <= 0 end ## @@ -40,7 +46,11 @@ module Comparable # ISO 15.3.3.2.3 def == other cmp = self <=> other - cmp == 0 + if cmp == 0 + true + else + false + end end ## @@ -53,8 +63,11 @@ module Comparable cmp = self <=> other if cmp.nil? raise ArgumentError, "comparison of #{self.class} with #{other.class} failed" + elsif cmp > 0 + true + else + false end - cmp > 0 end ## @@ -67,8 +80,11 @@ module Comparable cmp = self <=> other if cmp.nil? raise ArgumentError, "comparison of #{self.class} with #{other.class} failed" + elsif cmp >= 0 + true + else + false end - cmp >= 0 end ## @@ -79,6 +95,10 @@ module Comparable # # ISO 15.3.3.2.6 def between?(min, max) - self >= min and self <= max + if self < min or self > max + false + else + true + end end end |
