laser 0.7.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +14 -0
- data/LICENSE +661 -0
- data/README.md +158 -0
- data/Rakefile +104 -0
- data/VERSION +1 -0
- data/bin/laser +7 -0
- data/design_docs/goals.md +57 -0
- data/design_docs/object_regex.md +426 -0
- data/design_docs/type_annotations.md +80 -0
- data/ext/laser/BasicBlock.cpp +572 -0
- data/ext/laser/BasicBlock.h +118 -0
- data/ext/laser/extconf.rb +3 -0
- data/features/laser.feature +25 -0
- data/features/step_definitions/laser_steps.rb +39 -0
- data/features/support/env.rb +14 -0
- data/features/support/testdata/1_input +1 -0
- data/features/support/testdata/1_output +1 -0
- data/features/support/testdata/2_input +4 -0
- data/features/support/testdata/2_output +4 -0
- data/features/support/testdata/3_input +8 -0
- data/features/support/testdata/3_output +11 -0
- data/features/support/testdata/4_input +5 -0
- data/features/support/testdata/4_output +5 -0
- data/features/support/testdata/5_input +13 -0
- data/laser.gemspec +382 -0
- data/lib/laser.rb +98 -0
- data/lib/laser/analysis/annotations.rb +95 -0
- data/lib/laser/analysis/annotations/annotation_config.yaml +3 -0
- data/lib/laser/analysis/annotations/comment_attachment_annotation.rb +66 -0
- data/lib/laser/analysis/annotations/node_pointers_annotation.rb +36 -0
- data/lib/laser/analysis/annotations/runtime_annotation.rb +55 -0
- data/lib/laser/analysis/argument_expansion.rb +132 -0
- data/lib/laser/analysis/arity.rb +34 -0
- data/lib/laser/analysis/bindings.rb +144 -0
- data/lib/laser/analysis/bootstrap/bootstrap.rb +298 -0
- data/lib/laser/analysis/bootstrap/laser_class.rb +106 -0
- data/lib/laser/analysis/bootstrap/laser_method.rb +255 -0
- data/lib/laser/analysis/bootstrap/laser_module.rb +403 -0
- data/lib/laser/analysis/bootstrap/laser_module_copy.rb +74 -0
- data/lib/laser/analysis/bootstrap/laser_object.rb +69 -0
- data/lib/laser/analysis/bootstrap/laser_proc.rb +150 -0
- data/lib/laser/analysis/bootstrap/laser_singleton_class.rb +44 -0
- data/lib/laser/analysis/comments.rb +35 -0
- data/lib/laser/analysis/control_flow.rb +28 -0
- data/lib/laser/analysis/control_flow/alias_analysis.rb +31 -0
- data/lib/laser/analysis/control_flow/basic_block.rb +105 -0
- data/lib/laser/analysis/control_flow/cfg_builder.rb +2505 -0
- data/lib/laser/analysis/control_flow/cfg_instruction.rb +190 -0
- data/lib/laser/analysis/control_flow/constant_propagation.rb +742 -0
- data/lib/laser/analysis/control_flow/control_flow_graph.rb +370 -0
- data/lib/laser/analysis/control_flow/lifetime_analysis.rb +91 -0
- data/lib/laser/analysis/control_flow/method_call_search.rb +26 -0
- data/lib/laser/analysis/control_flow/raise_properties.rb +25 -0
- data/lib/laser/analysis/control_flow/simulation.rb +385 -0
- data/lib/laser/analysis/control_flow/static_single_assignment.rb +185 -0
- data/lib/laser/analysis/control_flow/unreachability_analysis.rb +57 -0
- data/lib/laser/analysis/control_flow/unused_variables.rb +91 -0
- data/lib/laser/analysis/control_flow/yield_properties.rb +103 -0
- data/lib/laser/analysis/errors.rb +131 -0
- data/lib/laser/analysis/laser_utils.rb +18 -0
- data/lib/laser/analysis/lexical_analysis.rb +172 -0
- data/lib/laser/analysis/method_call.rb +68 -0
- data/lib/laser/analysis/protocol_registry.rb +30 -0
- data/lib/laser/analysis/scope.rb +118 -0
- data/lib/laser/analysis/sexp.rb +159 -0
- data/lib/laser/analysis/sexp_analysis.rb +40 -0
- data/lib/laser/analysis/sexp_extensions/constant_extraction.rb +115 -0
- data/lib/laser/analysis/sexp_extensions/source_location.rb +164 -0
- data/lib/laser/analysis/sexp_extensions/type_inference.rb +47 -0
- data/lib/laser/analysis/signature.rb +76 -0
- data/lib/laser/analysis/special_methods/send.rb +67 -0
- data/lib/laser/analysis/unused_methods.rb +21 -0
- data/lib/laser/analysis/visitor.rb +141 -0
- data/lib/laser/annotation_parser/annotations.treetop +126 -0
- data/lib/laser/annotation_parser/annotations_parser.rb +748 -0
- data/lib/laser/annotation_parser/class_annotations.treetop +82 -0
- data/lib/laser/annotation_parser/class_annotations_parser.rb +654 -0
- data/lib/laser/annotation_parser/overload.treetop +24 -0
- data/lib/laser/annotation_parser/overload_parser.rb +167 -0
- data/lib/laser/annotation_parser/parsers.rb +6 -0
- data/lib/laser/annotation_parser/structural.treetop +37 -0
- data/lib/laser/annotation_parser/structural_parser.rb +406 -0
- data/lib/laser/annotation_parser/useful_parsers.treetop +47 -0
- data/lib/laser/annotation_parser/useful_parsers_parser.rb +674 -0
- data/lib/laser/rake/task.rb +46 -0
- data/lib/laser/runner.rb +189 -0
- data/lib/laser/scanner.rb +169 -0
- data/lib/laser/standard_library/_thread.rb +110 -0
- data/lib/laser/standard_library/abbrev.rb +103 -0
- data/lib/laser/standard_library/array.rb +418 -0
- data/lib/laser/standard_library/base64.rb +91 -0
- data/lib/laser/standard_library/basic_object.rb +55 -0
- data/lib/laser/standard_library/benchmark.rb +556 -0
- data/lib/laser/standard_library/bignum.rb +185 -0
- data/lib/laser/standard_library/cgi.rb +275 -0
- data/lib/laser/standard_library/cgi/cookie.rb +147 -0
- data/lib/laser/standard_library/cgi/core.rb +791 -0
- data/lib/laser/standard_library/cgi/html.rb +1021 -0
- data/lib/laser/standard_library/cgi/session.rb +537 -0
- data/lib/laser/standard_library/cgi/session/pstore.rb +111 -0
- data/lib/laser/standard_library/cgi/util.rb +188 -0
- data/lib/laser/standard_library/class_definitions.rb +333 -0
- data/lib/laser/standard_library/comparable.rb +125 -0
- data/lib/laser/standard_library/complex.rb +162 -0
- data/lib/laser/standard_library/enumerable.rb +178 -0
- data/lib/laser/standard_library/exceptions.rb +135 -0
- data/lib/laser/standard_library/fixnum.rb +188 -0
- data/lib/laser/standard_library/float.rb +180 -0
- data/lib/laser/standard_library/hash.rb +237 -0
- data/lib/laser/standard_library/integer.rb +123 -0
- data/lib/laser/standard_library/laser_magic.rb +7 -0
- data/lib/laser/standard_library/nil_false_true.rb +113 -0
- data/lib/laser/standard_library/numbers.rb +192 -0
- data/lib/laser/standard_library/proc.rb +31 -0
- data/lib/laser/standard_library/set.rb +1348 -0
- data/lib/laser/standard_library/string.rb +666 -0
- data/lib/laser/standard_library/stringio.rb +2 -0
- data/lib/laser/standard_library/symbol.rb +125 -0
- data/lib/laser/standard_library/tsort.rb +242 -0
- data/lib/laser/support/acts_as_struct.rb +66 -0
- data/lib/laser/support/frequency.rb +55 -0
- data/lib/laser/support/inheritable_attributes.rb +145 -0
- data/lib/laser/support/module_extensions.rb +94 -0
- data/lib/laser/support/placeholder_object.rb +13 -0
- data/lib/laser/third_party/rgl/adjacency.rb +221 -0
- data/lib/laser/third_party/rgl/base.rb +228 -0
- data/lib/laser/third_party/rgl/bidirectional.rb +39 -0
- data/lib/laser/third_party/rgl/condensation.rb +47 -0
- data/lib/laser/third_party/rgl/connected_components.rb +138 -0
- data/lib/laser/third_party/rgl/control_flow.rb +170 -0
- data/lib/laser/third_party/rgl/depth_first_spanning_tree.rb +37 -0
- data/lib/laser/third_party/rgl/dominators.rb +124 -0
- data/lib/laser/third_party/rgl/dot.rb +93 -0
- data/lib/laser/third_party/rgl/graphxml.rb +51 -0
- data/lib/laser/third_party/rgl/implicit.rb +174 -0
- data/lib/laser/third_party/rgl/mutable.rb +117 -0
- data/lib/laser/third_party/rgl/rdot.rb +445 -0
- data/lib/laser/third_party/rgl/topsort.rb +72 -0
- data/lib/laser/third_party/rgl/transitivity.rb +180 -0
- data/lib/laser/third_party/rgl/traversal.rb +348 -0
- data/lib/laser/types/types.rb +433 -0
- data/lib/laser/version.rb +14 -0
- data/lib/laser/warning.rb +149 -0
- data/lib/laser/warning_sets/default.yml +13 -0
- data/lib/laser/warnings/assignment_in_condition.rb +20 -0
- data/lib/laser/warnings/comment_spacing.rb +31 -0
- data/lib/laser/warnings/extra_blank_lines.rb +30 -0
- data/lib/laser/warnings/extra_whitespace.rb +16 -0
- data/lib/laser/warnings/hash_symbol_18_warning.rb +63 -0
- data/lib/laser/warnings/hash_symbol_19_warning.rb +29 -0
- data/lib/laser/warnings/line_length.rb +115 -0
- data/lib/laser/warnings/misaligned_unindentation.rb +17 -0
- data/lib/laser/warnings/operator_spacing.rb +68 -0
- data/lib/laser/warnings/parens_on_declaration.rb +30 -0
- data/lib/laser/warnings/rescue_exception.rb +42 -0
- data/lib/laser/warnings/semicolon.rb +25 -0
- data/lib/laser/warnings/sexp_errors.rb +24 -0
- data/lib/laser/warnings/uncalled_method_warning.rb +7 -0
- data/lib/laser/warnings/useless_double_quotes.rb +38 -0
- data/spec/analysis_specs/annotations_spec.rb +47 -0
- data/spec/analysis_specs/annotations_specs/comment_attachment_spec.rb +68 -0
- data/spec/analysis_specs/annotations_specs/node_pointers_annotation_spec.rb +90 -0
- data/spec/analysis_specs/annotations_specs/runtime_annotation_spec.rb +135 -0
- data/spec/analysis_specs/annotations_specs/spec_helper.rb +33 -0
- data/spec/analysis_specs/argument_expansion_spec.rb +113 -0
- data/spec/analysis_specs/bindings_spec.rb +36 -0
- data/spec/analysis_specs/comment_spec.rb +93 -0
- data/spec/analysis_specs/control_flow_specs/cfg_instruction_spec.rb +111 -0
- data/spec/analysis_specs/control_flow_specs/constant_propagation_spec.rb +560 -0
- data/spec/analysis_specs/control_flow_specs/control_flow_graph_spec.rb +5 -0
- data/spec/analysis_specs/control_flow_specs/raise_properties_spec.rb +310 -0
- data/spec/analysis_specs/control_flow_specs/raise_type_inference_spec.rb +301 -0
- data/spec/analysis_specs/control_flow_specs/return_type_inference_spec.rb +431 -0
- data/spec/analysis_specs/control_flow_specs/simulation_spec.rb +158 -0
- data/spec/analysis_specs/control_flow_specs/spec_helper.rb +110 -0
- data/spec/analysis_specs/control_flow_specs/tuple_misuse_inference_spec.rb +125 -0
- data/spec/analysis_specs/control_flow_specs/unreachability_analysis_spec.rb +76 -0
- data/spec/analysis_specs/control_flow_specs/unused_variable_spec.rb +99 -0
- data/spec/analysis_specs/control_flow_specs/yield_properties_spec.rb +372 -0
- data/spec/analysis_specs/error_spec.rb +30 -0
- data/spec/analysis_specs/laser_class_spec.rb +322 -0
- data/spec/analysis_specs/lexical_analysis_spec.rb +184 -0
- data/spec/analysis_specs/protocol_registry_spec.rb +63 -0
- data/spec/analysis_specs/scope_annotation_spec.rb +1013 -0
- data/spec/analysis_specs/scope_spec.rb +126 -0
- data/spec/analysis_specs/sexp_analysis_spec.rb +30 -0
- data/spec/analysis_specs/sexp_extension_specs/constant_extraction_spec.rb +309 -0
- data/spec/analysis_specs/sexp_extension_specs/source_location_spec.rb +231 -0
- data/spec/analysis_specs/sexp_extension_specs/spec_helper.rb +1 -0
- data/spec/analysis_specs/sexp_extension_specs/type_inference_spec.rb +252 -0
- data/spec/analysis_specs/sexp_spec.rb +167 -0
- data/spec/analysis_specs/spec_helper.rb +27 -0
- data/spec/analysis_specs/unused_methods_spec.rb +65 -0
- data/spec/analysis_specs/visitor_spec.rb +64 -0
- data/spec/annotation_parser_specs/annotations_parser_spec.rb +89 -0
- data/spec/annotation_parser_specs/class_annotation_parser_spec.rb +120 -0
- data/spec/annotation_parser_specs/overload_parser_spec.rb +39 -0
- data/spec/annotation_parser_specs/parsers_spec.rb +14 -0
- data/spec/annotation_parser_specs/spec_helper.rb +1 -0
- data/spec/annotation_parser_specs/structural_parser_spec.rb +67 -0
- data/spec/laser_spec.rb +14 -0
- data/spec/rake_specs/spec_helper.rb +1 -0
- data/spec/rake_specs/task_spec.rb +67 -0
- data/spec/runner_spec.rb +207 -0
- data/spec/scanner_spec.rb +75 -0
- data/spec/spec_helper.rb +121 -0
- data/spec/standard_library/exceptions_spec.rb +19 -0
- data/spec/standard_library/globals_spec.rb +14 -0
- data/spec/standard_library/set_spec.rb +31 -0
- data/spec/standard_library/spec_helper.rb +1 -0
- data/spec/standard_library/standard_library_spec.rb +302 -0
- data/spec/support_specs/acts_as_struct_spec.rb +94 -0
- data/spec/support_specs/frequency_spec.rb +23 -0
- data/spec/support_specs/module_extensions_spec.rb +117 -0
- data/spec/support_specs/spec_helper.rb +1 -0
- data/spec/type_specs/spec_helper.rb +1 -0
- data/spec/type_specs/types_spec.rb +133 -0
- data/spec/warning_spec.rb +95 -0
- data/spec/warning_specs/assignment_in_condition_spec.rb +68 -0
- data/spec/warning_specs/comment_spacing_spec.rb +65 -0
- data/spec/warning_specs/extra_blank_lines_spec.rb +70 -0
- data/spec/warning_specs/extra_whitespace_spec.rb +33 -0
- data/spec/warning_specs/hash_symbol_18_warning_spec.rb +89 -0
- data/spec/warning_specs/hash_symbol_19_warning_spec.rb +63 -0
- data/spec/warning_specs/line_length_spec.rb +173 -0
- data/spec/warning_specs/misaligned_unindentation_spec.rb +35 -0
- data/spec/warning_specs/operator_spacing_spec.rb +104 -0
- data/spec/warning_specs/parens_on_declaration_spec.rb +57 -0
- data/spec/warning_specs/rescue_exception_spec.rb +105 -0
- data/spec/warning_specs/semicolon_spec.rb +58 -0
- data/spec/warning_specs/spec_helper.rb +1 -0
- data/spec/warning_specs/useless_double_quotes_spec.rb +74 -0
- data/status_reports/2010/12/2010-12-14.md +163 -0
- data/status_reports/2010/12/2010-12-23.md +298 -0
- data/status_reports/2010/12/2010-12-24.md +6 -0
- data/test/third_party_tests/rgl_tests/TestComponents.rb +65 -0
- data/test/third_party_tests/rgl_tests/TestCycles.rb +61 -0
- data/test/third_party_tests/rgl_tests/TestDirectedGraph.rb +125 -0
- data/test/third_party_tests/rgl_tests/TestDot.rb +18 -0
- data/test/third_party_tests/rgl_tests/TestEdge.rb +34 -0
- data/test/third_party_tests/rgl_tests/TestGraph.rb +71 -0
- data/test/third_party_tests/rgl_tests/TestGraphXML.rb +57 -0
- data/test/third_party_tests/rgl_tests/TestImplicit.rb +52 -0
- data/test/third_party_tests/rgl_tests/TestRdot.rb +863 -0
- data/test/third_party_tests/rgl_tests/TestTransitivity.rb +129 -0
- data/test/third_party_tests/rgl_tests/TestTraversal.rb +220 -0
- data/test/third_party_tests/rgl_tests/TestUnDirectedGraph.rb +102 -0
- data/test/third_party_tests/rgl_tests/examples/north/Graph.log +128 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.0.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.1.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.11.graphml +31 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.12.graphml +27 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.13.graphml +27 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.14.graphml +27 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.15.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.16.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.17.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.19.graphml +37 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.2.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.20.graphml +38 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.22.graphml +43 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.24.graphml +30 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.25.graphml +45 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.27.graphml +38 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.28.graphml +30 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.29.graphml +38 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.3.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.30.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.31.graphml +42 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.34.graphml +42 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.37.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.38.graphml +38 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.39.graphml +36 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.4.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.40.graphml +37 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.41.graphml +37 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.42.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.45.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.46.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.5.graphml +31 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.50.graphml +30 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.56.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.57.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.58.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.6.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.60.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.61.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.62.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.68.graphml +30 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.69.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.7.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.70.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.71.graphml +27 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.72.graphml +28 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.74.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.75.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.78.graphml +27 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.79.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.8.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.80.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.82.graphml +35 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.83.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.85.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.86.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.88.graphml +37 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.89.graphml +29 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.9.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.90.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.91.graphml +31 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.92.graphml +26 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.93.graphml +32 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.10.94.graphml +34 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.12.8.graphml +40 -0
- data/test/third_party_tests/rgl_tests/examples/north/g.14.9.graphml +36 -0
- data/test/third_party_tests/rgl_tests/test_helper.rb +7 -0
- data/test/third_party_tests/test_inheritable_attributes.rb +187 -0
- metadata +470 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
%x(rake build_parsers)
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
5
|
+
|
6
|
+
require 'laser'
|
7
|
+
require 'rspec'
|
8
|
+
require 'rspec/autorun'
|
9
|
+
require 'stringio'
|
10
|
+
|
11
|
+
include Laser
|
12
|
+
module Laser
|
13
|
+
remove_const(:TESTS_ACTIVATED)
|
14
|
+
const_set(:TESTS_ACTIVATED, true)
|
15
|
+
end
|
16
|
+
|
17
|
+
include Laser::Analysis
|
18
|
+
# Turn off method-is-used- checking until we explicitly test
|
19
|
+
# it - it just muddies up stuff
|
20
|
+
LaserMethod.default_dispatched = true
|
21
|
+
|
22
|
+
RSpec::Matchers.define :equal_type do |type|
|
23
|
+
match do |orig|
|
24
|
+
Types::subtype?(orig, type) || begin
|
25
|
+
orig.possible_classes.all? { |klass|
|
26
|
+
type.possible_classes.any? { |potential_super|
|
27
|
+
klass <= potential_super
|
28
|
+
}
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Matchers.define :see_var do |name|
|
35
|
+
match do |node|
|
36
|
+
node.scope.sees_var?(name)
|
37
|
+
end
|
38
|
+
|
39
|
+
failure_message_for_should do |node|
|
40
|
+
"scope #{node.scope.inspect} should have had variable #{name}, but it didn't."
|
41
|
+
end
|
42
|
+
|
43
|
+
failure_message_for_should_not do |node|
|
44
|
+
"scope #{node.scope.inspect} should have not been able to see variable #{name}, but it can."
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
RSpec::Matchers.define :parse_to do |output|
|
49
|
+
match do |actual|
|
50
|
+
@result = Parsers::AnnotationParser.new.parse(actual, root: :type)
|
51
|
+
@result && (@result.type == output)
|
52
|
+
end
|
53
|
+
|
54
|
+
failure_message_for_should do |actual|
|
55
|
+
"expected '#{actual}' to parse to #{output.inspect}, not #{@result.type.inspect}"
|
56
|
+
end
|
57
|
+
|
58
|
+
failure_message_for_should_not do |actual|
|
59
|
+
"expected '#{actual}' to not parse to #{output.inspect}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
RSpec::Matchers.define :correct_to do |input, output, *args|
|
64
|
+
match do |actual|
|
65
|
+
actual.new('(stdin)', input, *args).fix == output
|
66
|
+
end
|
67
|
+
|
68
|
+
failure_message_for_should do |actual|
|
69
|
+
"expected '#{input}' to correct to #{output.inspect}"
|
70
|
+
end
|
71
|
+
|
72
|
+
failure_message_for_should_not do |actual|
|
73
|
+
"expected '#{input}' to not correct to #{output.inspect}"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
RSpec::Matchers.define :warn do |input, *args|
|
78
|
+
match do |actual|
|
79
|
+
result = actual.new('(stdin)', input, *args).match?
|
80
|
+
result && result != [] # empty list is also failure to find any warnings
|
81
|
+
end
|
82
|
+
|
83
|
+
failure_message_for_should do |actual|
|
84
|
+
"expected '#{actual}' to match #{input.inspect}"
|
85
|
+
end
|
86
|
+
|
87
|
+
failure_message_for_should_not do |actual|
|
88
|
+
"expected '#{actual}' to not match #{input.inspect}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
RSpec.configure do |config|
|
93
|
+
config.filter_run focus: true
|
94
|
+
config.run_all_when_everything_filtered = true
|
95
|
+
end
|
96
|
+
|
97
|
+
def many_mocks(n)
|
98
|
+
([nil] * n).fill { mock }
|
99
|
+
end
|
100
|
+
|
101
|
+
def with_examples(*args)
|
102
|
+
args.each do |arg|
|
103
|
+
yield arg
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def swizzling_io
|
108
|
+
old_stdout, $stdout = $stdout, StringIO.new
|
109
|
+
yield
|
110
|
+
return $stdout.string
|
111
|
+
ensure
|
112
|
+
$stdout = old_stdout
|
113
|
+
end
|
114
|
+
|
115
|
+
def swizzling_stdin
|
116
|
+
old_stdin, $stdin = $stdin, StringIO.new
|
117
|
+
yield $stdin
|
118
|
+
return $stdin.string
|
119
|
+
ensure
|
120
|
+
$stdin = old_stdin
|
121
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe 'standard library exceptions' do
|
4
|
+
%w(Exception StandardError IOError TypeError ScriptError SystemExit
|
5
|
+
SignalException Interrupt ArgumentError IndexError KeyError
|
6
|
+
RangeError SyntaxError LoadError NotImplementedError NameError
|
7
|
+
NoMethodError RuntimeError SecurityError NoMemoryError EncodingError
|
8
|
+
SystemCallError ZeroDivisionError FloatDomainError RegexpError EOFError
|
9
|
+
LocalJumpError SystemStackError).each do |error|
|
10
|
+
it "should define a constant named #{error} at the top level" do
|
11
|
+
ClassRegistry['Object'].const_get(error).should be_a(LaserClass)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should define #{error} as a class with Exception in its superset" do
|
15
|
+
klass = ClassRegistry['Object'].const_get(error)
|
16
|
+
klass.superset.should include(ClassRegistry['Exception'])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Scope::GlobalScope do
|
4
|
+
describe '$:' do
|
5
|
+
it 'should be an array' do
|
6
|
+
Scope::GlobalScope.lookup('$:').value.should be_a(Array)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should contain the path to standard_library' do
|
10
|
+
Scope::GlobalScope.lookup('$:').value.should include(
|
11
|
+
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'laser', 'standard_library')))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe 'the Set module' do
|
4
|
+
before(:all) do
|
5
|
+
@tree = annotate_all('require "set"')
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should have no errors from the inclusion' do
|
9
|
+
@tree.all_errors.should be_empty
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should load fine' do
|
13
|
+
ClassRegistry['Set'].should_not be_nil
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should have a class method .[]' do
|
17
|
+
method = ClassRegistry['Set'].singleton_class.instance_method(:[])
|
18
|
+
method.should_not be_nil
|
19
|
+
method.arity.should == Arity::ANY
|
20
|
+
method.arguments.size.should == 1
|
21
|
+
end
|
22
|
+
|
23
|
+
%w(& + - << == ^ add add? classify clear collect! delete delete? delete_if difference divide
|
24
|
+
each empty? flatten flatten! flatten_merge include? initialize_copy inspect intersection
|
25
|
+
length map! member? merge proper_subset? proper_superset? reject! replace size
|
26
|
+
subset? subtract superset? to_a union |).each do |method|
|
27
|
+
it "should have an instance method named #{method}" do
|
28
|
+
ClassRegistry['Set'].instance_method(method).should_not be_nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative '../spec_helper'
|
@@ -0,0 +1,302 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe 'the automatically analyzed Ruby Standard Library' do
|
4
|
+
shared_examples_for 'a module' do
|
5
|
+
it 'should be a module' do
|
6
|
+
@module.class.should == LaserModule
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
shared_examples_for 'a class' do
|
11
|
+
it 'should be a class' do
|
12
|
+
@class.class.should == LaserClass
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
shared_examples_for 'a singleton class' do
|
17
|
+
it 'should be a singleton class' do
|
18
|
+
@class.class.should == LaserSingletonClass
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have a single object with an equal singleton class' do
|
22
|
+
@class.get_instance.singleton_class.should be @class
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should have a single object whose class equals the singleton class' do
|
26
|
+
@class.get_instance.klass.should be @class
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'RUBY_VERSION' do
|
31
|
+
it 'should be 1.9.2' do
|
32
|
+
ClassRegistry['Object'].const_get('RUBY_VERSION').should == "1.9.2"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'Kernel' do
|
37
|
+
before do
|
38
|
+
@module = ClassRegistry['Kernel']
|
39
|
+
end
|
40
|
+
|
41
|
+
it_should_behave_like 'a module'
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'BasicObject' do
|
45
|
+
before do
|
46
|
+
@class = ClassRegistry['BasicObject']
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should have no superclass' do
|
50
|
+
@class.superclass.should == nil
|
51
|
+
end
|
52
|
+
|
53
|
+
%w(! == != equal? __send__ instance_eval instance_exec).each do |method|
|
54
|
+
sym = method.to_sym
|
55
|
+
it "should define the instance method #{method}" do
|
56
|
+
@class.instance_method(sym).should_not be_nil
|
57
|
+
end
|
58
|
+
it "should define the instance method #{method} as public" do
|
59
|
+
@class.visibility_table[sym].should be :public
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
%w(initialize method_missing singleton_method_added singleton_method_removed
|
64
|
+
singleton_method_undefined).each do |method|
|
65
|
+
sym = method.to_sym
|
66
|
+
it "should define the instance method #{method}" do
|
67
|
+
@class.instance_method(sym).should_not be_nil
|
68
|
+
end
|
69
|
+
it "should define the instance method #{method} as private" do
|
70
|
+
@class.visibility_table[sym].should be :private
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
it_should_behave_like 'a class'
|
75
|
+
end
|
76
|
+
|
77
|
+
describe 'Object' do
|
78
|
+
before do
|
79
|
+
@class = ClassRegistry['Object']
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should be a subclass of BasicObject' do
|
83
|
+
@class.superclass.should == ClassRegistry['BasicObject']
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should include the Kernel module' do
|
87
|
+
@class.included_modules.should include(ClassRegistry['Kernel'])
|
88
|
+
end
|
89
|
+
|
90
|
+
it_should_behave_like 'a class'
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'NilClass' do
|
94
|
+
before do
|
95
|
+
@class = ClassRegistry['NilClass']
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should be a subclass of Object' do
|
99
|
+
@class.superclass.should == ClassRegistry['Object']
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should have an instance named nil' do
|
103
|
+
@class.get_instance.name.should == 'nil'
|
104
|
+
end
|
105
|
+
|
106
|
+
it_should_behave_like 'a singleton class'
|
107
|
+
end
|
108
|
+
|
109
|
+
describe 'TrueClass' do
|
110
|
+
before do
|
111
|
+
@class = ClassRegistry['TrueClass']
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should be a subclass of Object' do
|
115
|
+
@class.superclass.should == ClassRegistry['Object']
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should have an instance named true' do
|
119
|
+
@class.get_instance.name.should == 'true'
|
120
|
+
end
|
121
|
+
|
122
|
+
it_should_behave_like 'a singleton class'
|
123
|
+
end
|
124
|
+
|
125
|
+
describe 'FalseClass' do
|
126
|
+
before do
|
127
|
+
@class = ClassRegistry['FalseClass']
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should be a subclass of Object' do
|
131
|
+
@class.superclass.should == ClassRegistry['Object']
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should have an instance named false' do
|
135
|
+
@class.get_instance.name.should == 'false'
|
136
|
+
end
|
137
|
+
|
138
|
+
it_should_behave_like 'a singleton class'
|
139
|
+
end
|
140
|
+
|
141
|
+
describe 'Hash' do
|
142
|
+
before do
|
143
|
+
@class = ClassRegistry['Hash']
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should be a subclass of Object' do
|
147
|
+
@class.superclass.should == ClassRegistry['Object']
|
148
|
+
end
|
149
|
+
|
150
|
+
it_should_behave_like 'a class'
|
151
|
+
end
|
152
|
+
|
153
|
+
describe 'Array' do
|
154
|
+
before do
|
155
|
+
@class = ClassRegistry['Array']
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'should be a subclass of Object' do
|
159
|
+
@class.superclass.should == ClassRegistry['Object']
|
160
|
+
end
|
161
|
+
|
162
|
+
it_should_behave_like 'a class'
|
163
|
+
end
|
164
|
+
|
165
|
+
describe 'Range' do
|
166
|
+
before do
|
167
|
+
@class = ClassRegistry['Range']
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'should be a subclass of Object' do
|
171
|
+
@class.superclass.should == ClassRegistry['Object']
|
172
|
+
end
|
173
|
+
|
174
|
+
it_should_behave_like 'a class'
|
175
|
+
end
|
176
|
+
|
177
|
+
describe 'Proc' do
|
178
|
+
before do
|
179
|
+
@class = ClassRegistry['Proc']
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'should be a subclass of Object' do
|
183
|
+
@class.superclass.should == ClassRegistry['Object']
|
184
|
+
end
|
185
|
+
|
186
|
+
it_should_behave_like 'a class'
|
187
|
+
end
|
188
|
+
|
189
|
+
describe 'String' do
|
190
|
+
before do
|
191
|
+
@class = ClassRegistry['String']
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'should be a subclass of Object' do
|
195
|
+
@class.superclass.should == ClassRegistry['Object']
|
196
|
+
end
|
197
|
+
|
198
|
+
it_should_behave_like 'a class'
|
199
|
+
end
|
200
|
+
|
201
|
+
describe 'Symbol' do
|
202
|
+
before do
|
203
|
+
@class = ClassRegistry['Symbol']
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'should be a subclass of Object' do
|
207
|
+
@class.superclass.should == ClassRegistry['Object']
|
208
|
+
end
|
209
|
+
|
210
|
+
it_should_behave_like 'a class'
|
211
|
+
end
|
212
|
+
|
213
|
+
describe 'Regexp' do
|
214
|
+
before do
|
215
|
+
@class = ClassRegistry['Regexp']
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'should be a subclass of Object' do
|
219
|
+
@class.superclass.should == ClassRegistry['Object']
|
220
|
+
end
|
221
|
+
|
222
|
+
it_should_behave_like 'a class'
|
223
|
+
end
|
224
|
+
|
225
|
+
describe 'Encoding' do
|
226
|
+
before do
|
227
|
+
@class = ClassRegistry['Encoding']
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'should be a subclass of Object' do
|
231
|
+
@class.superclass.should == ClassRegistry['Object']
|
232
|
+
end
|
233
|
+
|
234
|
+
it_should_behave_like 'a class'
|
235
|
+
end
|
236
|
+
|
237
|
+
describe 'Numeric' do
|
238
|
+
before do
|
239
|
+
@class = ClassRegistry['Numeric']
|
240
|
+
end
|
241
|
+
|
242
|
+
it 'should be a subclass of Object' do
|
243
|
+
@class.superclass.should == ClassRegistry['Object']
|
244
|
+
end
|
245
|
+
|
246
|
+
it_should_behave_like 'a class'
|
247
|
+
end
|
248
|
+
|
249
|
+
describe 'Integer' do
|
250
|
+
before do
|
251
|
+
@class = ClassRegistry['Integer']
|
252
|
+
end
|
253
|
+
|
254
|
+
it 'should be a subclass of Numeric' do
|
255
|
+
@class.superclass.should == ClassRegistry['Numeric']
|
256
|
+
end
|
257
|
+
|
258
|
+
it_should_behave_like 'a class'
|
259
|
+
end
|
260
|
+
|
261
|
+
describe 'Fixnum' do
|
262
|
+
before do
|
263
|
+
@class = ClassRegistry['Fixnum']
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'should be a subclass of Integer' do
|
267
|
+
@class.superclass.should == ClassRegistry['Integer']
|
268
|
+
end
|
269
|
+
|
270
|
+
describe '#==' do
|
271
|
+
it 'should be pure' do
|
272
|
+
@class.instance_method(:==).pure.should be true
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
it_should_behave_like 'a class'
|
277
|
+
end
|
278
|
+
|
279
|
+
describe 'Bignum' do
|
280
|
+
before do
|
281
|
+
@class = ClassRegistry['Bignum']
|
282
|
+
end
|
283
|
+
|
284
|
+
it 'should be a subclass of Integer' do
|
285
|
+
@class.superclass.should == ClassRegistry['Integer']
|
286
|
+
end
|
287
|
+
|
288
|
+
it_should_behave_like 'a class'
|
289
|
+
end
|
290
|
+
|
291
|
+
describe 'Float' do
|
292
|
+
before do
|
293
|
+
@class = ClassRegistry['Float']
|
294
|
+
end
|
295
|
+
|
296
|
+
it 'should be a subclass of Numeric' do
|
297
|
+
@class.superclass.should == ClassRegistry['Numeric']
|
298
|
+
end
|
299
|
+
|
300
|
+
it_should_behave_like 'a class'
|
301
|
+
end
|
302
|
+
end
|