Skip to content
Browse files

Spec Fixnum#{even,odd}?

  • Loading branch information...
1 parent 46dae28 commit e59d7a579d304c0ef7be9e3e914327a9f0f6b58b @jfirebaugh jfirebaugh committed Feb 21, 2012
Showing with 38 additions and 2 deletions.
  1. +19 −1 spec/ruby/core/fixnum/even_spec.rb
  2. +19 −1 spec/ruby/core/fixnum/odd_spec.rb
View
20 spec/ruby/core/fixnum/even_spec.rb
@@ -2,6 +2,24 @@
ruby_version_is "1.9" do
describe "Fixnum#even?" do
- it "needs to be reviewed for spec completeness"
+ it "is true for zero" do
+ 0.even?.should be_true
+ end
+
+ it "is true for even positive Fixnums" do
+ 4.even?.should be_true
+ end
+
+ it "is true for even negative Fixnums" do
+ (-4).even?.should be_true
+ end
+
+ it "is false for odd positive Fixnums" do
+ 5.even?.should be_false
+ end
+
+ it "is false for odd negative Fixnums" do
+ (-5).even?.should be_false
+ end
end
end
View
20 spec/ruby/core/fixnum/odd_spec.rb
@@ -2,6 +2,24 @@
ruby_version_is "1.9" do
describe "Fixnum#odd?" do
- it "needs to be reviewed for spec completeness"
+ it "is false for zero" do
+ 0.odd?.should be_false
+ end
+
+ it "is false for even positive Fixnums" do
+ 4.odd?.should be_false
+ end
+
+ it "is false for even negative Fixnums" do
+ (-4).odd?.should be_false
+ end
+
+ it "is true for odd positive Fixnums" do
+ 5.odd?.should be_true
+ end
+
+ it "is true for odd negative Fixnums" do
+ (-5).odd?.should be_true
+ end
end
end

0 comments on commit e59d7a5

Please sign in to comment.
Something went wrong with that request. Please try again.