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

BCDice: ロール結果のインスタンス変数の未初期化 #155

Closed
ochaochaocha3 opened this issue Apr 12, 2020 · 0 comments · Fixed by #159
Closed

BCDice: ロール結果のインスタンス変数の未初期化 #155

ochaochaocha3 opened this issue Apr 12, 2020 · 0 comments · Fixed by #159
Labels
bug バグってる!

Comments

@ochaochaocha3
Copy link
Member

ochaochaocha3 commented Apr 12, 2020

/src/test/test_d66_table.rb に実装されているテストの実行時に、ロール結果のインスタンス変数の未初期化が原因の警告が出ます。

/src/bcdiceCore.rb:1018: warning: instance variable @rand_results not initialized
/src/bcdiceCore.rb:1074: warning: instance variable @detailed_rand_results not initialized

このテストのように、コマンドを呼ぶ前に BCDice#setCollectRandResult を呼ぶのは忘れやすいです。例えば、BCDiceクラスのコンストラクタで setCollectRandResult(true) を呼ぶのが対策となります。

@ochaochaocha3 ochaochaocha3 added the bug バグってる! label Apr 12, 2020
ysakasin added a commit that referenced this issue Apr 20, 2020
ysakasin added a commit that referenced this issue Apr 21, 2020
* Set initial value of rand_results

Fix #155

* Fix #setCollectRandResult

Array#clearだと、外部から参照された配列の中身も丸ごと消してしまうので、元の挙動の通り空配列で初期化する
ysakasin added a commit that referenced this issue Aug 30, 2020
* Set initial value of rand_results

Fix #155

* Fix #setCollectRandResult

Array#clearだと、外部から参照された配列の中身も丸ごと消してしまうので、元の挙動の通り空配列で初期化する
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug バグってる!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant