Skip to content

Commit

Permalink
Make the test suite compatible with --enable-frozen-string-literal
Browse files Browse the repository at this point in the history
Ref: https://bugs.ruby-lang.org/issues/20205
Ref: voxpupuli/json-schema#508

Since `typeprof` is tested as part of ruby-core CI, it needs to be compatible
with the `--enable-frozen-string-literal` option.
  • Loading branch information
byroot committed Mar 18, 2024
1 parent 73f4c47 commit df1e8b7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
fail-fast: false
matrix:
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
include:
- ruby-version: ruby
rubyopt: "--enable-frozen-string-literal"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -35,5 +38,5 @@ jobs:
- run: bundle exec typeprof --version
- name: Run the test suite
run: |
bundle exec rake TESTOPT=-v
bundle exec rake TESTOPT=-v RUBYOPT="${{ matrix.rubyopt }}"
if: ${{ !startsWith(matrix.ruby, 'truffle') }}
4 changes: 2 additions & 2 deletions lib/typeprof/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ class Signature
include Utils::StructuralEquality

def screen_name(iseq, scratch)
fargs_str = "("
fargs_str = +"("
sig_help = {}
add_farg = -> farg, name, help: false, key: sig_help.size do
name = "`#{ name }`" if RBS::Parser::KEYWORDS.key?(name.to_s)
Expand Down Expand Up @@ -917,7 +917,7 @@ def screen_name(iseq, scratch)

fargs_str << ")"

fargs_str = "" if fargs_str == "()"
fargs_str = +"" if fargs_str == "()"

# Dirty Hack: Stop the iteration at most once!
# I'll remove this hack if RBS removes the limitation of nesting blocks
Expand Down
6 changes: 3 additions & 3 deletions test/typeprof/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CLITest < Test::Unit::TestCase
rb_file = File.join(__dir__, "../../smoke/simple.rb")
rb_files = [rb_file, rb_file]
rbs_files = []
output = StringIO.new("")
output = StringIO.new(+"")
options = {}
options[:show_untyped] = true
options[:show_errors] = true
Expand Down Expand Up @@ -37,7 +37,7 @@ def foo: (Integer n) -> String
rb_file = File.join(__dir__, "../../smoke/any1.rb")
rb_files = [rb_file]
rbs_files = []
output = StringIO.new("")
output = StringIO.new(+"")
options = {}
options[:exclude_untyped] = true
options[:show_untyped] = true
Expand Down Expand Up @@ -67,7 +67,7 @@ class Object
rb_file = File.join(__dir__, "../../smoke/simple.rb")
rb_files = [rb_file]
rbs_files = [["test.rbs", "class Bar < Foo\nend"]]
output = StringIO.new("")
output = StringIO.new(+"")
options = {}
options[:show_untyped] = true
options[:show_errors] = true
Expand Down
2 changes: 1 addition & 1 deletion test/typeprof/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def run(gem_rbs_features: [], **options)

rb_files = [@name]
rbs_files = [@rbs_path].compact
output = StringIO.new("")
output = StringIO.new(+"")
options[:show_untyped] = true unless options.key?(:show_untyped)
options[:show_errors] = true unless options.key?(:show_errors)
options[:show_indicator] = false unless options.key?(:show_indicator)
Expand Down

0 comments on commit df1e8b7

Please sign in to comment.