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

Unexpected behaviour of internal type `stack' #14

Open
dolmen opened this issue Jan 24, 2023 · 0 comments
Open

Unexpected behaviour of internal type `stack' #14

dolmen opened this issue Jan 24, 2023 · 0 comments

Comments

@dolmen
Copy link

dolmen commented Jan 24, 2023

func TestBoolStack(t *testing.T) {
	var bs stack
	bs.push(true)
	bs.push(false)
	bs.push(true)
	for i := len(bs); i > 0; i-- {
		t.Log(bs.len(), bs.pop())
	}
}

Output:

=== RUN   TestBoolStack
    decoder_test.go:229: 3 false
    decoder_test.go:229: 2 true
    decoder_test.go:229: 1 false
--- PASS: TestBoolStack (0.00s)

The output doesn't match the reversed input. This is not what I expect from a stack with methods push and pop. Is it on purpose? I guess not, but there is no comment on the stack type to tell otherwise.

@dolmen dolmen changed the title Behaviour of internal type `stack' is unexpected Unexpected behaviour of internal type `stack' Jan 24, 2023
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

No branches or pull requests

1 participant