summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser/scope.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/parser/scope.rb')
-rwxr-xr-xspec/unit/parser/scope.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/unit/parser/scope.rb b/spec/unit/parser/scope.rb
index ec8ab6d7d..fa76c4ff2 100755
--- a/spec/unit/parser/scope.rb
+++ b/spec/unit/parser/scope.rb
@@ -34,4 +34,54 @@ describe Puppet::Parser::Scope do
end
end
+
+ describe Puppet::Parser::Scope, "when calling number?" do
+
+ it "should return nil if called with anything not a number" do
+ Puppet::Parser::Scope.number?([2]).should be_nil
+ end
+
+ it "should return a Fixnum for a Fixnum" do
+ Puppet::Parser::Scope.number?(2).should be_an_instance_of(Fixnum)
+ end
+
+ it "should return a Float for a Float" do
+ Puppet::Parser::Scope.number?(2.34).should be_an_instance_of(Float)
+ end
+
+ it "should return 234 for '234'" do
+ Puppet::Parser::Scope.number?("234").should == 234
+ end
+
+ it "should return nil for 'not a number'" do
+ Puppet::Parser::Scope.number?("not a number").should be_nil
+ end
+
+ it "should return 23.4 for '23.4'" do
+ Puppet::Parser::Scope.number?("23.4").should == 23.4
+ end
+
+ it "should return 23.4e13 for '23.4e13'" do
+ Puppet::Parser::Scope.number?("23.4e13").should == 23.4e13
+ end
+
+ it "should understand negative numbers" do
+ Puppet::Parser::Scope.number?("-234").should == -234
+ end
+
+ it "should know how to convert exponential float numbers ala '23e13'" do
+ Puppet::Parser::Scope.number?("23e13").should == 23e13
+ end
+
+ it "should understand hexadecimal numbers" do
+ Puppet::Parser::Scope.number?("0x234").should == 0x234
+ end
+
+ it "should understand octal numbers" do
+ Puppet::Parser::Scope.number?("0755").should == 0755
+ end
+
+
+ end
+
end