~ubuntu-branches/ubuntu/wily/puppet/wily

« back to all changes in this revision

Viewing changes to spec/unit/pops/transformer/transform_calls_spec.rb

  • Committer: Package Import Robot
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2014-04-17 14:50:28 UTC
  • mfrom: (3.1.59 sid)
  • Revision ID: package-import@ubuntu.com-20140417145028-j3p3dwvp8ggpzvaf
Tags: 3.5.1-1
ImportedĀ upstreamĀ releaseĀ 3.5.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
        astdump(parse("foo()")).should == "(invoke foo)"
15
15
      end
16
16
 
17
 
      it "foo bar" do
18
 
        astdump(parse("foo bar")).should == "(invoke foo bar)"
 
17
      it "notice bar" do
 
18
        astdump(parse("notice bar")).should == "(invoke notice bar)"
19
19
      end
20
20
    end
21
21
 
24
24
        astdump(parse("if true {foo()}")).should == "(if true\n  (then (invoke foo)))"
25
25
      end
26
26
 
27
 
      it "if true { foo bar}" do
28
 
        astdump(parse("if true {foo bar}")).should == "(if true\n  (then (invoke foo bar)))"
29
 
      end
 
27
      it "if true { notice bar}" do
 
28
        astdump(parse("if true {notice bar}")).should == "(if true\n  (then (invoke notice bar)))"
 
29
      end
 
30
    end
 
31
    context "in general" do
 
32
      {
 
33
        "require bar"      => '(invoke require bar)',
 
34
        "realize bar"      => '(invoke realize bar)',
 
35
        "contain bar"      => '(invoke contain bar)',
 
36
        "include bar"      => '(invoke include bar)',
 
37
 
 
38
        "info bar"         => '(invoke info bar)',
 
39
        "notice bar"       => '(invoke notice bar)',
 
40
        "error bar"        => '(invoke error bar)',
 
41
        "warning bar"      => '(invoke warning bar)',
 
42
        "debug bar"        => '(invoke debug bar)',
 
43
 
 
44
        "fail bar"         => '(invoke fail bar)',
 
45
 
 
46
        "notice {a => 1}"  => "(invoke notice ({} ('a' 1)))",
 
47
        "notice 1,2,3"     => "(invoke notice 1 2 3)",
 
48
        "notice(1,2,3)"    => "(invoke notice 1 2 3)",
 
49
      }.each do |source, result|
 
50
        it "should transform #{source} to #{result}" do
 
51
          astdump(parse(source)).should == result
 
52
        end
 
53
      end
 
54
 
 
55
      {
 
56
        "foo bar"      => '(block foo bar)',
 
57
        "tag bar"      => '(block tag bar)',
 
58
        "tag"          => 'tag',
 
59
      }.each do |source, result|
 
60
        it "should not transform #{source}, and instead produce #{result}" do
 
61
          astdump(parse(source)).should == result
 
62
        end
 
63
      end
 
64
 
30
65
    end
31
66
  end
32
67
 
60
95
      astdump(parse("$a.foo")).should == "(call-method (. $a foo))"
61
96
    end
62
97
 
63
 
    it "$a.foo ||{ }" do
 
98
    it "$a.foo || { }" do
64
99
      astdump(parse("$a.foo || { }")).should == "(call-method (. $a foo) (lambda ()))"
65
100
    end
66
101
 
68
103
      astdump(parse("$a.foo || {[]}")).should == "(call-method (. $a foo) (lambda (block ([]))))"
69
104
    end
70
105
 
71
 
    it "$a.foo {|$x| }" do
 
106
    it "$a.foo |$x| { }" do
72
107
      astdump(parse("$a.foo |$x| { }")).should == "(call-method (. $a foo) (lambda (parameters x) ()))"
73
108
    end
74
109