laser 0.7.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
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,39 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe Parsers::OverloadParser do
4
+ before do
5
+ @parser = Parsers::AnnotationParser.new
6
+ end
7
+
8
+ describe 'a simple overload type' do
9
+ it 'is parsed as a generic proc type' do
10
+ '(Float=) -> Float='.should parse_to(
11
+ Types::GenericType.new(
12
+ Types::PROC, [Types::TupleType.new([Types::FLOAT]), Types::FLOAT]))
13
+ end
14
+
15
+ it 'is parsed as a generic proc type without the arrow' do
16
+ '(Float=) Float='.should parse_to(
17
+ Types::GenericType.new(
18
+ Types::PROC, [Types::TupleType.new([Types::FLOAT]), Types::FLOAT]))
19
+ end
20
+ end
21
+
22
+ describe 'more complex overload listings' do
23
+ it 'is parsed as a generic proc type' do
24
+ '(Float=, Array=, Fixnum=) -> Float= | NilClass='.should parse_to(
25
+ Types::GenericType.new(
26
+ Types::PROC,
27
+ [Types::TupleType.new([Types::FLOAT, Types::ARRAY, Types::FIXNUM]),
28
+ Types::UnionType.new([Types::FLOAT, Types::NILCLASS])]))
29
+ end
30
+
31
+ it 'is parsed as a generic proc type without the arrow' do
32
+ '(Float=, Array=, Fixnum=) Float= | NilClass='.should parse_to(
33
+ Types::GenericType.new(
34
+ Types::PROC,
35
+ [Types::TupleType.new([Types::FLOAT, Types::ARRAY, Types::FIXNUM]),
36
+ Types::UnionType.new([Types::FLOAT, Types::NILCLASS])]))
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,14 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe Parsers do
4
+ describe Parsers::AnnotationParser do
5
+ it 'exists' do
6
+ Parsers::AnnotationParser != nil
7
+ end
8
+ end
9
+ describe Parsers::ClassParser do
10
+ it 'exists' do
11
+ Parsers::ClassParser != nil
12
+ end
13
+ end
14
+ end
@@ -0,0 +1 @@
1
+ require_relative '../spec_helper'
@@ -0,0 +1,67 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe Parsers::StructuralParser do
4
+ before do
5
+ @parser = Parsers::AnnotationParser.new
6
+ end
7
+
8
+ describe 'a simple, full structural constraint' do
9
+ it 'is parsed into a single constraint' do
10
+ '#write(String, Fixnum=) -> NilClass'.should parse_to(
11
+ Types::StructuralType.new('write',
12
+ [Types::ClassType.new('String', :covariant),
13
+ Types::ClassType.new('Fixnum', :invariant)],
14
+ Types::ClassType.new('NilClass', :covariant)))
15
+ end
16
+
17
+ it 'parses with an empty arg list' do
18
+ '#write() -> NilClass'.should parse_to(
19
+ Types::StructuralType.new('write',
20
+ [], Types::ClassType.new('NilClass', :covariant)))
21
+ end
22
+ end
23
+
24
+ describe 'a full structural constraint in Go-style' do
25
+ it 'is parsed into the equivalent constraint' do
26
+ '#write(String) NilClass'.should parse_to(
27
+ Types::StructuralType.new('write',
28
+ [Types::ClassType.new('String', :covariant)],
29
+ Types::ClassType.new('NilClass', :covariant)))
30
+ end
31
+
32
+ it 'parses with an empty arg list' do
33
+ '#write() NilClass'.should parse_to(
34
+ Types::StructuralType.new('write',
35
+ [], Types::ClassType.new('NilClass', :covariant)))
36
+ end
37
+ end
38
+
39
+ describe 'a structural constraint without a return type' do
40
+ it 'is parsed into a constraint with an empty return type constraint set' do
41
+ '#write(String, Fixnum=)'.should parse_to(
42
+ Types::StructuralType.new('write',
43
+ [Types::ClassType.new('String', :covariant),
44
+ Types::ClassType.new('Fixnum', :invariant)],
45
+ []))
46
+ end
47
+
48
+ it 'parses with an empty arg list' do
49
+ '#write()'.should parse_to(
50
+ Types::StructuralType.new('write', [], []))
51
+ end
52
+ end
53
+
54
+ describe 'a structural constraint with an elided argument list' do
55
+ it 'is parsed into a constraint with an empty return type and argument constraint set' do
56
+ '#write->Fixnum-'.should parse_to(
57
+ Types::StructuralType.new('write', [],
58
+ Types::ClassType.new('Fixnum', :contravariant)))
59
+ end
60
+ end
61
+
62
+ describe 'a structural constraint with no arguments or return types specified' do
63
+ it 'is parsed into a constraint with an empty return type and argument constraint set' do
64
+ '#write'.should parse_to(Types::StructuralType.new('write', [], []))
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,14 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe Laser do
4
+ it "has a version" do
5
+ VERSION.should_not be_nil
6
+ VERSION.should >= "0.5.0"
7
+ end
8
+
9
+ describe 'TESTS_ACTIVATED' do
10
+ it 'should be true' do
11
+ TESTS_ACTIVATED.should be true
12
+ end
13
+ end
14
+ end
@@ -0,0 +1 @@
1
+ require_relative '../spec_helper'
@@ -0,0 +1,67 @@
1
+ require_relative 'spec_helper'
2
+ require 'rubygems'
3
+ require 'rake'
4
+ require 'tmpdir'
5
+ require 'laser/rake/task'
6
+
7
+ describe Laser::Rake::LaserTask do
8
+ describe '#initialize' do
9
+ it 'yields to allow setting :libs and :extras' do
10
+ task_name = "temptask1-#{rand(65329)}".to_sym
11
+ task = Laser::Rake::LaserTask.new(task_name) do |laser|
12
+ laser.libs = "LOL"
13
+ laser.extras = "hai"
14
+ end
15
+ task.settings.libs.should == "LOL"
16
+ task.settings.extras.should == "hai"
17
+ end
18
+
19
+ it 'creates a Rake task with the given name that calls #run' do
20
+ task_name = "temptask2_#{rand(65000)}".to_sym
21
+ task = Laser::Rake::LaserTask.new(task_name)
22
+ Rake::Task[task_name].should_not be_nil
23
+ task.should_receive(:run)
24
+ Rake::Task[task_name].invoke
25
+ end
26
+
27
+ it 'allows you to specify which warnings to use' do
28
+ task_name = "temptask3_#{rand(65000)}".to_sym
29
+ task = Laser::Rake::LaserTask.new(task_name) do |laser|
30
+ laser.using << :one << :two
31
+ end
32
+ task.settings.using.should == [:one, :two]
33
+ end
34
+
35
+ it 'defaults to using all warnings' do
36
+ task_name = "temptask4_#{rand(65000)}".to_sym
37
+ task = Laser::Rake::LaserTask.new(task_name) do |laser|
38
+ end
39
+ task.settings.using.should == [:all]
40
+ end
41
+ end
42
+
43
+ describe '#run' do
44
+ it 'searches the listed libraries for files' do
45
+ Dir.should_receive(:[]).with('lib/**/*.rb').and_return([])
46
+ Dir.should_receive(:[]).with('spec/**/*.rb').and_return([])
47
+ task = Laser::Rake::LaserTask.new("temptask3-#{rand(65329)}".to_sym) do |laser|
48
+ laser.libs << 'lib' << 'spec'
49
+ end
50
+ swizzling_io { task.run }
51
+ end
52
+
53
+ it 'scans the matching files' do
54
+ test_file = File.open(File.join(Dir.tmpdir, 'test_input'), 'w') do |fp|
55
+ fp << 'a + b '
56
+ end
57
+ Dir.should_receive(:[]).with('lib/**/*.rb').and_return([File.join(Dir.tmpdir, 'test_input')])
58
+ Dir.should_receive(:[]).with('spec/**/*.rb').and_return([])
59
+ task = Laser::Rake::LaserTask.new("temptask4-#{rand(65329)}".to_sym) do |laser|
60
+ laser.libs << 'lib' << 'spec'
61
+ end
62
+ printout = swizzling_io { task.run }
63
+ printout.should =~ /whitespace/
64
+ printout.should =~ /1 are fixable/
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,207 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe Runner do
4
+ before do
5
+ @runner = Runner.new(['a', :b])
6
+ end
7
+
8
+ describe '#run' do
9
+ it 'collects options and arguments, decides what to scan, scans, and displays' do
10
+ runner = Runner.new(['--report-fixed', 'hello', 'world'])
11
+ expected_settings = {:"report-fixed_given"=>true, :"report-fixed"=>true,
12
+ fix: false, help: false, debug: false,
13
+ InlineCommentSpaceWarning::OPTION_KEY => 2,
14
+ :"line-length" => nil, only: nil, stdin: false,
15
+ display: true, :"list-modules" => false, profile: false,
16
+ __using__: Warning.all_warnings,
17
+ __fix__: Warning.all_warnings}
18
+ scanner = mock(:scanner)
19
+ Scanner.should_receive(:new, expected_settings).and_return(scanner)
20
+
21
+ data1, data2 = mock(:data1), mock(:data2)
22
+ warning1, warning2 = mock(:warning1), mock(:warning2)
23
+ file1, file2 = mock(:file1), mock(:file2)
24
+
25
+ scanner.should_receive(:settings).exactly(3).times.and_return({:"report-fixed" => true})
26
+ File.should_receive(:read).with('hello').twice.and_return(data1)
27
+ scanner.should_receive(:scan).
28
+ with(data1, 'hello').
29
+ and_return([warning1])
30
+ warning1.should_receive(:to_ary)
31
+
32
+ scanner.should_receive(:settings).and_return({})
33
+ File.should_receive(:read).with('world').twice.and_return(data2)
34
+ scanner.should_receive(:scan).
35
+ with(data2, 'world').
36
+ and_return([warning2])
37
+ warning2.should_receive(:to_ary)
38
+
39
+ runner.should_receive(:display_warnings).with([warning1, warning2], expected_settings)
40
+
41
+ runner.run
42
+ end
43
+
44
+ it 'works with stdin: true' do
45
+ runner = Runner.new(['--stdin', '--only', 'UselessDoubleQuotesWarning'])
46
+ expected_settings = {:"report-fixed" => false, fix: false, help: false,
47
+ debug: false, InlineCommentSpaceWarning::OPTION_KEY => 2,
48
+ :"line-length" => nil, only: 'UselessDoubleQuotesWarning',
49
+ stdin: true, stdin_given: true, only_given: true,
50
+ display: true, :"list-modules" => false, profile: false,
51
+ __using__: [UselessDoubleQuotesWarning],
52
+ __fix__: [UselessDoubleQuotesWarning]}
53
+ scanner = mock(:scanner)
54
+ Scanner.should_receive(:new, expected_settings).and_return(scanner)
55
+
56
+ data1 = mock(:data1)
57
+ warning1 = mock(:warning1)
58
+
59
+ scanner.should_receive(:settings).twice.and_return({:"report-fixed" => true})
60
+ STDIN.should_receive(:read).twice.and_return(data1)
61
+ scanner.should_receive(:scan).
62
+ with(data1, '(stdin)').
63
+ and_return([warning1])
64
+ warning1.should_receive(:to_ary)
65
+
66
+ runner.should_receive(:display_warnings).with([warning1], expected_settings)
67
+ runner.run
68
+ end
69
+
70
+ it 'works with --list-modules' do
71
+ output = swizzling_io do
72
+ runner = Runner.new(['--list-modules'])
73
+ runner.run
74
+ end
75
+ modules = output.split("\n")[2..-1]
76
+ modules.should_not be_empty
77
+ modules.should == modules.sort
78
+ ["Array < Object", "Module < Object", "Proc < Object", "Class < Module", "Object < BasicObject"].each do |mod|
79
+ modules.should include(mod)
80
+ end
81
+ end
82
+ end
83
+
84
+ describe '#collect_options_and_arguments' do
85
+ before do
86
+ @runner = Runner.new(['--fix', '--report-fixed', '--line-length', '103', 'hello', 'there'])
87
+ @settings, @arguments = @runner.collect_options_and_arguments
88
+ end
89
+
90
+ after do
91
+ new_warning = current = Warning.all_warnings.find do |warning|
92
+ warning.superclass == GenericLineLengthWarning && warning.line_length_limit == 103
93
+ end
94
+ while (current = current.superclass) && current != Warning.superclass
95
+ current.all_warnings.delete new_warning
96
+ end if current
97
+ end
98
+
99
+ it 'finds both flags' do
100
+ @settings[:fix].should be_true
101
+ @settings[:"report-fixed"].should be_true
102
+ @settings[:"line-length"].should == 103
103
+ end
104
+
105
+ it 'finds both stray arguments' do
106
+ @arguments.should == ['hello', 'there']
107
+ end
108
+ end
109
+
110
+ describe '#swizzling_argv' do
111
+ it 'changes ARGV to the runner\'s argv value' do
112
+ @runner.swizzling_argv do
113
+ ARGV.should == ['a', :b]
114
+ end
115
+ end
116
+
117
+ it 'restores ARGV despite an exception' do
118
+ old_argv = ARGV.dup
119
+ expect {
120
+ @runner.swizzling_argv do
121
+ raise SystemExit.new('exiting')
122
+ end
123
+ }.to raise_error(SystemExit)
124
+ ARGV.should == old_argv
125
+ end
126
+ end
127
+
128
+ describe '#get_settings' do
129
+ it 'has a --fix option' do
130
+ runner = Runner.new(['--fix'])
131
+ settings = runner.swizzling_argv { runner.get_settings }
132
+ settings[:fix].should be_true
133
+ settings[:fix_given].should be_true
134
+ end
135
+
136
+ it 'has a --report-fixed option' do
137
+ runner = Runner.new(['--report-fixed'])
138
+ settings = runner.swizzling_argv { runner.get_settings }
139
+ settings[:"report-fixed"].should be_true
140
+ settings[:"report-fixed_given"].should be_true
141
+ end
142
+ end
143
+
144
+ describe '#handle_global_options' do
145
+ it 'specifies :using and :fix when :only is provided' do
146
+ runner = Runner.new([])
147
+ runner.handle_global_options(only: 'UselessDoubleQuotesWarning')
148
+ runner.using.should == [UselessDoubleQuotesWarning]
149
+ runner.fix.should == [UselessDoubleQuotesWarning]
150
+ end
151
+
152
+ it 'works with multiple short names' do
153
+ runner = Runner.new([])
154
+ runner.handle_global_options(only: 'ST1,ST3')
155
+ runner.using.size.should == 2
156
+ runner.using.each {|w| w.ancestors.should include(Warning) }
157
+ end
158
+ end
159
+
160
+ describe '#convert_warning_list' do
161
+ it 'should have a :whitespace helper' do
162
+ result = @runner.convert_warning_list([:whitespace])
163
+ list = ExtraBlankLinesWarning, ExtraWhitespaceWarning,
164
+ OperatorSpacing, MisalignedUnindentationWarning
165
+ (result & list).should == list
166
+ end
167
+
168
+ it 'should have an :all option' do
169
+ @runner.convert_warning_list([:all]).should == Warning.all_warnings
170
+ end
171
+ end
172
+
173
+ describe '#display_warnings' do
174
+ it 'prints the lines and files where there are warnings' do
175
+ warning = Warning.new('hello', 'a+b')
176
+ warning.line_number = 4
177
+ warning.severity = 3
178
+ warnings = [warning]
179
+ runner = Runner.new(['temp', 'hello'])
180
+ output = swizzling_io do
181
+ runner.display_warnings(warnings, {})
182
+ end
183
+ output.should =~ /hello:4/
184
+ output.should =~ /(3)/
185
+ output.should =~ /Warning/
186
+ output.should =~ /1 warning/
187
+ output.should =~ /0 are fixable/
188
+ end
189
+ end
190
+
191
+ describe '#collect_warnings' do
192
+ it 'scans each file provided' do
193
+ scanner = mock(:scanner)
194
+ data1, data2 = mock(:data1), mock(:data2)
195
+ warning_list1, warning_list2 = mock(:wl1), mock(:wl2)
196
+ File.should_receive(:read).with('abc').and_return(data1)
197
+ scanner.should_receive(:settings).exactly(4).times.and_return({})
198
+ scanner.should_receive(:scan).with(data1, 'abc').and_return(warning_list1)
199
+ warning_list1.should_receive(:to_ary)
200
+ File.should_receive(:read).with('def').and_return(data2)
201
+ scanner.should_receive(:scan).with(data2, 'def').and_return(warning_list2)
202
+ warning_list2.should_receive(:to_ary)
203
+
204
+ @runner.collect_warnings(['abc', 'def'], scanner).should == [warning_list1, warning_list2]
205
+ end
206
+ end
207
+ end
@@ -0,0 +1,75 @@
1
+ require_relative 'spec_helper'
2
+ require 'stringio'
3
+
4
+ describe Scanner do
5
+ before do
6
+ @scanner = Scanner.new(InlineCommentSpaceWarning::OPTION_KEY => 2)
7
+
8
+ @fix_scanner_stdout = StringIO.new
9
+ @fix_scanner = Scanner.new(fix: true, output_file: @fix_scanner_stdout)
10
+ end
11
+
12
+ describe '#scan' do
13
+ it 'takes an input and gathers warnings about it' do
14
+ warnings = @scanner.scan('1 + 2 ', '(stdin)')
15
+ warnings.size.should == 1
16
+ warnings[0].should be_a(ExtraWhitespaceWarning)
17
+ end
18
+
19
+ it "ignores warnings specified in the line's comments by class name" do
20
+ warnings = @scanner.scan('1 +2 # laser: ignore OperatorSpacing')
21
+ warnings.size.should == 0
22
+ end
23
+
24
+ it "ignores warnings specified in the line's comments by short name" do
25
+ warnings = @scanner.scan("1 +2 # laser: ignore #{OperatorSpacing.short_name}")
26
+ warnings.size.should == 0
27
+ end
28
+
29
+ it "ignores multiple warnings that are marked in the line's comments" do
30
+ warnings = @scanner.scan(
31
+ '1 +2; 3 + 4 # laser: ignore OperatorSpacing SemicolonWarning')
32
+ warnings.size.should == 0
33
+ end
34
+
35
+ it "ignores multiple warnings in the line's comments as short name" do
36
+ warnings = @scanner.scan(
37
+ "1 +2; 3 + 4 # laser: ignore #{OperatorSpacing.short_name} #{SemicolonWarning.short_name}")
38
+ warnings.size.should == 0
39
+ end
40
+
41
+ it 'fixes the input and writes it to :output_file' do
42
+ warnings = @fix_scanner.scan('1 + 2 ', '(stdin)')
43
+ warnings.size.should == 1
44
+ warnings[0].should be_a(ExtraWhitespaceWarning)
45
+ @fix_scanner_stdout.string.should == "1 + 2"
46
+ end
47
+
48
+ it 'fixes multiple errors on one line' do
49
+ warnings = @fix_scanner.scan('1 +2 ', '(stdin)')
50
+ warnings.size.should == 2
51
+ @fix_scanner_stdout.string.should == "1 + 2"
52
+ end
53
+
54
+ it 'fixes multiline inputs' do
55
+ warnings = @fix_scanner.scan("def plus(a, b)\n a + b \nend", '(stdin)')
56
+ warnings.size.should == 1
57
+ warnings[0].should be_a(ExtraWhitespaceWarning)
58
+ @fix_scanner_stdout.string.should == "def plus(a, b)\n a + b\nend"
59
+ end
60
+
61
+ it 'fixes multiline mis-indented inputs' do
62
+ warnings = @fix_scanner.scan("def plus(a, b)\n a + b\n end", '(stdin)')
63
+ warnings.size.should == 1
64
+ warnings[0].should be_a(MisalignedUnindentationWarning)
65
+ @fix_scanner_stdout.string.should == "def plus(a, b)\n a + b\nend"
66
+ end
67
+
68
+ it 'fixes class definitions' do
69
+ warnings = @fix_scanner.scan("class Hello\n 1+2\nend", '(stdin)')
70
+ warnings.size.should == 1
71
+ warnings[0].should be_a(OperatorSpacing)
72
+ @fix_scanner_stdout.string.should == "class Hello\n 1 + 2\nend"
73
+ end
74
+ end
75
+ end