annotate modules/stdlib/spec/functions/is_float_spec.rb @ 37:addb0ea390a1 puppet-3.6

Update Puppet "stdlib" module
author IBBoard <dev@ibboard.co.uk>
date Sat, 14 Mar 2015 20:09:45 +0000
parents
children c42fb28cff86
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
37
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 #! /usr/bin/env ruby -S rspec
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 require 'spec_helper'
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 describe "the is_float function" do
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 it "should exist" do
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 expect(Puppet::Parser::Functions.function("is_float")).to eq("function_is_float")
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 end
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 it "should raise a ParseError if there is less than 1 arguments" do
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 expect { scope.function_is_float([]) }.to( raise_error(Puppet::ParseError))
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 end
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 it "should return true if a float" do
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 result = scope.function_is_float(["0.12"])
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 expect(result).to(eq(true))
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 end
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 it "should return false if a string" do
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 result = scope.function_is_float(["asdf"])
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 expect(result).to(eq(false))
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 end
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 it "should return false if an integer" do
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 result = scope.function_is_float(["3"])
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 expect(result).to(eq(false))
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 end
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 it "should return true if a float is created from an arithmetical operation" do
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 result = scope.function_is_float([3.2*2])
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 expect(result).to(eq(true))
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 end
addb0ea390a1 Update Puppet "stdlib" module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 end