-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- v1.0.52
- v1.0.51
- v1.0.50
- v1.0.49
- v1.0.48
- v1.0.47
- v1.0.46
- v1.0.45
- v1.0.44
- v1.0.43
- v1.0.42
- v1.0.41
- v1.0.40
- v1.0.39
- v1.0.38
- v1.0.37
- v1.0.36
- v1.0.35
- v1.0.34
- v1.0.33
- v1.0.32
- v1.0.31
- v1.0.30
- v1.0.29
- v1.0.28
- v1.0.27
- v1.0.26
- v1.0.25
- v1.0.24
- v1.0.23
- v1.0.22
- v1.0.21
- v1.0.20
- v1.0.19
- v1.0.18
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- runtime/v1.0.52
- runtime/v1.0.49
- runtime/v1.0.48
- runtime/v1.0.47
- runtime/v1.0.45
- runtime/v1.0.43
- runtime/v1.0.42
- runtime/v1.0.41
- runtime/v1.0.40
- runtime/v1.0.39
- runtime/v1.0.38
- runtime/v1.0.37
- runtime/v1.0.36
- runtime/v1.0.35
- runtime/v1.0.34
- runtime/v1.0.33
- runtime/v1.0.32
- runtime/v1.0.31
- runtime/v1.0.30
- runtime/v1.0.30-alpha
- runtime/v1.0.29
- runtime/v1.0.28
- runtime/v1.0.27
- runtime/v1.0.26
- runtime/v1.0.25
- runtime/v1.0.24
- runtime/v1.0.23
- runtime/v1.0.22
- runtime/v1.0.21
- runtime/v1.0.20
- runtime/v1.0.19
- runtime/v1.0.18
- runtime/v1.0.17
- runtime/v1.0.16
- runtime/v1.0.15
- runtime/v1.0.14
- runtime/v1.0.13
- runtime/v1.0.12
- runtime/v1.0.11
Showing
26 changed files
with
358 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// debug test is a convienent package | ||
// you can paste your minimal code your | ||
// to focus only the problemtic part of | ||
// failing code | ||
|
||
package debug | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/xhd2015/xgo/runtime/trap" | ||
) | ||
|
||
type struct_ struct { | ||
} | ||
|
||
func (c *struct_) F() { | ||
panic("should never call me") | ||
} | ||
|
||
func TestDebug(t *testing.T) { | ||
s := &struct_{} | ||
srecv, sf := trap.Inspect(s.F) | ||
if sf == nil { | ||
t.Fatalf("struct_.F not found") | ||
} | ||
if srecv == nil { | ||
t.Fatalf("expect receive for struct_.F not nil, actual: %v", srecv) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package mock_closuer | ||
|
||
import "testing" | ||
|
||
// see https://github.com/xhd2015/xgo/issues/13 | ||
func TestClosuerWithIfFalse(t *testing.T) { | ||
// assert this function | ||
var a int | ||
if false { | ||
func() { | ||
a = 10 | ||
}() | ||
} | ||
if a != 0 { | ||
t.Fatalf("expect a to be 0, actual: %d", a) | ||
} | ||
} | ||
func TestClosuerWithIfTrue(t *testing.T) { | ||
var a int | ||
if true { | ||
func() { | ||
a = 10 | ||
}() | ||
} | ||
if a != 10 { | ||
t.Fatalf("expect a to be 10, actual: %d", a) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package mock_closuer | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
func TestImmediatelyCalledClosure(t *testing.T) { | ||
// assert the compiler can compile | ||
// and run this code | ||
text := func(a int) string { | ||
return fmt.Sprintf("%d", a) | ||
}(10) | ||
if text != "10" { | ||
t.Logf("expect text to be %s, actual: %s", "10", text) | ||
} | ||
} | ||
|
||
func TestDeferNoArgCall(t *testing.T) { | ||
var b int | ||
defer func() { | ||
if b != 10 { | ||
t.Fatalf("expect b to be %d, actual: %d", 10, b) | ||
} | ||
}() | ||
|
||
b = 10 | ||
} | ||
|
||
func TestDeferArgCall(t *testing.T) { | ||
var b int | ||
defer func(b int) { | ||
if b != 10 { | ||
t.Fatalf("expect b to be %d, actual: %d", 10, b) | ||
} | ||
}(10) | ||
|
||
b = 11 | ||
_ = b | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//go:build !go1.22 | ||
// +build !go1.22 | ||
|
||
package trap | ||
|
||
const ClosureHasFunc = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//go:build go1.22 | ||
// +build go1.22 | ||
|
||
package trap | ||
|
||
const ClosureHasFunc = true |
Oops, something went wrong.