From 190b9438c58eab2322bdf216be1aaae109d14072 Mon Sep 17 00:00:00 2001 From: stephen Date: Thu, 3 Jan 2013 13:53:03 +0000 Subject: Add test/validation for is_numeric if created from an arithmetical operation --- spec/unit/puppet/parser/functions/is_numeric_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'spec/unit/puppet/parser') diff --git a/spec/unit/puppet/parser/functions/is_numeric_spec.rb b/spec/unit/puppet/parser/functions/is_numeric_spec.rb index 4078b37..d7440fb 100644 --- a/spec/unit/puppet/parser/functions/is_numeric_spec.rb +++ b/spec/unit/puppet/parser/functions/is_numeric_spec.rb @@ -22,6 +22,16 @@ describe "the is_numeric function" do result.should(eq(true)) end + it "should return true if an integer is created from an arithmetical operation" do + result = scope.function_is_numeric([3*2]) + result.should(eq(true)) + end + + it "should return true if a float is created from an arithmetical operation" do + result = scope.function_is_numeric([3.2*2]) + result.should(eq(true)) + end + it "should return false if a string" do result = scope.function_is_numeric(["asdf"]) result.should(eq(false)) -- cgit v1.2.3 From b86f5dc1293ad431581afbb8f294560f3cf34d43 Mon Sep 17 00:00:00 2001 From: stephen Date: Thu, 3 Jan 2013 14:02:58 +0000 Subject: Add test/validation for is_integer if created from an arithmetical operation --- lib/puppet/parser/functions/is_integer.rb | 2 +- spec/unit/puppet/parser/functions/is_integer_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'spec/unit/puppet/parser') diff --git a/lib/puppet/parser/functions/is_integer.rb b/lib/puppet/parser/functions/is_integer.rb index 8ee34f6..6b29e98 100644 --- a/lib/puppet/parser/functions/is_integer.rb +++ b/lib/puppet/parser/functions/is_integer.rb @@ -15,7 +15,7 @@ Returns true if the variable returned to this string is an integer. value = arguments[0] - if value != value.to_i.to_s then + if value != value.to_i.to_s and !value.is_a? Fixnum then return false else return true diff --git a/spec/unit/puppet/parser/functions/is_integer_spec.rb b/spec/unit/puppet/parser/functions/is_integer_spec.rb index 5afbba4..4335795 100644 --- a/spec/unit/puppet/parser/functions/is_integer_spec.rb +++ b/spec/unit/puppet/parser/functions/is_integer_spec.rb @@ -26,4 +26,9 @@ describe "the is_integer function" do result = scope.function_is_integer(["asdf"]) result.should(eq(false)) end + + it "should return true if an integer is created from an arithmetical operation" do + result = scope.function_is_integer([3*2]) + result.should(eq(true)) + end end -- cgit v1.2.3 From a773281760469f2b104c89b2bfb760c0e3013422 Mon Sep 17 00:00:00 2001 From: stephen Date: Thu, 3 Jan 2013 14:05:29 +0000 Subject: Add test/validation for is_float if created from an arithmetical operation --- lib/puppet/parser/functions/is_float.rb | 2 +- spec/unit/puppet/parser/functions/is_float_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'spec/unit/puppet/parser') diff --git a/lib/puppet/parser/functions/is_float.rb b/lib/puppet/parser/functions/is_float.rb index 2fc05ba..911f3c2 100644 --- a/lib/puppet/parser/functions/is_float.rb +++ b/lib/puppet/parser/functions/is_float.rb @@ -15,7 +15,7 @@ Returns true if the variable passed to this function is a float. value = arguments[0] - if value != value.to_f.to_s then + if value != value.to_f.to_s and !value.is_a? Float then return false else return true diff --git a/spec/unit/puppet/parser/functions/is_float_spec.rb b/spec/unit/puppet/parser/functions/is_float_spec.rb index 2f527d9..b7d73b0 100644 --- a/spec/unit/puppet/parser/functions/is_float_spec.rb +++ b/spec/unit/puppet/parser/functions/is_float_spec.rb @@ -26,4 +26,8 @@ describe "the is_float function" do result = scope.function_is_float(["3"]) result.should(eq(false)) end + it "should return true if a float is created from an arithmetical operation" do + result = scope.function_is_float([3.2*2]) + result.should(eq(true)) + end end -- cgit v1.2.3