diff --git a/test/blocks_test.rb b/test/blocks_test.rb deleted file mode 100644 index 6e2d1f6..0000000 --- a/test/blocks_test.rb +++ /dev/null @@ -1,133 +0,0 @@ -# frozen_string_literal: true - -require 'test_helper' - -class BlocksTest < Minitest::Test - def setup - @analyzer = MethodRay::Analyzer.new('test.rb') - end - - # Basic block with single parameter - code parses correctly - def test_block_with_single_parameter - code = <<~RUBY - items = [1, 2, 3] - items.each { |x| x } - RUBY - result = @analyzer.infer_types(code) - # Outer variable should be tracked - assert_includes result, 'items: Array' - end - - # Block with multiple parameters - def test_block_with_multiple_parameters - code = <<~RUBY - data = {a: 1, b: 2} - data.each { |k, v| k } - RUBY - result = @analyzer.infer_types(code) - assert_includes result, 'data: Hash' - end - - # do...end syntax - def test_block_do_end_syntax - code = <<~RUBY - items = [1, 2, 3] - items.each do |item| - item - end - RUBY - result = @analyzer.infer_types(code) - assert_includes result, 'items: Array' - end - - # Block accessing outer scope variable - def test_block_accesses_outer_scope - code = <<~RUBY - prefix = "Item: " - items = [1, 2, 3] - items.each { |x| prefix.upcase } - RUBY - result = @analyzer.infer_types(code) - assert_includes result, 'prefix: String' - assert_includes result, 'items: Array' - end - - # map with block - def test_map_with_block - code = <<~RUBY - items = [1, 2, 3] - items.map { |x| x } - RUBY - result = @analyzer.infer_types(code) - assert_includes result, 'items: Array' - end - - # select with block - def test_select_with_block - code = <<~RUBY - items = [1, 2, 3] - items.select { |x| x } - RUBY - result = @analyzer.infer_types(code) - assert_includes result, 'items: Array' - end - - # Nested blocks - def test_nested_blocks - code = <<~RUBY - outer = [[1, 2], [3, 4]] - outer.each do |arr| - arr.each { |x| x } - end - RUBY - result = @analyzer.infer_types(code) - assert_includes result, 'outer: Array' - end - - # Block inside method definition - def test_block_inside_method - code = <<~RUBY - class Processor - def process - items = [1, 2, 3] - items.each { |item| item } - end - end - RUBY - result = @analyzer.infer_types(code) - # Should parse without error - refute_nil result - end - - # Block with optional parameter and default value - def test_block_with_optional_parameter - code = <<~RUBY - items = [1, 2, 3] - items.each { |x = "default"| x.upcase } - RUBY - result = @analyzer.infer_types(code) - assert_includes result, 'items: Array' - end - - # Block with rest parameter - def test_block_with_rest_parameter - code = <<~RUBY - items = [1, 2, 3] - items.each { |*args| args.first } - RUBY - result = @analyzer.infer_types(code) - assert_includes result, 'items: Array' - end - - # Outer variable modified before block - def test_outer_variable_before_block - code = <<~RUBY - message = "Hello" - items = [1, 2, 3] - items.each { |x| message } - RUBY - result = @analyzer.infer_types(code) - assert_includes result, 'message: String' - assert_includes result, 'items: Array' - end -end diff --git a/test/check_test.rb b/test/integration_test.rb similarity index 100% rename from test/check_test.rb rename to test/integration_test.rb diff --git a/test/methodray_test.rb b/test/methodray_test.rb deleted file mode 100644 index 84bdaba..0000000 --- a/test/methodray_test.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -require 'test_helper' - -class MethodRayTest < Minitest::Test - def test_that_it_has_a_version_number - refute_nil ::MethodRay::VERSION - end - - def test_analyzer_can_be_created - analyzer = MethodRay::Analyzer.new('.') - assert_instance_of MethodRay::Analyzer, analyzer - end - - def test_analyzer_version_method - analyzer = MethodRay::Analyzer.new('.') - assert_equal '0.1.0', analyzer.version - end - - def test_infer_types_string_literal - analyzer = MethodRay::Analyzer.new('test.rb') - result = analyzer.infer_types('x = "hello"') - assert_includes result, 'x: String' - end - - def test_infer_types_integer_literal - analyzer = MethodRay::Analyzer.new('test.rb') - result = analyzer.infer_types('x = 42') - assert_includes result, 'x: Integer' - end - - def test_infer_types_method_chain - analyzer = MethodRay::Analyzer.new('test.rb') - result = analyzer.infer_types('x = "hello".upcase') - assert_includes result, 'x: String' - end - - def test_infer_types_multiple_vars - analyzer = MethodRay::Analyzer.new('test.rb') - result = analyzer.infer_types(<<~RUBY) - x = "hello" - y = 123 - RUBY - assert_includes result, 'x: String' - assert_includes result, 'y: Integer' - end -end diff --git a/test/test_chain.rb b/test/test_chain.rb deleted file mode 100644 index 835c633..0000000 --- a/test/test_chain.rb +++ /dev/null @@ -1,6 +0,0 @@ -x = "hello" -y = x.upcase -z = y.downcase -a = z.length -b = a.to_s -c = b.upcase diff --git a/test/test_error.rb b/test/test_error.rb deleted file mode 100644 index 5814b11..0000000 --- a/test/test_error.rb +++ /dev/null @@ -1,2 +0,0 @@ -x = 1 -y = x.upcase # Error: Integer#upcase is undefined diff --git a/test/test_example.rb b/test/test_example.rb deleted file mode 100644 index 21d2095..0000000 --- a/test/test_example.rb +++ /dev/null @@ -1,3 +0,0 @@ -x = "hello" -y = x.upcase -z = y.length diff --git a/test/test_helper.rb b/test/test_helper.rb index 6cdf7a1..1aa7206 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -12,7 +12,7 @@ module CLITestHelper private def run_check(source) - file = Tempfile.new(['check_test', '.rb']) + file = Tempfile.new(['integration_test', '.rb']) file.write(source) file.close diff --git a/test/test_line2.rb b/test/test_line2.rb deleted file mode 100644 index a03ddf7..0000000 --- a/test/test_line2.rb +++ /dev/null @@ -1,5 +0,0 @@ -a = "hello" -b = a.upcase -c = b.length -d = 42 -e = d.foo diff --git a/test/test_multiple_errors.rb b/test/test_multiple_errors.rb deleted file mode 100644 index 3cfa101..0000000 --- a/test/test_multiple_errors.rb +++ /dev/null @@ -1,8 +0,0 @@ -x = 1 -y = x.upcase # Error: Integer#upcase - -a = "hello" -b = a.unknown_method # Error: String#unknown_method - -c = 42 -d = c.foo # Error: Integer#foo diff --git a/test/test_simple_error.rb b/test/test_simple_error.rb deleted file mode 100644 index 8695fb2..0000000 --- a/test/test_simple_error.rb +++ /dev/null @@ -1,2 +0,0 @@ -x = 1 -y = x.upcase diff --git a/test/test_watch.rb b/test/test_watch.rb deleted file mode 100644 index dce0251..0000000 --- a/test/test_watch.rb +++ /dev/null @@ -1,2 +0,0 @@ -x = "hello" -y = x.upcase