farleyknight-ionize 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/README.rdoc +59 -0
  2. data/Rakefile +5 -0
  3. data/bin/ionize +47 -0
  4. data/lib/ionize.rb +75 -0
  5. data/lib/ionize/environment.rb +56 -0
  6. data/lib/ionize/environment/application.rb +58 -0
  7. data/lib/ionize/environment/php_array.rb +95 -0
  8. data/lib/ionize/parser.rb +272 -0
  9. data/lib/ionize/tokenizer.rb +544 -0
  10. data/lib/ionize/translate.rb +34 -0
  11. data/lib/ionize/translate/composite_string_statements.rb +79 -0
  12. data/lib/ionize/translate/debug.rb +16 -0
  13. data/lib/ionize/translate/ext.rb +47 -0
  14. data/lib/ionize/translate/function_args.rb +132 -0
  15. data/lib/ionize/translate/if_statements.rb +42 -0
  16. data/lib/ionize/translate/multiple_statements.rb +22 -0
  17. data/lib/ionize/translate/php_to_ruby.rb +40 -0
  18. data/lib/ionize/translate/rails_for_php.rb +191 -0
  19. data/lib/ionize/translate/rewritable.rb +133 -0
  20. data/lib/ionize/translate/rewrites.rb +51 -0
  21. data/lib/ionize/translate/statements.rb +622 -0
  22. data/lib/ionize/translate/switch_case_statements.rb +52 -0
  23. data/lib/ionize/translate/term_statements.rb +76 -0
  24. data/lib/ionize/translate/translator.rb +52 -0
  25. data/lib/ionize/version.rb +9 -0
  26. data/spec/fixtures/array_lookup.php +10 -0
  27. data/spec/fixtures/boolean_operators.php +5 -0
  28. data/spec/fixtures/boolean_operators.rb +6 -0
  29. data/spec/fixtures/class_def.php +34 -0
  30. data/spec/fixtures/class_def.rb +34 -0
  31. data/spec/fixtures/dangling_else.php +8 -0
  32. data/spec/fixtures/dangling_else.rb +12 -0
  33. data/spec/fixtures/drupal_1.php +663 -0
  34. data/spec/fixtures/drupal_2.php +1152 -0
  35. data/spec/fixtures/empty_string.php +12 -0
  36. data/spec/fixtures/for_loop.php +17 -0
  37. data/spec/fixtures/for_loop2.php +13 -0
  38. data/spec/fixtures/for_loop3.php +16 -0
  39. data/spec/fixtures/for_loop3.rb +17 -0
  40. data/spec/fixtures/for_loop4.php +5 -0
  41. data/spec/fixtures/for_loop4.rb +6 -0
  42. data/spec/fixtures/foreach.php +9 -0
  43. data/spec/fixtures/foreach2.php +8 -0
  44. data/spec/fixtures/foreach3.php +7 -0
  45. data/spec/fixtures/foreach3.rb +7 -0
  46. data/spec/fixtures/fun_def.php +9 -0
  47. data/spec/fixtures/fun_def2.php +30 -0
  48. data/spec/fixtures/fun_def2.rb +30 -0
  49. data/spec/fixtures/fun_def3.php +33 -0
  50. data/spec/fixtures/fun_def4.php +43 -0
  51. data/spec/fixtures/fun_def4.rb +37 -0
  52. data/spec/fixtures/fun_def5.php +36 -0
  53. data/spec/fixtures/fun_with_if.php +6 -0
  54. data/spec/fixtures/fun_with_if.rb +6 -0
  55. data/spec/fixtures/fun_with_ifs.php +12 -0
  56. data/spec/fixtures/fun_with_ifs.rb +14 -0
  57. data/spec/fixtures/hello_world.php +6 -0
  58. data/spec/fixtures/heredoc.php +6 -0
  59. data/spec/fixtures/heredoc.rb +5 -0
  60. data/spec/fixtures/if.php +6 -0
  61. data/spec/fixtures/if.rb +7 -0
  62. data/spec/fixtures/if_boolean.php +5 -0
  63. data/spec/fixtures/if_boolean.rb +5 -0
  64. data/spec/fixtures/if_else.php +11 -0
  65. data/spec/fixtures/if_else1.php +17 -0
  66. data/spec/fixtures/if_else2.php +8 -0
  67. data/spec/fixtures/if_else3.php +15 -0
  68. data/spec/fixtures/if_else_nested.php +14 -0
  69. data/spec/fixtures/if_else_nested.rb +15 -0
  70. data/spec/fixtures/if_else_series.php +12 -0
  71. data/spec/fixtures/if_else_series.rb +12 -0
  72. data/spec/fixtures/if_not.php +5 -0
  73. data/spec/fixtures/if_not.rb +5 -0
  74. data/spec/fixtures/if_with_brackets.php +7 -0
  75. data/spec/fixtures/if_with_brackets.rb +7 -0
  76. data/spec/fixtures/long_if_else.php +10 -0
  77. data/spec/fixtures/long_if_else.rb +9 -0
  78. data/spec/fixtures/oo.php +16 -0
  79. data/spec/fixtures/php_nuke/sql_layer.php +527 -0
  80. data/spec/fixtures/postop.php +3 -0
  81. data/spec/fixtures/preop.php +7 -0
  82. data/spec/fixtures/simple_fun_def.php +4 -0
  83. data/spec/fixtures/switch_case.php +13 -0
  84. data/spec/fixtures/switch_case.rb +14 -0
  85. data/spec/fixtures/switch_case2.php +25 -0
  86. data/spec/fixtures/switch_case3.php +40 -0
  87. data/spec/fixtures/switch_case3.rb +42 -0
  88. data/spec/fixtures/switch_case4.php +56 -0
  89. data/spec/fixtures/switch_case5.php +71 -0
  90. data/spec/fixtures/switch_case_with_rescue_nil.php +43 -0
  91. data/spec/fixtures/switch_case_with_rescue_nil.rb +35 -0
  92. data/spec/fixtures/tertiary.php +3 -0
  93. data/spec/helper.rb +17 -0
  94. data/spec/php_environment_spec.rb +83 -0
  95. data/spec/php_parser_spec.rb +121 -0
  96. data/spec/php_translator_spec.rb +358 -0
  97. data/spec/rails_for_php_spec.rb +303 -0
  98. metadata +191 -0
@@ -0,0 +1,121 @@
1
+
2
+ require 'spec'
3
+ require 'lib/ionize'
4
+
5
+ Ionize::Php::CharacterLimit = 50000
6
+
7
+ Kernel.module_eval { alias :running :lambda }
8
+
9
+ describe "Parsing Php" do
10
+ def parsing(text)
11
+ lambda { Ionize::Php.to_ast(text) }
12
+ end
13
+
14
+ def parsing_file(filename)
15
+ parsing(File.read(filename))
16
+ end
17
+
18
+ def parsing_fixture(filename)
19
+ parsing_file("spec/fixtures/#{filename}")
20
+ end
21
+
22
+ it "parses hello world as" do
23
+ parsing(%q{ print("Hello World!"); }).should_not raise_error
24
+ end
25
+
26
+ it "parses a variable right next to a keyword" do
27
+ parsing(%q{ print$buffer; }).should_not raise_error
28
+ end
29
+
30
+ it "parses a preop and an op in one line" do
31
+ parsing(%q{!update($module) + $a;}).should_not raise_error
32
+ end
33
+
34
+ it "parses a trailing comma in the function args" do
35
+ parsing(%q{ array('#value' => "stuff",); }).should_not raise_error
36
+ end
37
+
38
+ it "parses a keyword touching a string" do
39
+ parsing(%q{ echo"<table border=\"0\" width=\"100%\" cellspacing=\"1\"><tr>"; }).should_not raise_error
40
+ end
41
+
42
+ it "parses a postop" do
43
+ parsing("$i++;").should_not raise_error
44
+ end
45
+
46
+ it "parses a braced lookup" do
47
+ parsing(%q{ $email{$i}; }).should_not raise_error
48
+ end
49
+
50
+ it "parses a class method call" do
51
+ parsing(%q{ MyClass::call($variable); }).should_not raise_error
52
+ end
53
+
54
+ it "parses a reference to an expression" do
55
+ parsing(%q{ $obj =& new $classname; }).should_not raise_error
56
+ end
57
+
58
+ it "parses an empty if else" do
59
+ parsing(%q{ if (true); else echo "whatever"; }).should_not raise_error
60
+ end
61
+
62
+ it "parses a backslash right after a variable, within a composite string" do
63
+ parsing(%q{ require_once "./profiles/$profile/$profile.profile"; }).should_not raise_error
64
+ end
65
+
66
+ it "parses a variable with an array, within a string" do
67
+ parsing(%q{ $default_val = "$attributes[default]"; }).should_not raise_error
68
+ end
69
+
70
+ it "parses an echo statement with a one line if statement" do
71
+ parsing(%q{ if($sql_debug) echo "SQL query: "; }).should_not raise_error
72
+ end
73
+
74
+ it "parses multi oo expr" do
75
+ parsing(%q{ $this->installer->config->getRegistry(); }).should_not raise_error
76
+ end
77
+
78
+ it "parses a complicated string" do
79
+ parsing(%q{ echo "<!-- tinyMCE -->
80
+ <script language=\"javascript\" type=\"text/javascript\" src=\"includes/tiny_mce/tiny_mce.js\"></script>";}).should_not raise_error
81
+ end
82
+
83
+ it "parses a variable within an array lookup within a string" do
84
+ parsing(%q{ $row = $db->sql_fetchrow($db->sql_query("SELECT mid from " . $prefix . "_modules where title='$modlist[$i]'")); }).should_not raise_error
85
+ end
86
+
87
+ it "parses two array lookups within a string" do
88
+ parsing(%q{ $db->sql_query("insert into " . $prefix . "_modules values (NULL, '$modlist[$i]', '$modlist[$i]', '0', '0', '1', '0', '')"); }).should_not raise_error
89
+ end
90
+
91
+ Dir['spec/fixtures/*.php'].each do |fixture|
92
+ it "parses #{fixture}" do
93
+ parsing_file(fixture).should_not raise_error
94
+ end
95
+ end
96
+
97
+ it "parses PHP-NUKE's SQL Layer" do
98
+ parsing_fixture("php_nuke/sql_layer.php").should_not raise_error
99
+ end
100
+
101
+
102
+ it "parses a heredoc" do
103
+ code = %q{
104
+ $something =<<<EOF
105
+ okay
106
+ EOF;
107
+ }
108
+ parsing(code).should_not raise_error
109
+ end
110
+
111
+ it "parses an empty if else within an empty if else" do
112
+ parsing(%q{
113
+ if ($cond1);
114
+ else
115
+ if ($cond2);
116
+ else
117
+ $regs[1] = "";
118
+ }).should_not raise_error
119
+ end
120
+
121
+ end
@@ -0,0 +1,358 @@
1
+
2
+ require 'spec'
3
+ require 'lib/ionize'
4
+
5
+ describe "Transforms Php" do
6
+ # teh php codez
7
+ def php_ast(text)
8
+ Ionize::Php.to_sexp(text)
9
+ end
10
+
11
+ # teh ruby codez
12
+ def ruby_ast(text)
13
+ ParseTree.translate(text)
14
+ end
15
+
16
+ def php_file(filename)
17
+ php_ast(File.read(filename))
18
+ end
19
+
20
+ def ruby_file(filename)
21
+ ruby_ast(File.read(filename))
22
+ end
23
+
24
+ def php_file_matches_ruby_file(filename)
25
+ php_file("spec/fixtures/#{filename}.php").should ==
26
+ ruby_file("spec/fixtures/#{filename}.rb")
27
+ end
28
+
29
+ it "transforms hello world" do
30
+ php_ast(%q{ print "hello world"; }).should ==
31
+ ruby_ast(%q{ print "hello world" })
32
+ end
33
+
34
+ it "transforms an assignment statement" do
35
+ php_ast(%q{ $something = true; }).should ==
36
+ ruby_ast(%q{ something = true })
37
+ end
38
+
39
+ it "transforms a one-line if statement" do
40
+ php_ast(%q{ $something = true; if ($something) { print "hey"; } }).should ==
41
+ ruby_ast(%q{ something = true; if something; print "hey"; end })
42
+ end
43
+
44
+ it "transforms a tertiary statement" do
45
+ php_ast(%q{ $something = (TRUE == TRUE) ? TRUE : FALSE; }).should ==
46
+ ruby_ast(%q{ something = (true == true) ? true : false })
47
+ end
48
+
49
+ it "tranforms a cast" do
50
+ php_ast(%q{ (double)microtime() * 100; }).should ==
51
+ ruby_ast(%q{ microtime().to_double * 100 })
52
+ end
53
+
54
+ it "transforms a simple function definition" do
55
+ php_ast(%q{ function hey() { print "there"; } }).should ==
56
+ ruby_ast(%q{ def hey; print "there"; end })
57
+ end
58
+
59
+ it "transforms a global variable" do |node|
60
+ php_ast(%q{ global $something; }).should ==
61
+ ruby_ast(%q{ $something })
62
+ end
63
+
64
+ it "transforms two global variables" do |node|
65
+ php_ast(%q{ global $something, $another; }).should ==
66
+ ruby_ast(%q{ global $something, $another })
67
+ end
68
+
69
+ it "transforms an echo statement" do |node|
70
+ php_ast(%q{ echo "something"; }).should ==
71
+ ruby_ast(%q{ echo "something" })
72
+ end
73
+
74
+ it "transforms a new Object to an Object.new" do |node|
75
+ php_ast(%q{ $result_set = new ResultSet; }).should ==
76
+ ruby_ast(%q{ result_set = ResultSet.new })
77
+ end
78
+
79
+ it "transforms a slightly more complicated function" do
80
+ php_ast(%q{ function something($a, $b, $c) { return $a + $b + $c; } }).should ==
81
+ ruby_ast(%q{ def something(a, b, c); return a + b + c; end })
82
+ end
83
+
84
+ it "tranforms a function call" do
85
+ # We will need to create an 'array' method to simulate Php's top-level function
86
+ php_ast(%q{ $something = array(); }).should ==
87
+ ruby_ast(%q{ something = array() })
88
+ end
89
+
90
+ it "transforms a complicated function header" do
91
+ php_ast(%q{ function add_column(&$ret, $attributes = array()) { print 'something'; } }).should ==
92
+ ruby_ast(%q{ def add_column(ret, attributes = array()); print 'something'; end })
93
+ end
94
+
95
+ it "transforms an error guard into a rescue nil" do
96
+ php_ast(%q{ $id = 0; $other = @mysql_close($id); }).should ==
97
+ ruby_ast(%q{ id = 0; other = mysql_close(id) rescue nil })
98
+ end
99
+
100
+ it "transforms a require_once into just a require" do
101
+ php_ast(%q{ require_once "PEAR.php"; }).should ==
102
+ ruby_ast(%q{ require "PEAR.php" })
103
+ end
104
+
105
+ it "transforms an include_once into a load" do
106
+ php_ast(%q{ include_once "PEAR.php"; }).should ==
107
+ ruby_ast(%q{ load "PEAR.php" })
108
+ end
109
+
110
+ it "transforms an include into a load" do
111
+ php_ast(%q{ include "PEAR.php"; }).should ==
112
+ ruby_ast(%q{ load "PEAR.php" })
113
+ end
114
+
115
+ it "transforms a class inheritance" do
116
+ php_ast(%q{ class Something extends Another { var $foo; } }).should ==
117
+ ruby_ast(%q{ class Something < Another; attr_accessor :foo; end })
118
+ end
119
+
120
+ it "transforms a class variable default into an attr_access_with_default" do
121
+ php_ast(%q{ class Something { var $foo = "string"; } }).should ==
122
+ ruby_ast(%q{ class Something; attr_accessor(:foo, "string"); end })
123
+ end
124
+
125
+ it "transforms a braced lookup into a regular array-style lookup" do
126
+ php_ast(%q{ $var = "string"; $var{0}; }).should ==
127
+ ruby_ast(%q{ var = "string"; var[0]; })
128
+ end
129
+
130
+ it "transforms an object attribute array assignment" do
131
+ php_ast(%q{ $method = 3; $classname = "Object"; $var = thing(); $var->attr[$method] = $classname; }).should ==
132
+ ruby_ast(%q{ method = 3; classname = "Object"; var = thing(); var.attr[method] = classname })
133
+ end
134
+
135
+
136
+ it "transforms an object dynamic variable assignment" do
137
+ # In php, you can do this:
138
+ #
139
+ # $var = "foo";
140
+ # $obj->$var = "bar";
141
+ #
142
+ # and this
143
+ #
144
+ # $obj->foo == "bar"
145
+ #
146
+ # would be true
147
+ #
148
+ #
149
+
150
+ php_ast(%q{ $var = "foo"; $obj = new Object; $obj->$var = "something"; }).should ==
151
+ ruby_ast(%q{ var = "foo"; obj = Object.new; obj.set(var, "something") })
152
+ end
153
+
154
+ it "transforms an object dynamic variable retrieve" do
155
+ php_ast(%q{ $var = "foo"; $obj = new Object; $obj->$var; }).should ==
156
+ ruby_ast(%q{ var = "foo"; obj = Object.new; obj.get(var) })
157
+ end
158
+
159
+ it "transforms an array lookup on an object" do
160
+ php_ast(%q{ $user = new User; $user->data['user_id']; }).should ==
161
+ ruby_ast(%q{ user = User.new; user.data["user_id"] })
162
+ end
163
+
164
+ it "transforms a while loop" do
165
+ php_ast(%q{ while (TRUE) { print "hahaha!1!"; } }).should ==
166
+ ruby_ast(%q{ while true; print "hahaha!1!"; end })
167
+ end
168
+
169
+ it "transforms an empty fun call" do
170
+ php_ast(%q{ something(); }).should ==
171
+ ruby_ast(%q{ something() })
172
+ end
173
+
174
+ it "tranforms an attribute assignment" do
175
+ php_ast(%q{ $a = array(); $a[1] = 2; }).should ==
176
+ ruby_ast(%q{ a = array(); a[1] = 2 })
177
+ end
178
+
179
+ it "transforms an oo assignment" do
180
+ php_ast(%q{ $some = yup(); $some->thing = "other"; }).should ==
181
+ ruby_ast(%q{ some = yup(); some.thing = "other" })
182
+ end
183
+
184
+ it "transforms a multiple oo function call" do
185
+ php_ast(%q{ $obj = new Object(); $obj->installer->something(1); }).should ==
186
+ ruby_ast(%q{ obj = Object.new; obj.installer.something(1) })
187
+ end
188
+
189
+ it "transforms a multiple oo attribute" do
190
+ php_ast(%q{ $obj = new Object(); $obj->installer->something->config; }).should ==
191
+ ruby_ast(%q{ obj = Object.new; obj.installer.something.config })
192
+ end
193
+
194
+ it "transforms a return" do
195
+ php_ast(%q{ return $this->result; }).should ==
196
+ ruby_ast(%q{ return self.result })
197
+ end
198
+
199
+ it "tranforms Php's destructuring bind" do
200
+ php_ast(%q{ list($hey, $whats, $up) = array("hey", "whats", "up"); }).should ==
201
+ ruby_ast(%q{ hey, whats, up = *array("hey", "whats", "up") })
202
+ end
203
+
204
+ it "transforms string concatenation" do
205
+ php_ast(%q{ $check = "test"; $check .= "test"; }).should ==
206
+ ruby_ast(%q{ check = "test"; check << "test" })
207
+ end
208
+
209
+ it "transforms Php's string concat to Ruby's string concat" do
210
+ php_ast(%q{$column = "something"; $type = "something"; $table = "something"; "ALTER TABLE {". $table . "} ADD $column $type";}).should ==
211
+ ruby_ast(%q{column = "something"; type = "something"; table = "something"; "ALTER TABLE {" + table + "} ADD #{column} #{type}"})
212
+ end
213
+
214
+ it "tranforms an array access within a string" do
215
+ php_ast(%q{ $something = array(); print "Things inside $something[okay]"; }).should ==
216
+ ruby_ast(%q{ something = array(); print "Things inside #{something['okay']}" })
217
+ end
218
+
219
+ it "transforms ++ into += 1" do
220
+ php_ast(%q{ $i++; }).should == ruby_ast(%q{ i += 1 })
221
+ end
222
+
223
+ it "transforms an array append" do
224
+ php_ast(%q{ $something = array(); $something[] = "other"; }).should ==
225
+ ruby_ast(%q{ something = array(); something << "other" })
226
+ end
227
+
228
+ it "transforms array lookup" do
229
+ php_ast(%q{ $attributes = array(); $attributes['default']; }).should ==
230
+ ruby_ast(%q{ attributes = array(); attributes['default'] })
231
+ end
232
+
233
+ it "transforms threequals" do
234
+ php_ast(%q{ $attributes = array(); $attributes['default'] === FALSE; }).should ==
235
+ ruby_ast(%q{ attributes = array(); attributes['default'] === false; })
236
+ end
237
+
238
+ it "transforms multiple args in the actual parameters" do
239
+ php_ast(%q{ $attributes = array(); array_key_exists('not null', $attributes); }).should ==
240
+ ruby_ast(%q{ attributes = array(); array_key_exists('not null', attributes) })
241
+ end
242
+
243
+ it "tranforms an array with hashed values" do
244
+ php_ast(%q{ array("something" => "er other", "with" => array("nested" => "values")); }).should ==
245
+ ruby_ast(%q{ array("something" => "er other", "with" => array("nested" => "values")) })
246
+ end
247
+
248
+ it "transforms an entire function" do
249
+ php_ast(%q{ function db_add_column(&$ret, $table, $column, $type, $attributes = array()) { print 'something'; } }).should ==
250
+ ruby_ast(%q{ def db_add_column(ret, table, column, type, attributes = array()); print 'something'; end })
251
+ end
252
+
253
+ it "transforms a class method call" do
254
+ php_ast(%q{ MyClass::foo(1, 'bar', 'baz'); }).should ==
255
+ ruby_ast(%Q{ MyClass.foo(1, 'bar', 'baz') })
256
+ end
257
+
258
+ it "transforms a variable class name to a const_get" do
259
+ php_ast(%q{ $classname = "Foo"; obj =& new $classname; }).should ==
260
+ ruby_ast(%q{ classname = "Foo"; obj = Object.const_get(classname).new })
261
+ end
262
+
263
+ it "transforms an if statement" do
264
+ php_file_matches_ruby_file("if")
265
+ end
266
+
267
+ it "transforms a class definition" do
268
+ php_file_matches_ruby_file("class_def")
269
+ end
270
+
271
+
272
+ it "transforms a function with an if statement" do
273
+ php_file_matches_ruby_file("fun_with_if")
274
+ end
275
+
276
+ it "transforms a foreach to an each loop" do
277
+ php_file_matches_ruby_file("foreach3")
278
+ end
279
+
280
+ it "transforms an even more complicated function" do
281
+ php_file_matches_ruby_file("fun_def2")
282
+ end
283
+
284
+ it "transforms a yet even more complicated function" do
285
+ php_file_matches_ruby_file("fun_def4")
286
+ end
287
+
288
+ it "unrolls a for loop into a while loop with setup and update operations" do
289
+ php_file_matches_ruby_file("for_loop4")
290
+ end
291
+
292
+ it "transforms another for loop" do
293
+ php_file_matches_ruby_file("for_loop3")
294
+ end
295
+
296
+ it "transforms a switch case" do
297
+ php_file_matches_ruby_file("switch_case3")
298
+ end
299
+
300
+ it "transforms a heredoc" do
301
+ php_file_matches_ruby_file("heredoc")
302
+ end
303
+
304
+ it "transforms a switch case within a function definition" do
305
+ php_file_matches_ruby_file("switch_case_with_rescue_nil")
306
+ end
307
+
308
+ it "transforms a switch-case" do
309
+ php_file_matches_ruby_file("switch_case")
310
+ end
311
+
312
+ it "transforms an if statement with brackets" do
313
+ php_file_matches_ruby_file("if_with_brackets")
314
+ end
315
+
316
+ it "transforms a dangling else" do
317
+ # http://en.wikipedia.org/wiki/Dangling_else
318
+ php_file_matches_ruby_file("dangling_else")
319
+ end
320
+
321
+ it "transforms a series of else if's" do
322
+ php_file_matches_ruby_file("if_else_series")
323
+ end
324
+
325
+ it "transforms boolean operators, and, not, and or" do
326
+ # The associativity on boolean operators is not being done
327
+ # correctly. Look into this again at some point
328
+ php_file_matches_ruby_file("boolean_operators")
329
+ end
330
+
331
+ it "transforms an if (not something) into if (something) nil.. " do
332
+ php_file_matches_ruby_file("if_not")
333
+ end
334
+
335
+ it "transforms an if statement with a boolean condition" do
336
+ php_file_matches_ruby_file("if_boolean")
337
+ end
338
+
339
+ it "transforms an if else nested within an if" do
340
+ php_file_matches_ruby_file("if_else_nested")
341
+ end
342
+
343
+ it "transforms another function with 3 if statements" do
344
+ php_file_matches_ruby_file("fun_with_ifs")
345
+ end
346
+
347
+ it "transforms a longer if-else" do
348
+ php_file_matches_ruby_file("long_if_else")
349
+ end
350
+
351
+ it "transforms a function definition without error" do
352
+ lambda do
353
+ php_file("spec/fixtures/fun_def4.php")
354
+ end.should_not raise_error
355
+ end
356
+
357
+ end
358
+