Skip to content

feat: add String#reverse for TryRuby compatibility (#524 Phase1-1)#525

Merged
takaokouji merged 1 commit into
developfrom
feat/tryruby-compat
Apr 17, 2026
Merged

feat: add String#reverse for TryRuby compatibility (#524 Phase1-1)#525
takaokouji merged 1 commit into
developfrom
feat/tryruby-compat

Conversation

@takaokouji
Copy link
Copy Markdown

Summary

  • String#reverse を smalrubyRuby_stringMethodR ブロックとして登録(コンバーター + ジェネレーター + VM 実行ロジック)
  • 引数なしメソッドに対応するため、ジェネレーターで block.inputs.ARG1 の有無を判定して括弧なし出力(str.reverse)を生成

Changes

  • packages/scratch-gui/src/lib/ruby-to-blocks-converter/smalruby-ruby.js.reverse コンバーター登録
  • packages/scratch-gui/src/lib/ruby-generator/smalruby-ruby.js — 引数なしメソッドの括弧なし生成
  • packages/scratch-vm/src/extensions/smalruby_ruby/index.js — VM 側 argumentsByMethod + メニュー + 実行ロジック追加
  • テスト追加: コンバーター 3 tests + ジェネレーター 1 test

Test Coverage

  • test/unit/lib/ruby-to-blocks-converter/smalruby-ruby.test.js — reverse の変換テスト
  • test/unit/lib/ruby-generator/smalruby-ruby.test.js — reverse の生成テスト
  • 既存テストの mock ブロックに inputs プロパティを追加(引数有無判定の影響)

Related Issues

Refs #524 (Phase 1 #1)

Register String#reverse as a smalrubyRuby_stringMethodR block
(0 args). Update the generator to emit `str.reverse` without
parentheses when no ARG1 input exists.

Refs #524

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

🚀 Preview deployed: https://smalruby.jp/smalruby3-editor/feat/tryruby-compat/

@takaokouji takaokouji merged commit 13b85af into develop Apr 17, 2026
9 checks passed
@takaokouji takaokouji deleted the feat/tryruby-compat branch April 17, 2026 11:57
github-actions Bot pushed a commit that referenced this pull request Apr 17, 2026
…compat

feat: add String#reverse for TryRuby compatibility (#524 Phase1-1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant