File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -29,14 +29,14 @@ def self.valid? val
29
29
# Check that an argument is a positive number.
30
30
class Pos
31
31
def self . valid? val
32
- val > 0
32
+ val && val > 0
33
33
end
34
34
end
35
35
36
36
# Check that an argument is a negative number.
37
37
class Neg
38
38
def self . valid? val
39
- val < 0
39
+ val && val < 0
40
40
end
41
41
end
42
42
Original file line number Diff line number Diff line change 29
29
it "should fail for negative numbers" do
30
30
expect { @o . pos_test ( -1 ) } . to raise_error ( ContractError )
31
31
end
32
+
33
+ it "should fail for nil" do
34
+ expect { @o . pos_test ( nil ) } . to raise_error ( ContractError )
35
+ end
32
36
end
33
37
34
38
describe "Neg:" do
43
47
it "should fail for positive numbers" do
44
48
expect { @o . neg_test ( 1 ) } . to raise_error ( ContractError )
45
49
end
50
+
51
+ it "should fail for nil" do
52
+ expect { @o . neg_test ( nil ) } . to raise_error ( ContractError )
53
+ end
46
54
end
47
55
48
56
describe "Nat:" do
61
69
it "should fail for negative numbers" do
62
70
expect { @o . nat_test ( -1 ) } . to raise_error ( ContractError )
63
71
end
72
+
73
+ it "should fail for nil" do
74
+ expect { @o . nat_test ( nil ) } . to raise_error ( ContractError )
75
+ end
64
76
end
65
77
66
78
describe "Any:" do
You can’t perform that action at this time.
0 commit comments