|
8 | 8 | Puppet::Parser::Functions.function("num2bool").should == "function_num2bool" |
9 | 9 | end |
10 | 10 |
|
11 | | - it "should raise a ParseError if there is less than 1 arguments" do |
| 11 | + it "should raise a ParseError if there are no arguments" do |
12 | 12 | lambda { scope.function_num2bool([]) }.should( raise_error(Puppet::ParseError)) |
13 | 13 | end |
14 | 14 |
|
15 | | - it "should return true if 1" do |
| 15 | + it "should raise a ParseError if there are more than 1 arguments" do |
| 16 | + lambda { scope.function_num2bool(["foo","bar"]) }.should( raise_error(Puppet::ParseError)) |
| 17 | + end |
| 18 | + |
| 19 | + it "should raise a ParseError if passed something non-numeric" do |
| 20 | + lambda { scope.function_num2bool(["xyzzy"]) }.should( raise_error(Puppet::ParseError)) |
| 21 | + end |
| 22 | + |
| 23 | + it "should return true if passed string 1" do |
16 | 24 | result = scope.function_num2bool(["1"]) |
17 | 25 | result.should(be_true) |
18 | 26 | end |
19 | 27 |
|
20 | | - it "should return false if 0" do |
| 28 | + it "should return true if passed string 1.5" do |
| 29 | + result = scope.function_num2bool(["1.5"]) |
| 30 | + result.should(be_true) |
| 31 | + end |
| 32 | + |
| 33 | + it "should return true if passed number 1" do |
| 34 | + result = scope.function_num2bool([1]) |
| 35 | + result.should(be_true) |
| 36 | + end |
| 37 | + |
| 38 | + it "should return false if passed string 0" do |
21 | 39 | result = scope.function_num2bool(["0"]) |
22 | 40 | result.should(be_false) |
23 | 41 | end |
| 42 | + |
| 43 | + it "should return false if passed number 0" do |
| 44 | + result = scope.function_num2bool([0]) |
| 45 | + result.should(be_false) |
| 46 | + end |
| 47 | + |
| 48 | + it "should return false if passed string -1" do |
| 49 | + result = scope.function_num2bool(["-1"]) |
| 50 | + result.should(be_false) |
| 51 | + end |
| 52 | + |
| 53 | + it "should return false if passed string -1.5" do |
| 54 | + result = scope.function_num2bool(["-1.5"]) |
| 55 | + result.should(be_false) |
| 56 | + end |
| 57 | + |
| 58 | + it "should return false if passed number -1" do |
| 59 | + result = scope.function_num2bool([-1]) |
| 60 | + result.should(be_false) |
| 61 | + end |
| 62 | + |
| 63 | + it "should return false if passed float -1.5" do |
| 64 | + result = scope.function_num2bool([-1.5]) |
| 65 | + result.should(be_false) |
| 66 | + end |
24 | 67 | end |
0 commit comments