laser 0.7.0.pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +14 -0
  4. data/LICENSE +661 -0
  5. data/README.md +158 -0
  6. data/Rakefile +104 -0
  7. data/VERSION +1 -0
  8. data/bin/laser +7 -0
  9. data/design_docs/goals.md +57 -0
  10. data/design_docs/object_regex.md +426 -0
  11. data/design_docs/type_annotations.md +80 -0
  12. data/ext/laser/BasicBlock.cpp +572 -0
  13. data/ext/laser/BasicBlock.h +118 -0
  14. data/ext/laser/extconf.rb +3 -0
  15. data/features/laser.feature +25 -0
  16. data/features/step_definitions/laser_steps.rb +39 -0
  17. data/features/support/env.rb +14 -0
  18. data/features/support/testdata/1_input +1 -0
  19. data/features/support/testdata/1_output +1 -0
  20. data/features/support/testdata/2_input +4 -0
  21. data/features/support/testdata/2_output +4 -0
  22. data/features/support/testdata/3_input +8 -0
  23. data/features/support/testdata/3_output +11 -0
  24. data/features/support/testdata/4_input +5 -0
  25. data/features/support/testdata/4_output +5 -0
  26. data/features/support/testdata/5_input +13 -0
  27. data/laser.gemspec +382 -0
  28. data/lib/laser.rb +98 -0
  29. data/lib/laser/analysis/annotations.rb +95 -0
  30. data/lib/laser/analysis/annotations/annotation_config.yaml +3 -0
  31. data/lib/laser/analysis/annotations/comment_attachment_annotation.rb +66 -0
  32. data/lib/laser/analysis/annotations/node_pointers_annotation.rb +36 -0
  33. data/lib/laser/analysis/annotations/runtime_annotation.rb +55 -0
  34. data/lib/laser/analysis/argument_expansion.rb +132 -0
  35. data/lib/laser/analysis/arity.rb +34 -0
  36. data/lib/laser/analysis/bindings.rb +144 -0
  37. data/lib/laser/analysis/bootstrap/bootstrap.rb +298 -0
  38. data/lib/laser/analysis/bootstrap/laser_class.rb +106 -0
  39. data/lib/laser/analysis/bootstrap/laser_method.rb +255 -0
  40. data/lib/laser/analysis/bootstrap/laser_module.rb +403 -0
  41. data/lib/laser/analysis/bootstrap/laser_module_copy.rb +74 -0
  42. data/lib/laser/analysis/bootstrap/laser_object.rb +69 -0
  43. data/lib/laser/analysis/bootstrap/laser_proc.rb +150 -0
  44. data/lib/laser/analysis/bootstrap/laser_singleton_class.rb +44 -0
  45. data/lib/laser/analysis/comments.rb +35 -0
  46. data/lib/laser/analysis/control_flow.rb +28 -0
  47. data/lib/laser/analysis/control_flow/alias_analysis.rb +31 -0
  48. data/lib/laser/analysis/control_flow/basic_block.rb +105 -0
  49. data/lib/laser/analysis/control_flow/cfg_builder.rb +2505 -0
  50. data/lib/laser/analysis/control_flow/cfg_instruction.rb +190 -0
  51. data/lib/laser/analysis/control_flow/constant_propagation.rb +742 -0
  52. data/lib/laser/analysis/control_flow/control_flow_graph.rb +370 -0
  53. data/lib/laser/analysis/control_flow/lifetime_analysis.rb +91 -0
  54. data/lib/laser/analysis/control_flow/method_call_search.rb +26 -0
  55. data/lib/laser/analysis/control_flow/raise_properties.rb +25 -0
  56. data/lib/laser/analysis/control_flow/simulation.rb +385 -0
  57. data/lib/laser/analysis/control_flow/static_single_assignment.rb +185 -0
  58. data/lib/laser/analysis/control_flow/unreachability_analysis.rb +57 -0
  59. data/lib/laser/analysis/control_flow/unused_variables.rb +91 -0
  60. data/lib/laser/analysis/control_flow/yield_properties.rb +103 -0
  61. data/lib/laser/analysis/errors.rb +131 -0
  62. data/lib/laser/analysis/laser_utils.rb +18 -0
  63. data/lib/laser/analysis/lexical_analysis.rb +172 -0
  64. data/lib/laser/analysis/method_call.rb +68 -0
  65. data/lib/laser/analysis/protocol_registry.rb +30 -0
  66. data/lib/laser/analysis/scope.rb +118 -0
  67. data/lib/laser/analysis/sexp.rb +159 -0
  68. data/lib/laser/analysis/sexp_analysis.rb +40 -0
  69. data/lib/laser/analysis/sexp_extensions/constant_extraction.rb +115 -0
  70. data/lib/laser/analysis/sexp_extensions/source_location.rb +164 -0
  71. data/lib/laser/analysis/sexp_extensions/type_inference.rb +47 -0
  72. data/lib/laser/analysis/signature.rb +76 -0
  73. data/lib/laser/analysis/special_methods/send.rb +67 -0
  74. data/lib/laser/analysis/unused_methods.rb +21 -0
  75. data/lib/laser/analysis/visitor.rb +141 -0
  76. data/lib/laser/annotation_parser/annotations.treetop +126 -0
  77. data/lib/laser/annotation_parser/annotations_parser.rb +748 -0
  78. data/lib/laser/annotation_parser/class_annotations.treetop +82 -0
  79. data/lib/laser/annotation_parser/class_annotations_parser.rb +654 -0
  80. data/lib/laser/annotation_parser/overload.treetop +24 -0
  81. data/lib/laser/annotation_parser/overload_parser.rb +167 -0
  82. data/lib/laser/annotation_parser/parsers.rb +6 -0
  83. data/lib/laser/annotation_parser/structural.treetop +37 -0
  84. data/lib/laser/annotation_parser/structural_parser.rb +406 -0
  85. data/lib/laser/annotation_parser/useful_parsers.treetop +47 -0
  86. data/lib/laser/annotation_parser/useful_parsers_parser.rb +674 -0
  87. data/lib/laser/rake/task.rb +46 -0
  88. data/lib/laser/runner.rb +189 -0
  89. data/lib/laser/scanner.rb +169 -0
  90. data/lib/laser/standard_library/_thread.rb +110 -0
  91. data/lib/laser/standard_library/abbrev.rb +103 -0
  92. data/lib/laser/standard_library/array.rb +418 -0
  93. data/lib/laser/standard_library/base64.rb +91 -0
  94. data/lib/laser/standard_library/basic_object.rb +55 -0
  95. data/lib/laser/standard_library/benchmark.rb +556 -0
  96. data/lib/laser/standard_library/bignum.rb +185 -0
  97. data/lib/laser/standard_library/cgi.rb +275 -0
  98. data/lib/laser/standard_library/cgi/cookie.rb +147 -0
  99. data/lib/laser/standard_library/cgi/core.rb +791 -0
  100. data/lib/laser/standard_library/cgi/html.rb +1021 -0
  101. data/lib/laser/standard_library/cgi/session.rb +537 -0
  102. data/lib/laser/standard_library/cgi/session/pstore.rb +111 -0
  103. data/lib/laser/standard_library/cgi/util.rb +188 -0
  104. data/lib/laser/standard_library/class_definitions.rb +333 -0
  105. data/lib/laser/standard_library/comparable.rb +125 -0
  106. data/lib/laser/standard_library/complex.rb +162 -0
  107. data/lib/laser/standard_library/enumerable.rb +178 -0
  108. data/lib/laser/standard_library/exceptions.rb +135 -0
  109. data/lib/laser/standard_library/fixnum.rb +188 -0
  110. data/lib/laser/standard_library/float.rb +180 -0
  111. data/lib/laser/standard_library/hash.rb +237 -0
  112. data/lib/laser/standard_library/integer.rb +123 -0
  113. data/lib/laser/standard_library/laser_magic.rb +7 -0
  114. data/lib/laser/standard_library/nil_false_true.rb +113 -0
  115. data/lib/laser/standard_library/numbers.rb +192 -0
  116. data/lib/laser/standard_library/proc.rb +31 -0
  117. data/lib/laser/standard_library/set.rb +1348 -0
  118. data/lib/laser/standard_library/string.rb +666 -0
  119. data/lib/laser/standard_library/stringio.rb +2 -0
  120. data/lib/laser/standard_library/symbol.rb +125 -0
  121. data/lib/laser/standard_library/tsort.rb +242 -0
  122. data/lib/laser/support/acts_as_struct.rb +66 -0
  123. data/lib/laser/support/frequency.rb +55 -0
  124. data/lib/laser/support/inheritable_attributes.rb +145 -0
  125. data/lib/laser/support/module_extensions.rb +94 -0
  126. data/lib/laser/support/placeholder_object.rb +13 -0
  127. data/lib/laser/third_party/rgl/adjacency.rb +221 -0
  128. data/lib/laser/third_party/rgl/base.rb +228 -0
  129. data/lib/laser/third_party/rgl/bidirectional.rb +39 -0
  130. data/lib/laser/third_party/rgl/condensation.rb +47 -0
  131. data/lib/laser/third_party/rgl/connected_components.rb +138 -0
  132. data/lib/laser/third_party/rgl/control_flow.rb +170 -0
  133. data/lib/laser/third_party/rgl/depth_first_spanning_tree.rb +37 -0
  134. data/lib/laser/third_party/rgl/dominators.rb +124 -0
  135. data/lib/laser/third_party/rgl/dot.rb +93 -0
  136. data/lib/laser/third_party/rgl/graphxml.rb +51 -0
  137. data/lib/laser/third_party/rgl/implicit.rb +174 -0
  138. data/lib/laser/third_party/rgl/mutable.rb +117 -0
  139. data/lib/laser/third_party/rgl/rdot.rb +445 -0
  140. data/lib/laser/third_party/rgl/topsort.rb +72 -0
  141. data/lib/laser/third_party/rgl/transitivity.rb +180 -0
  142. data/lib/laser/third_party/rgl/traversal.rb +348 -0
  143. data/lib/laser/types/types.rb +433 -0
  144. data/lib/laser/version.rb +14 -0
  145. data/lib/laser/warning.rb +149 -0
  146. data/lib/laser/warning_sets/default.yml +13 -0
  147. data/lib/laser/warnings/assignment_in_condition.rb +20 -0
  148. data/lib/laser/warnings/comment_spacing.rb +31 -0
  149. data/lib/laser/warnings/extra_blank_lines.rb +30 -0
  150. data/lib/laser/warnings/extra_whitespace.rb +16 -0
  151. data/lib/laser/warnings/hash_symbol_18_warning.rb +63 -0
  152. data/lib/laser/warnings/hash_symbol_19_warning.rb +29 -0
  153. data/lib/laser/warnings/line_length.rb +115 -0
  154. data/lib/laser/warnings/misaligned_unindentation.rb +17 -0
  155. data/lib/laser/warnings/operator_spacing.rb +68 -0
  156. data/lib/laser/warnings/parens_on_declaration.rb +30 -0
  157. data/lib/laser/warnings/rescue_exception.rb +42 -0
  158. data/lib/laser/warnings/semicolon.rb +25 -0
  159. data/lib/laser/warnings/sexp_errors.rb +24 -0
  160. data/lib/laser/warnings/uncalled_method_warning.rb +7 -0
  161. data/lib/laser/warnings/useless_double_quotes.rb +38 -0
  162. data/spec/analysis_specs/annotations_spec.rb +47 -0
  163. data/spec/analysis_specs/annotations_specs/comment_attachment_spec.rb +68 -0
  164. data/spec/analysis_specs/annotations_specs/node_pointers_annotation_spec.rb +90 -0
  165. data/spec/analysis_specs/annotations_specs/runtime_annotation_spec.rb +135 -0
  166. data/spec/analysis_specs/annotations_specs/spec_helper.rb +33 -0
  167. data/spec/analysis_specs/argument_expansion_spec.rb +113 -0
  168. data/spec/analysis_specs/bindings_spec.rb +36 -0
  169. data/spec/analysis_specs/comment_spec.rb +93 -0
  170. data/spec/analysis_specs/control_flow_specs/cfg_instruction_spec.rb +111 -0
  171. data/spec/analysis_specs/control_flow_specs/constant_propagation_spec.rb +560 -0
  172. data/spec/analysis_specs/control_flow_specs/control_flow_graph_spec.rb +5 -0
  173. data/spec/analysis_specs/control_flow_specs/raise_properties_spec.rb +310 -0
  174. data/spec/analysis_specs/control_flow_specs/raise_type_inference_spec.rb +301 -0
  175. data/spec/analysis_specs/control_flow_specs/return_type_inference_spec.rb +431 -0
  176. data/spec/analysis_specs/control_flow_specs/simulation_spec.rb +158 -0
  177. data/spec/analysis_specs/control_flow_specs/spec_helper.rb +110 -0
  178. data/spec/analysis_specs/control_flow_specs/tuple_misuse_inference_spec.rb +125 -0
  179. data/spec/analysis_specs/control_flow_specs/unreachability_analysis_spec.rb +76 -0
  180. data/spec/analysis_specs/control_flow_specs/unused_variable_spec.rb +99 -0
  181. data/spec/analysis_specs/control_flow_specs/yield_properties_spec.rb +372 -0
  182. data/spec/analysis_specs/error_spec.rb +30 -0
  183. data/spec/analysis_specs/laser_class_spec.rb +322 -0
  184. data/spec/analysis_specs/lexical_analysis_spec.rb +184 -0
  185. data/spec/analysis_specs/protocol_registry_spec.rb +63 -0
  186. data/spec/analysis_specs/scope_annotation_spec.rb +1013 -0
  187. data/spec/analysis_specs/scope_spec.rb +126 -0
  188. data/spec/analysis_specs/sexp_analysis_spec.rb +30 -0
  189. data/spec/analysis_specs/sexp_extension_specs/constant_extraction_spec.rb +309 -0
  190. data/spec/analysis_specs/sexp_extension_specs/source_location_spec.rb +231 -0
  191. data/spec/analysis_specs/sexp_extension_specs/spec_helper.rb +1 -0
  192. data/spec/analysis_specs/sexp_extension_specs/type_inference_spec.rb +252 -0
  193. data/spec/analysis_specs/sexp_spec.rb +167 -0
  194. data/spec/analysis_specs/spec_helper.rb +27 -0
  195. data/spec/analysis_specs/unused_methods_spec.rb +65 -0
  196. data/spec/analysis_specs/visitor_spec.rb +64 -0
  197. data/spec/annotation_parser_specs/annotations_parser_spec.rb +89 -0
  198. data/spec/annotation_parser_specs/class_annotation_parser_spec.rb +120 -0
  199. data/spec/annotation_parser_specs/overload_parser_spec.rb +39 -0
  200. data/spec/annotation_parser_specs/parsers_spec.rb +14 -0
  201. data/spec/annotation_parser_specs/spec_helper.rb +1 -0
  202. data/spec/annotation_parser_specs/structural_parser_spec.rb +67 -0
  203. data/spec/laser_spec.rb +14 -0
  204. data/spec/rake_specs/spec_helper.rb +1 -0
  205. data/spec/rake_specs/task_spec.rb +67 -0
  206. data/spec/runner_spec.rb +207 -0
  207. data/spec/scanner_spec.rb +75 -0
  208. data/spec/spec_helper.rb +121 -0
  209. data/spec/standard_library/exceptions_spec.rb +19 -0
  210. data/spec/standard_library/globals_spec.rb +14 -0
  211. data/spec/standard_library/set_spec.rb +31 -0
  212. data/spec/standard_library/spec_helper.rb +1 -0
  213. data/spec/standard_library/standard_library_spec.rb +302 -0
  214. data/spec/support_specs/acts_as_struct_spec.rb +94 -0
  215. data/spec/support_specs/frequency_spec.rb +23 -0
  216. data/spec/support_specs/module_extensions_spec.rb +117 -0
  217. data/spec/support_specs/spec_helper.rb +1 -0
  218. data/spec/type_specs/spec_helper.rb +1 -0
  219. data/spec/type_specs/types_spec.rb +133 -0
  220. data/spec/warning_spec.rb +95 -0
  221. data/spec/warning_specs/assignment_in_condition_spec.rb +68 -0
  222. data/spec/warning_specs/comment_spacing_spec.rb +65 -0
  223. data/spec/warning_specs/extra_blank_lines_spec.rb +70 -0
  224. data/spec/warning_specs/extra_whitespace_spec.rb +33 -0
  225. data/spec/warning_specs/hash_symbol_18_warning_spec.rb +89 -0
  226. data/spec/warning_specs/hash_symbol_19_warning_spec.rb +63 -0
  227. data/spec/warning_specs/line_length_spec.rb +173 -0
  228. data/spec/warning_specs/misaligned_unindentation_spec.rb +35 -0
  229. data/spec/warning_specs/operator_spacing_spec.rb +104 -0
  230. data/spec/warning_specs/parens_on_declaration_spec.rb +57 -0
  231. data/spec/warning_specs/rescue_exception_spec.rb +105 -0
  232. data/spec/warning_specs/semicolon_spec.rb +58 -0
  233. data/spec/warning_specs/spec_helper.rb +1 -0
  234. data/spec/warning_specs/useless_double_quotes_spec.rb +74 -0
  235. data/status_reports/2010/12/2010-12-14.md +163 -0
  236. data/status_reports/2010/12/2010-12-23.md +298 -0
  237. data/status_reports/2010/12/2010-12-24.md +6 -0
  238. data/test/third_party_tests/rgl_tests/TestComponents.rb +65 -0
  239. data/test/third_party_tests/rgl_tests/TestCycles.rb +61 -0
  240. data/test/third_party_tests/rgl_tests/TestDirectedGraph.rb +125 -0
  241. data/test/third_party_tests/rgl_tests/TestDot.rb +18 -0
  242. data/test/third_party_tests/rgl_tests/TestEdge.rb +34 -0
  243. data/test/third_party_tests/rgl_tests/TestGraph.rb +71 -0
  244. data/test/third_party_tests/rgl_tests/TestGraphXML.rb +57 -0
  245. data/test/third_party_tests/rgl_tests/TestImplicit.rb +52 -0
  246. data/test/third_party_tests/rgl_tests/TestRdot.rb +863 -0
  247. data/test/third_party_tests/rgl_tests/TestTransitivity.rb +129 -0
  248. data/test/third_party_tests/rgl_tests/TestTraversal.rb +220 -0
  249. data/test/third_party_tests/rgl_tests/TestUnDirectedGraph.rb +102 -0
  250. data/test/third_party_tests/rgl_tests/examples/north/Graph.log +128 -0
  251. data/test/third_party_tests/rgl_tests/examples/north/g.10.0.graphml +28 -0
  252. data/test/third_party_tests/rgl_tests/examples/north/g.10.1.graphml +28 -0
  253. data/test/third_party_tests/rgl_tests/examples/north/g.10.11.graphml +31 -0
  254. data/test/third_party_tests/rgl_tests/examples/north/g.10.12.graphml +27 -0
  255. data/test/third_party_tests/rgl_tests/examples/north/g.10.13.graphml +27 -0
  256. data/test/third_party_tests/rgl_tests/examples/north/g.10.14.graphml +27 -0
  257. data/test/third_party_tests/rgl_tests/examples/north/g.10.15.graphml +26 -0
  258. data/test/third_party_tests/rgl_tests/examples/north/g.10.16.graphml +26 -0
  259. data/test/third_party_tests/rgl_tests/examples/north/g.10.17.graphml +26 -0
  260. data/test/third_party_tests/rgl_tests/examples/north/g.10.19.graphml +37 -0
  261. data/test/third_party_tests/rgl_tests/examples/north/g.10.2.graphml +28 -0
  262. data/test/third_party_tests/rgl_tests/examples/north/g.10.20.graphml +38 -0
  263. data/test/third_party_tests/rgl_tests/examples/north/g.10.22.graphml +43 -0
  264. data/test/third_party_tests/rgl_tests/examples/north/g.10.24.graphml +30 -0
  265. data/test/third_party_tests/rgl_tests/examples/north/g.10.25.graphml +45 -0
  266. data/test/third_party_tests/rgl_tests/examples/north/g.10.27.graphml +38 -0
  267. data/test/third_party_tests/rgl_tests/examples/north/g.10.28.graphml +30 -0
  268. data/test/third_party_tests/rgl_tests/examples/north/g.10.29.graphml +38 -0
  269. data/test/third_party_tests/rgl_tests/examples/north/g.10.3.graphml +26 -0
  270. data/test/third_party_tests/rgl_tests/examples/north/g.10.30.graphml +34 -0
  271. data/test/third_party_tests/rgl_tests/examples/north/g.10.31.graphml +42 -0
  272. data/test/third_party_tests/rgl_tests/examples/north/g.10.34.graphml +42 -0
  273. data/test/third_party_tests/rgl_tests/examples/north/g.10.37.graphml +28 -0
  274. data/test/third_party_tests/rgl_tests/examples/north/g.10.38.graphml +38 -0
  275. data/test/third_party_tests/rgl_tests/examples/north/g.10.39.graphml +36 -0
  276. data/test/third_party_tests/rgl_tests/examples/north/g.10.4.graphml +26 -0
  277. data/test/third_party_tests/rgl_tests/examples/north/g.10.40.graphml +37 -0
  278. data/test/third_party_tests/rgl_tests/examples/north/g.10.41.graphml +37 -0
  279. data/test/third_party_tests/rgl_tests/examples/north/g.10.42.graphml +26 -0
  280. data/test/third_party_tests/rgl_tests/examples/north/g.10.45.graphml +28 -0
  281. data/test/third_party_tests/rgl_tests/examples/north/g.10.46.graphml +32 -0
  282. data/test/third_party_tests/rgl_tests/examples/north/g.10.5.graphml +31 -0
  283. data/test/third_party_tests/rgl_tests/examples/north/g.10.50.graphml +30 -0
  284. data/test/third_party_tests/rgl_tests/examples/north/g.10.56.graphml +29 -0
  285. data/test/third_party_tests/rgl_tests/examples/north/g.10.57.graphml +32 -0
  286. data/test/third_party_tests/rgl_tests/examples/north/g.10.58.graphml +32 -0
  287. data/test/third_party_tests/rgl_tests/examples/north/g.10.6.graphml +26 -0
  288. data/test/third_party_tests/rgl_tests/examples/north/g.10.60.graphml +32 -0
  289. data/test/third_party_tests/rgl_tests/examples/north/g.10.61.graphml +34 -0
  290. data/test/third_party_tests/rgl_tests/examples/north/g.10.62.graphml +34 -0
  291. data/test/third_party_tests/rgl_tests/examples/north/g.10.68.graphml +30 -0
  292. data/test/third_party_tests/rgl_tests/examples/north/g.10.69.graphml +32 -0
  293. data/test/third_party_tests/rgl_tests/examples/north/g.10.7.graphml +29 -0
  294. data/test/third_party_tests/rgl_tests/examples/north/g.10.70.graphml +26 -0
  295. data/test/third_party_tests/rgl_tests/examples/north/g.10.71.graphml +27 -0
  296. data/test/third_party_tests/rgl_tests/examples/north/g.10.72.graphml +28 -0
  297. data/test/third_party_tests/rgl_tests/examples/north/g.10.74.graphml +29 -0
  298. data/test/third_party_tests/rgl_tests/examples/north/g.10.75.graphml +29 -0
  299. data/test/third_party_tests/rgl_tests/examples/north/g.10.78.graphml +27 -0
  300. data/test/third_party_tests/rgl_tests/examples/north/g.10.79.graphml +34 -0
  301. data/test/third_party_tests/rgl_tests/examples/north/g.10.8.graphml +29 -0
  302. data/test/third_party_tests/rgl_tests/examples/north/g.10.80.graphml +34 -0
  303. data/test/third_party_tests/rgl_tests/examples/north/g.10.82.graphml +35 -0
  304. data/test/third_party_tests/rgl_tests/examples/north/g.10.83.graphml +32 -0
  305. data/test/third_party_tests/rgl_tests/examples/north/g.10.85.graphml +34 -0
  306. data/test/third_party_tests/rgl_tests/examples/north/g.10.86.graphml +34 -0
  307. data/test/third_party_tests/rgl_tests/examples/north/g.10.88.graphml +37 -0
  308. data/test/third_party_tests/rgl_tests/examples/north/g.10.89.graphml +29 -0
  309. data/test/third_party_tests/rgl_tests/examples/north/g.10.9.graphml +26 -0
  310. data/test/third_party_tests/rgl_tests/examples/north/g.10.90.graphml +32 -0
  311. data/test/third_party_tests/rgl_tests/examples/north/g.10.91.graphml +31 -0
  312. data/test/third_party_tests/rgl_tests/examples/north/g.10.92.graphml +26 -0
  313. data/test/third_party_tests/rgl_tests/examples/north/g.10.93.graphml +32 -0
  314. data/test/third_party_tests/rgl_tests/examples/north/g.10.94.graphml +34 -0
  315. data/test/third_party_tests/rgl_tests/examples/north/g.12.8.graphml +40 -0
  316. data/test/third_party_tests/rgl_tests/examples/north/g.14.9.graphml +36 -0
  317. data/test/third_party_tests/rgl_tests/test_helper.rb +7 -0
  318. data/test/third_party_tests/test_inheritable_attributes.rb +187 -0
  319. metadata +470 -0
@@ -0,0 +1,431 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe 'CFG-based return type inference' do
4
+ it 'should infer types based on specified overloads' do
5
+ g = cfg <<-EOF
6
+ module RTI2
7
+ def self.multiply(x, y)
8
+ x * y
9
+ end
10
+ end
11
+ EOF
12
+ method = ClassRegistry['RTI2'].singleton_class.instance_method(:multiply)
13
+ method.return_type_for_types(
14
+ Utilities.type_for(ClassRegistry['RTI2']),
15
+ [Types::FIXNUM, Types::FLOAT]).should equal_type Types::UnionType.new([Types::FLOAT])
16
+ method.return_type_for_types(
17
+ Utilities.type_for(ClassRegistry['RTI2']),
18
+ [Types::FIXNUM, Types::FIXNUM]).should equal_type Types::UnionType.new([Types::FIXNUM, Types::BIGNUM])
19
+ end
20
+
21
+ it 'should infer type errors on methods with specified overloads' do
22
+ g = cfg <<-EOF
23
+ module RTI3
24
+ def self.sim3
25
+ if gets.size > 2
26
+ x = 'hi'
27
+ else
28
+ x = :hi
29
+ end
30
+ y = 15 * x
31
+ end
32
+ end
33
+ EOF
34
+ ClassRegistry['RTI3'].singleton_class.instance_method(:sim3).
35
+ return_type_for_types(
36
+ Utilities.type_for(ClassRegistry['RTI3'])).should == Types::EMPTY
37
+ g.should have_error(NoMatchingTypeSignature).on_line(8).with_message(/\*/)
38
+ end
39
+
40
+ it 'should infer the type resulting from a simple chain of standard-library methods' do
41
+ g = cfg <<-EOF
42
+ module RTI4
43
+ def self.bar
44
+ x = gets
45
+ qux(baz(x))
46
+ end
47
+ def self.baz(y)
48
+ y.to_sym.size
49
+ end
50
+ def self.qux(z)
51
+ z.zero?
52
+ end
53
+ end
54
+ EOF
55
+ ClassRegistry['RTI4'].singleton_class.instance_method(:bar).
56
+ return_type_for_types(
57
+ Utilities.type_for(ClassRegistry['RTI4'])).should equal_type Types::BOOLEAN
58
+ end
59
+
60
+ it 'should infer the type resulting from Class#new' do
61
+ g = cfg <<-EOF
62
+ module RTI5
63
+ class Foo
64
+ def initialize(x, y)
65
+ @x = x
66
+ @y = y
67
+ end
68
+ end
69
+ def self.make_a_foo(a, b)
70
+ Foo.new(a, b)
71
+ end
72
+ end
73
+ EOF
74
+ result = Types::UnionType.new([Types::ClassType.new('RTI5::Foo', :invariant)])
75
+ ClassRegistry['RTI5'].singleton_class.instance_method(:make_a_foo).
76
+ return_type_for_types(
77
+ Utilities.type_for(ClassRegistry['RTI5']),
78
+ [Types::FIXNUM, Types::FLOAT]).should equal_type result
79
+ end
80
+
81
+ it 'should infer types based on SSA, when appropriate' do
82
+ g = cfg <<-EOF
83
+ module RTI6
84
+ def self.multiply
85
+ if $$ > 10
86
+ a = 'hello'
87
+ else
88
+ a = 20
89
+ end
90
+ a * 3
91
+ end
92
+ end
93
+ EOF
94
+ result = Types::UnionType.new([Types::FIXNUM, Types::BIGNUM, Types::STRING])
95
+ ClassRegistry['RTI6'].singleton_class.instance_method(:multiply).
96
+ return_type_for_types(
97
+ Utilities.type_for(ClassRegistry['RTI6'])).should equal_type result
98
+ end
99
+
100
+ it 'should improve type inference due to SSA, when appropriate' do
101
+ g = cfg <<-EOF
102
+ module RTI7
103
+ def self.multiply
104
+ if $$ > 10
105
+ a = 'hello'
106
+ else
107
+ a = 20
108
+ end
109
+ b = a * 3
110
+ a = 3.14
111
+ a * 20
112
+ end
113
+ end
114
+ EOF
115
+ ClassRegistry['RTI7'].singleton_class.instance_method(:multiply).
116
+ return_type_for_types(
117
+ Utilities.type_for(ClassRegistry['RTI7'])).should equal_type Types::FLOAT
118
+ end
119
+
120
+ it 'should handle, via SSA, uninitialized variable types' do
121
+ g = cfg <<-EOF
122
+ class RTI8
123
+ def self.switch
124
+ if $$ > 10
125
+ a = 'hello'
126
+ end
127
+ b = a
128
+ end
129
+ end
130
+ EOF
131
+ ClassRegistry['RTI8'].singleton_class.instance_method(:switch).
132
+ return_type_for_types(
133
+ Utilities.type_for(ClassRegistry['RTI8'])).should equal_type(
134
+ Types::UnionType.new([Types::STRING, Types::NILCLASS]))
135
+ end
136
+
137
+ it 'should warn against certain methods with improper return types' do
138
+ g = cfg <<-EOF
139
+ class RTI8
140
+ def to_s
141
+ gets.strip! # whoops, ! means nil sometimes
142
+ end
143
+ end
144
+ EOF
145
+ ClassRegistry['RTI8'].instance_method(:to_s).
146
+ return_type_for_types(
147
+ ClassRegistry['RTI8'].as_type) # force calculation
148
+ ClassRegistry['RTI8'].instance_method(:to_s).proc.ast_node.should(
149
+ have_error(ImproperOverloadTypeError).with_message(/to_s/))
150
+ end
151
+
152
+ it 'should collect inferred types in global variables' do
153
+ g = cfg <<-EOF
154
+ module RTI9
155
+ def self.bar
156
+ $sim9 = x = gets
157
+ qux(baz(x))
158
+ end
159
+ def self.baz(y)
160
+ $sim9 = y.to_sym.size
161
+ end
162
+ def self.qux(z)
163
+ $sim9
164
+ end
165
+ end
166
+ EOF
167
+ # First, qux should give nil
168
+ ClassRegistry['RTI9'].singleton_class.instance_method(:qux).
169
+ return_type_for_types(
170
+ Utilities.type_for(ClassRegistry['RTI9']), [Types::STRING]).should equal_type Types::NILCLASS
171
+ expected_type = Types::UnionType.new(
172
+ [Types::STRING, Types::FIXNUM, Types::BIGNUM, Types::NILCLASS])
173
+ ClassRegistry['RTI9'].singleton_class.instance_method(:bar).
174
+ return_type_for_types(
175
+ Utilities.type_for(ClassRegistry['RTI9'])).should equal_type expected_type
176
+ Scope::GlobalScope.lookup('$sim9').expr_type.should equal_type expected_type
177
+ ClassRegistry['RTI9'].singleton_class.instance_method(:qux).
178
+ return_type_for_types(
179
+ Utilities.type_for(ClassRegistry['RTI9']), [Types::STRING]).should equal_type expected_type
180
+ end
181
+
182
+ it 'should collect inferred types in instance variables by class' do
183
+ g = cfg <<-EOF
184
+ class TI1
185
+ def set_foo(x)
186
+ @foo = x
187
+ end
188
+ def get_foo
189
+ @foo
190
+ end
191
+ end
192
+ class TI2
193
+ def set_foo(x)
194
+ @foo = x
195
+ end
196
+ def get_foo
197
+ @foo
198
+ end
199
+ end
200
+ EOF
201
+ ClassRegistry['TI1'].instance_method(:get_foo).return_type_for_types(
202
+ ClassRegistry['TI1'].as_type).should equal_type Types::NILCLASS
203
+ ClassRegistry['TI1'].instance_method(:set_foo).return_type_for_types(
204
+ ClassRegistry['TI1'].as_type, [Types::STRING]).should equal_type Types::STRING
205
+ ClassRegistry['TI1'].instance_method(:get_foo).return_type_for_types(
206
+ ClassRegistry['TI1'].as_type).should equal_type(
207
+ Types::UnionType.new([Types::NILCLASS, Types::STRING]))
208
+ ClassRegistry['TI1'].instance_method(:set_foo).return_type_for_types(
209
+ ClassRegistry['TI1'].as_type, [Types::FIXNUM]).should equal_type Types::FIXNUM
210
+ ClassRegistry['TI1'].instance_method(:get_foo).return_type_for_types(
211
+ ClassRegistry['TI1'].as_type).should equal_type(
212
+ Types::UnionType.new([Types::NILCLASS, Types::STRING, Types::FIXNUM]))
213
+
214
+ ClassRegistry['TI2'].instance_method(:get_foo).return_type_for_types(
215
+ ClassRegistry['TI2'].as_type).should equal_type Types::NILCLASS
216
+ ClassRegistry['TI2'].instance_method(:set_foo).return_type_for_types(
217
+ ClassRegistry['TI2'].as_type, [Types::FIXNUM]).should equal_type Types::FIXNUM
218
+ ClassRegistry['TI2'].instance_method(:get_foo).return_type_for_types(
219
+ ClassRegistry['TI2'].as_type).should equal_type(
220
+ Types::UnionType.new([Types::NILCLASS, Types::FIXNUM]))
221
+ end
222
+
223
+ it 'should extract argument types from rest arguments by index' do
224
+ g = cfg <<-EOF
225
+ class RTI11
226
+ def foo(*args)
227
+ args[0]
228
+ end
229
+ def bar(*args)
230
+ args[1]
231
+ end
232
+ end
233
+ EOF
234
+ ClassRegistry['RTI11'].instance_method(:foo).return_type_for_types(
235
+ ClassRegistry['RTI11'].as_type, [Types::FIXNUM, Types::PROC]).should equal_type Types::FIXNUM
236
+ ClassRegistry['RTI11'].instance_method(:bar).return_type_for_types(
237
+ ClassRegistry['RTI11'].as_type, [Types::FIXNUM, Types::PROC]).should equal_type Types::PROC
238
+ end
239
+
240
+ it 'should extract argument types from rest arguments by range index' do
241
+ g = cfg <<-EOF
242
+ class RTI12
243
+ def foo(*args)
244
+ args[0..1]
245
+ end
246
+ def bar(*args)
247
+ args[1..3]
248
+ end
249
+ def baz(*args)
250
+ args[-3..4]
251
+ end
252
+ def qux(*args)
253
+ args[-4..4]
254
+ end
255
+ end
256
+ EOF
257
+ ClassRegistry['RTI12'].instance_method(:foo).return_type_for_types(
258
+ ClassRegistry['RTI12'].as_type, [Types::FIXNUM, Types::PROC, Types::TRUECLASS]).should equal_type(
259
+ Types::TupleType.new([Types::FIXNUM, Types::PROC]))
260
+ ClassRegistry['RTI12'].instance_method(:bar).return_type_for_types(
261
+ ClassRegistry['RTI12'].as_type, [Types::STRING, Types::FLOAT, Types::HASH]).should equal_type(
262
+ Types::TupleType.new([Types::FLOAT, Types::HASH]))
263
+ ClassRegistry['RTI12'].instance_method(:baz).return_type_for_types(
264
+ ClassRegistry['RTI12'].as_type, [Types::STRING, Types::FLOAT, Types::HASH]).should equal_type(
265
+ Types::TupleType.new([Types::STRING, Types::FLOAT, Types::HASH]))
266
+ ClassRegistry['RTI12'].instance_method(:qux).return_type_for_types(
267
+ ClassRegistry['RTI12'].as_type, [Types::STRING, Types::FLOAT, Types::HASH]).should equal_type(
268
+ Types::NILCLASS)
269
+ end
270
+
271
+ it 'infers tuple types during expansion' do
272
+ g = cfg <<-EOF
273
+ class RTI13
274
+ def foo(*args)
275
+ a, b, c = args
276
+ a
277
+ end
278
+ def bar(*args)
279
+ a, b, c = args
280
+ b
281
+ end
282
+ def baz(*args)
283
+ a, b, c = args
284
+ c
285
+ end
286
+ end
287
+ EOF
288
+ ClassRegistry['RTI13'].instance_method(:foo).return_type_for_types(
289
+ ClassRegistry['RTI13'].as_type, [Types::FIXNUM, Types::PROC, Types::TRUECLASS]).should equal_type(
290
+ Types::FIXNUM)
291
+ ClassRegistry['RTI13'].instance_method(:bar).return_type_for_types(
292
+ ClassRegistry['RTI13'].as_type, [Types::FIXNUM, Types::PROC, Types::TRUECLASS]).should equal_type(
293
+ Types::PROC)
294
+ ClassRegistry['RTI13'].instance_method(:baz).return_type_for_types(
295
+ ClassRegistry['RTI13'].as_type, [Types::FIXNUM, Types::PROC, Types::TRUECLASS]).should equal_type(
296
+ Types::TRUECLASS)
297
+ ClassRegistry['RTI13'].instance_method(:baz).return_type_for_types(
298
+ ClassRegistry['RTI13'].as_type, [Types::FIXNUM, Types::PROC]).should equal_type(
299
+ Types::NILCLASS)
300
+ end
301
+
302
+ it 'infers the result of #size on tuples' do
303
+ g = cfg <<-EOF
304
+ class RTI14
305
+ def foo(*args)
306
+ args[args.size - 2]
307
+ end
308
+ def bar(*args)
309
+ args[args.length - 2]
310
+ end
311
+ def baz(*args)
312
+ args[args.size - 4]
313
+ end
314
+ end
315
+ EOF
316
+ ClassRegistry['RTI14'].instance_method(:foo).return_type_for_types(
317
+ ClassRegistry['RTI14'].as_type, [Types::FIXNUM, Types::PROC, Types::TRUECLASS]).should equal_type(
318
+ Types::PROC)
319
+ ClassRegistry['RTI14'].instance_method(:bar).return_type_for_types(
320
+ ClassRegistry['RTI14'].as_type, [Types::FIXNUM, Types::PROC, Types::TRUECLASS]).should equal_type(
321
+ Types::PROC)
322
+ ClassRegistry['RTI14'].instance_method(:foo).return_type_for_types(
323
+ ClassRegistry['RTI14'].as_type, [Types::FIXNUM, Types::PROC]).should equal_type(
324
+ Types::FIXNUM)
325
+ ClassRegistry['RTI14'].instance_method(:bar).return_type_for_types(
326
+ ClassRegistry['RTI14'].as_type, [Types::FIXNUM, Types::PROC]).should equal_type(
327
+ Types::FIXNUM)
328
+ ClassRegistry['RTI14'].instance_method(:baz).return_type_for_types(
329
+ ClassRegistry['RTI14'].as_type, [Types::FIXNUM, Types::PROC, Types::TRUECLASS]).should equal_type(
330
+ Types::TRUECLASS)
331
+ end
332
+
333
+ it 'infers the type of #to_a/ary on tuples' do
334
+ g = cfg <<-EOF
335
+ class RTI15
336
+ def foo(*args)
337
+ args.to_a.to_ary.to_a.to_a
338
+ end
339
+ end
340
+ EOF
341
+ ClassRegistry['RTI15'].instance_method(:foo).return_type_for_types(
342
+ ClassRegistry['RTI15'].as_type, [Types::FIXNUM, Types::PROC, Types::TRUECLASS]).should equal_type(
343
+ Types::TupleType.new([Types::FIXNUM, Types::PROC, Types::TRUECLASS]))
344
+ end
345
+
346
+ it 'infers tuple types from array literals' do
347
+ g = cfg <<-EOF
348
+ class RTI16
349
+ def foo
350
+ [1, :foo, 'string', {}]
351
+ end
352
+ end
353
+ EOF
354
+ ClassRegistry['RTI16'].instance_method(:foo).return_type_for_types(
355
+ ClassRegistry['RTI16'].as_type).should equal_type(
356
+ Types::TupleType.new([Types::FIXNUM, ClassRegistry['Symbol'].as_type,
357
+ Types::STRING, Types::HASH]))
358
+ end
359
+
360
+ it 'infers tuple types from array literals with varying components' do
361
+ g = cfg <<-EOF
362
+ class RTI17
363
+ def foo(x)
364
+ [x, :foo, 'string', {}]
365
+ end
366
+ end
367
+ EOF
368
+ ClassRegistry['RTI17'].instance_method(:foo).return_type_for_types(
369
+ ClassRegistry['RTI17'].as_type, [Types::FIXNUM]).should equal_type(
370
+ Types::TupleType.new([Types::FIXNUM, ClassRegistry['Symbol'].as_type,
371
+ Types::STRING, Types::HASH]))
372
+ end
373
+
374
+ it 'infers through calls to super' do
375
+ g = cfg <<-EOF
376
+ class RTI18
377
+ def foo(x)
378
+ "Hello \#{x}"
379
+ end
380
+ end
381
+ class RTI19 < RTI18
382
+ def foo(x, y)
383
+ super(y).size
384
+ end
385
+ end
386
+ class RTI20 < RTI19
387
+ def foo(x, y)
388
+ z = super
389
+ z.to_s
390
+ end
391
+ end
392
+ EOF
393
+ ClassRegistry['RTI18'].instance_method(:foo).return_type_for_types(
394
+ ClassRegistry['RTI18'].as_type, [Types::FIXNUM]).should equal_type(Types::STRING)
395
+ ClassRegistry['RTI19'].instance_method(:foo).return_type_for_types(
396
+ ClassRegistry['RTI19'].as_type, [Types::FIXNUM, Types::STRING]).should equal_type(
397
+ Types::FIXNUM | Types::BIGNUM)
398
+ ClassRegistry['RTI20'].instance_method(:foo).return_type_for_types(
399
+ ClassRegistry['RTI20'].as_type, [Types::FIXNUM, Types::STRING]).should equal_type(
400
+ Types::STRING)
401
+ end
402
+
403
+ it 'infers tuple types from tuple addition' do
404
+ g = cfg <<-EOF
405
+ class RTI22
406
+ def foo(x)
407
+ [x, :foo] + ['foobar', x]
408
+ end
409
+ end
410
+ EOF
411
+ ClassRegistry['RTI22'].instance_method(:foo).return_type_for_types(
412
+ ClassRegistry['RTI22'].as_type, [Types::FIXNUM]).should equal_type(
413
+ Types::TupleType.new([Types::FIXNUM, ClassRegistry['Symbol'].as_type,
414
+ Types::STRING, Types::FIXNUM]))
415
+ end
416
+
417
+ it 'infers tuple types from tuple multiplication' do
418
+ g = cfg <<-EOF
419
+ class RTI21
420
+ def foo(x)
421
+ [x, :foo] * 3
422
+ end
423
+ end
424
+ EOF
425
+ ClassRegistry['RTI21'].instance_method(:foo).return_type_for_types(
426
+ ClassRegistry['RTI21'].as_type, [Types::FIXNUM]).should equal_type(
427
+ Types::TupleType.new([Types::FIXNUM, ClassRegistry['Symbol'].as_type,
428
+ Types::FIXNUM, ClassRegistry['Symbol'].as_type,
429
+ Types::FIXNUM, ClassRegistry['Symbol'].as_type]))
430
+ end
431
+ end
@@ -0,0 +1,158 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe ControlFlow::Simulation do
4
+ it 'should create classes during toplevel simulation' do
5
+ g = cfg <<-EOF
6
+ class Sim1 < Hash
7
+ end
8
+ EOF
9
+ ClassRegistry['Sim1'].should_not be nil
10
+ ClassRegistry['Sim1'].superclass.should == ClassRegistry['Hash']
11
+ end
12
+
13
+ it 'should create methods during toplevel simulation' do
14
+ g = cfg <<-EOF
15
+ class Sim2
16
+ def foo(x, y)
17
+ end
18
+ end
19
+ EOF
20
+ ClassRegistry['Sim2'].instance_method(:foo).should_not be_nil
21
+ end
22
+
23
+ it 'should simulate toplevel alias_method calls' do
24
+ g = cfg <<-EOF
25
+ class Sim3
26
+ def foo(x, y)
27
+ end
28
+ alias_method :bar, :foo
29
+ end
30
+ EOF
31
+ ClassRegistry['Sim3'].instance_method(:foo).should ==
32
+ ClassRegistry['Sim3'].instance_method(:bar)
33
+ end
34
+
35
+ it 'should simulate toplevel general calls' do
36
+ g = cfg %q{
37
+ class Sim4
38
+ class << self
39
+ def alias_method_chain(name, suffix)
40
+ alias_method "#{name}_without_#{suffix}", name
41
+ alias_method name, "#{name}_with_#{suffix}"
42
+ end
43
+ end
44
+
45
+ def foo(x, y)
46
+ end
47
+ def foo_with_fun(x, y)
48
+ end
49
+ end
50
+ }
51
+ old_foo = ClassRegistry['Sim4'].instance_method(:foo)
52
+ new_foo = ClassRegistry['Sim4'].instance_method(:foo_with_fun)
53
+ g2 = cfg %q{
54
+ class Sim4
55
+ alias_method_chain :foo, :fun
56
+ end
57
+ }
58
+ ClassRegistry['Sim4'].instance_method(:foo_without_fun).should == old_foo
59
+ ClassRegistry['Sim4'].instance_method(:foo).should == new_foo
60
+ end
61
+
62
+ it 'should simulate ruby-level attr_{reader,writer,accessor} calls' do
63
+ g = cfg %q{
64
+ class Sim5
65
+ attr_reader :foo, :bar
66
+ attr_writer :baz
67
+ attr_accessor :qux, :pie
68
+ end
69
+ }
70
+
71
+ %w(foo bar qux pie).each do |name|
72
+ method = ClassRegistry['Sim5'].instance_method(name)
73
+ method.should be_a(LaserMethod)
74
+ method.arity.should == Arity.new(0..0)
75
+ end
76
+
77
+ %w(baz= qux= pie=).each do |name|
78
+ method = ClassRegistry['Sim5'].instance_method(name)
79
+ method.should be_a(LaserMethod)
80
+ method.arity.should == Arity.new(1..1)
81
+ end
82
+ end
83
+
84
+ it 'should simulate blocks being called by builtins' do
85
+ g = cfg %q{
86
+ input = (1..10).to_a
87
+ output = input.map do |x|
88
+ x ** x
89
+ end
90
+ }
91
+
92
+ expected = (1..10).map { |x| x ** x }
93
+ g.var_named('output').value.should == expected
94
+ end
95
+
96
+ it 'should simulate #define_method with a block' do
97
+ g = cfg %q{
98
+ class Sim6
99
+ [1, 2].each do |multiplicand|
100
+ define_method("times_#{multiplicand}") { |x| x * multiplicand }
101
+ end
102
+ end
103
+ }
104
+ method = ClassRegistry['Sim6'].instance_method(:times_1)
105
+ method.should be_a(LaserMethod)
106
+ method.arity.should == Arity.new(1..1)
107
+ method = ClassRegistry['Sim6'].instance_method(:times_1)
108
+ method.should be_a(LaserMethod)
109
+ method.arity.should == Arity.new(1..1)
110
+ end
111
+
112
+
113
+ it 'should give up on simulation and turn to constant propagation when unpredictability occurs' do
114
+ g = cfg %q{
115
+ class Sim7
116
+ def foo(str)
117
+ bar(str[0..3]).size
118
+ end
119
+ def bar(substr)
120
+ substr.split(//)
121
+ end
122
+ end
123
+ SimVal8 = Sim7.new.foo(gets)
124
+ }
125
+ ClassRegistry['Sim7'].instance_method(:bar).return_type_for_types(
126
+ ClassRegistry['Sim7'].as_type, [Types::STRING]).should equal_type Types::UnionType.new([Types::ARRAY])
127
+ ClassRegistry['Sim7'].instance_method(:foo).return_type_for_types(
128
+ ClassRegistry['Sim7'].as_type, [Types::STRING]).should equal_type Types::UnionType.new([Types::FIXNUM])
129
+ end
130
+
131
+ it 'should simulate calls to super' do
132
+ g = cfg %q{
133
+ class Sim8
134
+ def foo(x, y)
135
+ x * y
136
+ end
137
+ end
138
+ class Sim8B < Sim8
139
+ def foo(x)
140
+ super(x, 5)
141
+ end
142
+ end
143
+ fifty = Sim8B.new.foo(10)
144
+ string = Sim8B.new.foo('xx')
145
+ }
146
+ g.var_named('fifty').value.should == 50
147
+ g.var_named('string').value.should == 'xxxxxxxxxx'
148
+ end
149
+
150
+ # passes, but takes fucking forever
151
+ # it 'should add an error when simulation fails to terminate' do
152
+ # input = 'x = 1 while true'
153
+ # tree = annotate_all(input)
154
+ # tree.all_errors.size.should be 1
155
+ # tree.all_errors.first.should be_a(TopLevelSimulationRaised)
156
+ # tree.all_errors.first.error.should be_a(ControlFlow::Simulation::SimulationNonterminationError)
157
+ # end
158
+ end