Skip to content

Commit

Permalink
test chain
Browse files Browse the repository at this point in the history
  • Loading branch information
sdfsdhgjkbmnmxc committed Mar 23, 2021
1 parent a211666 commit fdc2efc
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions swap_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package swap

import "testing"

func TestChain(t *testing.T) {
x := 2
y := 3

t.Run("defer", func(t *testing.T) {
if x != 2 {
t.Fatal("x must be 2")
}
defer Chain(
Int(&x, 10),
Int(&y, 20),
)()
if x != 10 {
t.Fatal("x must be 10")
}
})

if x != 2 {
t.Fatal("x must be 2")
}
}

func TestInt(t *testing.T) {
x := 2
t.Run("defer", func(t *testing.T) {
if x != 2 {
t.Fatal("x must be 2")
}
defer Int(&x, 10)()
if x != 10 {
t.Fatal("x must be 10")
}
})
if x != 2 {
t.Fatal("x must be 2")
}
}

0 comments on commit fdc2efc

Please sign in to comment.