Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the program method if the source of the script file doesn't match the source of all program methods in the file #324

Merged
merged 5 commits into from
Oct 31, 2021

Conversation

ono-max
Copy link
Member

@ono-max ono-max commented Oct 10, 2021

The current test generator adds just the scenario method when the generated file already exists. However, users want to add the program method if the source of the script file doesn't match the source of all program methods. This PR fixes it.

Before

    def test_1635256878
      debug_code(program) do
        type 's'
        assert_line_num 2
        assert_line_text([
          /\[1, 10\] in .*/,
          /     1\| module Foo/,
          /=>   2\|   class Bar/,
          /     3\|     def self\.a/,
          /     4\|       p 'hoge'/,
          /     5\|       "hello"/,
          /     6\|     end/,
          /     7\|   end/,
          /     8\|   Bar\.a/,
          /     9\|   bar = Bar\.new/,
          /    10\| end/,
          /=>\#0\t<module:Foo> at .*/,
          /  \#1\t<main> at .*/
        ])
        type 'q!'
      end
    end

After

class FooTest1635256743 < TestCase
    def program
      <<~RUBY
         1| module Foo
         2|   class Bar
         3|     def self.a
         4|       p 'hoge'
         5|       "hello"
         6|     end
         7|   end
         8|   Bar.a
         9|   bar = Bar.new
        10| end
      RUBY
    end
    
    def test_1635256743
      debug_code(program) do
        type 's'
        assert_line_num 2
        assert_line_text([
          /\[1, 10\] in .*/,
          /     1\| module Foo/,
          /=>   2\|   class Bar/,
          /     3\|     def self\.a/,
          /     4\|       p 'hoge'/,
          /     5\|       "hello"/,
          /     6\|     end/,
          /     7\|   end/,
          /     8\|   Bar\.a/,
          /     9\|   bar = Bar\.new/,
          /    10\| end/,
          /=>\#0\t<module:Foo> at .*/,
          /  \#1\t<main> at .*/
        ])
        type 'q!'
      end
    end
  end

@ono-max ono-max force-pushed the improve-test-builder branch 2 times, most recently from c805265 to d23c0dc Compare October 10, 2021 12:30
@ono-max ono-max changed the title Add the program method if the source of the script file doesn't match the source of all program methods in the file Add the program method if the source of the script file doesn't match the source of all program methods in the file Oct 10, 2021
…tch the source of all `program` methods in the file
@ko1 ko1 merged commit 30e2a8e into ruby:master Oct 31, 2021
@ono-max ono-max deleted the improve-test-builder branch October 31, 2021 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants