Thank you for your interest in improving TypeProf! When reporting a bug or proposing a feature, including a scenario file is very helpful (but not mandatory).
A scenario file describes TypeProf's behavior — the input code and the expected type inference result. You can find many examples in the scenario/ directory.
A minimal scenario file has two sections: ## update (input code) and ## assert (expected type signatures in RBS syntax).
## update
def foo(n)
n.to_s
end
foo(42)
## assert
class Object
def foo: (Integer) -> String
endYou can include multiple ## update / ## assert pairs to test how TypeProf handles code changes:
## update
def foo = "symbol#{ 42 }"
## assert
class Object
def foo: -> String
end
## update
def foo = :"symbol#{ 42 }"
## assert
class Object
def foo: -> Symbol
endUse ## diagnostics to verify that TypeProf reports type errors at the expected locations:
## update
def foo(x)
x
end
foo(1, 2)
## diagnostics
(5,0)-(5,3): wrong number of arguments (2 for 1)Run a single scenario file:
$ ruby tool/scenario_runner.rb path/to/your_scenario.rbRun all tests:
$ bundle exec rake test- Create a scenario file that reproduces the issue.
- Run it with
ruby tool/scenario_runner.rb your_scenario.rbto confirm the problem. - Open an issue and include:
- Your TypeProf version (
typeprof --version) - The scenario file content
- What you expected vs. what actually happened
- Your TypeProf version (