Skip to content

Unexpected behaviour of internal type `stack' #14

Description

@dolmen
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions