Skip to content

math/big: fix the bug of testShiftFunc in arith_test.go#14

Open
SparrowLii wants to merge 6 commits intoMabinGo:masterfrom
SparrowLii:Sparrowlii_0824
Open

math/big: fix the bug of testShiftFunc in arith_test.go#14
SparrowLii wants to merge 6 commits intoMabinGo:masterfrom
SparrowLii:Sparrowlii_0824

Conversation

@SparrowLii
Copy link
Copy Markdown

math/big: fix the bug of testShiftFunc in arith_test.go

The function will breakdown setting '-count' argument plural during testing.
The change uses copy instead of assigning statement to avoid this.

This PR will be imported into Gerrit with the title and first
comment (this text) used to generate the subject and body of
the Gerrit change.

Please ensure you adhere to every item in this list.

More info can be found at https://github.com/golang/go/wiki/CommitMessage

  • The PR title is formatted as follows: net/http: frob the quux before blarfing
    • The package name goes before the colon
    • The part after the colon uses the verb tense + phrase that completes the blank in,
      "This change modifies Go to ___________"
    • Lowercase verb after the colon
    • No trailing period
    • Keep the title as short as possible. ideally under 76 characters or shorter
  • No Markdown
  • The first PR comment (this one) is wrapped at 76 characters, unless it's
    really needed (ASCII art, table, or long link)
  • If there is a corresponding issue, add either Fixes #1234 or Updates #1234
    (the latter if this is not a complete fix) to this comment
  • If referring to a repo other than golang/go you can use the
    owner/repo#issue_number syntax: Fixes golang/tools#1234
  • We do not use Signed-off-by lines in Go. Please don't add them.
    Our Gerrit server & GitHub bots enforce CLA compliance instead.
  • Delete these instructions once you have read and applied them

Fixes golang#39406
When use checkForResumption() function it could be side-effect sometime.
1. hs.sessionState will be changed and retained although the function return false.
2. hs.suite will be changed and retained when the statements below return false.
So  we should use a local variable, cilentSessionState, to replace hs.sessionState in the function. And move the set-suite statements down to avoid being changed too early.
The function will breakdown setting '-count' argument plural during testing.
The change uses copy instead of assigning statement to avoid this.
@zaneChou1
Copy link
Copy Markdown

可以具体描述一下bug吗,目前看起来,修改前测试用例是通过的

copy(b, a.d)
z := a.d[a.zp : a.zp+a.l]
x := a.d[a.xp : a.xp+a.l]
z:=make([]Word,a.l)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确认新的操作不会造成性能损失,影响测试结果

@SparrowLii
Copy link
Copy Markdown
Author

可以具体描述一下bug吗,目前看起来,修改前测试用例是通过的

在终端输入 go test math/big -count=2会报错。经测试只要将count参数设为1以上就会报错,原因是原代码在测试函数执行过程中改变了所输入原始数据的值,但期望输出未变,所以会造成多次测试中结果错误的bug

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.

3 participants