X7ROOT File Manager
Current Path:
/opt/golang/1.19.4/test
opt
/
golang
/
1.19.4
/
test
/
📁
..
📄
235.go
(1.56 KB)
📄
64bit.go
(24.83 KB)
📄
README.md
(696 B)
📁
abi
📄
alg.go
(822 B)
📄
alias.go
(588 B)
📄
alias1.go
(803 B)
📄
alias2.go
(2.8 KB)
📁
alias3.dir
📄
alias3.go
(187 B)
📄
align.go
(603 B)
📄
append.go
(9.09 KB)
📄
append1.go
(883 B)
📄
args.go
(374 B)
📄
armimm.go
(3.85 KB)
📁
asmhdr.dir
📄
asmhdr.go
(237 B)
📄
assign.go
(1.01 KB)
📄
assign1.go
(5.55 KB)
📄
atomicload.go
(798 B)
📁
bench
📄
bigalg.go
(2.12 KB)
📄
bigmap.go
(2.46 KB)
📄
blank.go
(2.1 KB)
📄
blank1.go
(724 B)
📄
bom.go
(406 B)
📄
bombad.go
(480 B)
📄
bounds.go
(6.09 KB)
📄
cannotassign.go
(1.04 KB)
📁
chan
📄
chancap.go
(1.57 KB)
📄
chanlinear.go
(2.12 KB)
📄
char_lit.go
(657 B)
📄
char_lit1.go
(822 B)
📄
checkbce.go
(3.56 KB)
📄
clearfat.go
(1.15 KB)
📄
closedchan.go
(5.79 KB)
📄
closure.go
(1.69 KB)
📄
closure1.go
(280 B)
📄
closure2.go
(1.86 KB)
📁
closure3.dir
📄
closure3.go
(321 B)
📄
closure4.go
(364 B)
📁
closure5.dir
📄
closure5.go
(280 B)
📄
closure6.go
(346 B)
📄
closure7.go
(373 B)
📄
cmp.go
(7.63 KB)
📄
cmp6.go
(2.16 KB)
📄
cmplx.go
(1.39 KB)
📄
cmplxdivide.c
(2.05 KB)
📄
cmplxdivide.go
(868 B)
📄
cmplxdivide1.go
(240.68 KB)
📁
codegen
📄
complit.go
(1.71 KB)
📄
complit1.go
(1.63 KB)
📄
compos.go
(403 B)
📄
const.go
(4.78 KB)
📄
const1.go
(3.79 KB)
📄
const2.go
(1008 B)
📄
const3.go
(659 B)
📄
const4.go
(1.28 KB)
📄
const5.go
(835 B)
📄
const6.go
(834 B)
📄
const7.go
(1.72 KB)
📄
const8.go
(727 B)
📄
convT2X.go
(3.33 KB)
📄
convert.go
(833 B)
📄
convert1.go
(3.41 KB)
📄
convert2.go
(5.92 KB)
📄
convert3.go
(544 B)
📄
convert4.go
(1.63 KB)
📄
convlit.go
(2.39 KB)
📄
convlit1.go
(458 B)
📄
copy.go
(6.6 KB)
📄
copy1.go
(851 B)
📄
crlf.go
(782 B)
📄
ddd.go
(4.23 KB)
📄
ddd1.go
(1.7 KB)
📁
ddd2.dir
📄
ddd2.go
(252 B)
📄
decl.go
(926 B)
📄
declbad.go
(1.43 KB)
📄
defer.go
(875 B)
📄
defererrcheck.go
(1.4 KB)
📄
deferfin.go
(1.05 KB)
📄
defernil.go
(563 B)
📄
deferprint.go
(586 B)
📄
deferprint.out
(126 B)
📄
devirt.go
(574 B)
📄
directive.go
(1.33 KB)
📄
directive2.go
(1.21 KB)
📄
divide.go
(1.22 KB)
📄
divmod.go
(9.28 KB)
📁
dwarf
📄
embedfunc.go
(308 B)
📄
embedvers.go
(292 B)
📄
empty.go
(316 B)
📄
env.go
(585 B)
📄
eof.go
(308 B)
📄
eof1.go
(333 B)
📄
escape.go
(3.79 KB)
📄
escape2.go
(35.07 KB)
📄
escape2n.go
(35.1 KB)
📄
escape3.go
(524 B)
📄
escape4.go
(1.31 KB)
📄
escape5.go
(5.31 KB)
📄
escape_array.go
(3.64 KB)
📄
escape_calls.go
(1.26 KB)
📄
escape_closure.go
(4.24 KB)
📄
escape_field.go
(2.92 KB)
📄
escape_goto.go
(677 B)
📄
escape_hash_maphash.go
(368 B)
📄
escape_iface.go
(4.47 KB)
📄
escape_indir.go
(3.31 KB)
📄
escape_level.go
(1.79 KB)
📄
escape_map.go
(2.76 KB)
📄
escape_param.go
(8.9 KB)
📄
escape_runtime_atomic.go
(874 B)
📄
escape_selfassign.go
(538 B)
📄
escape_slice.go
(3.79 KB)
📄
escape_struct_param1.go
(8.9 KB)
📄
escape_struct_param2.go
(8.94 KB)
📄
escape_struct_return.go
(1.04 KB)
📄
escape_sync_atomic.go
(943 B)
📄
escape_unsafe.go
(2.16 KB)
📄
fibo.go
(6.28 KB)
📄
finprofiled.go
(1.95 KB)
📁
fixedbugs
📄
float_lit.go
(3.95 KB)
📄
float_lit2.go
(7.88 KB)
📄
float_lit3.go
(1.72 KB)
📄
floatcmp.go
(3.03 KB)
📄
for.go
(844 B)
📄
func.go
(1.29 KB)
📄
func1.go
(445 B)
📄
func2.go
(578 B)
📄
func3.go
(505 B)
📄
func4.go
(409 B)
📄
func5.go
(1.49 KB)
📄
func6.go
(393 B)
📄
func7.go
(477 B)
📄
func8.go
(599 B)
📄
funcdup.go
(1.31 KB)
📄
funcdup2.go
(721 B)
📄
fuse.go
(5.31 KB)
📄
gc.go
(411 B)
📄
gc1.go
(303 B)
📄
gc2.go
(972 B)
📄
gcgort.go
(34.54 KB)
📄
gcstring.go
(872 B)
📄
goprint.go
(722 B)
📄
goprint.out
(65 B)
📄
goto.go
(8.39 KB)
📄
heapsampling.go
(9.67 KB)
📄
helloworld.go
(269 B)
📄
helloworld.out
(13 B)
📄
if.go
(1.36 KB)
📄
import.go
(425 B)
📄
import1.go
(621 B)
📁
import2.dir
📄
import2.go
(247 B)
📁
import4.dir
📄
import4.go
(310 B)
📄
import5.go
(722 B)
📄
import6.go
(1.44 KB)
📄
index.go
(6.42 KB)
📄
index0.go
(301 B)
📄
index1.go
(305 B)
📄
index2.go
(305 B)
📄
indirect.go
(1.39 KB)
📄
indirect1.go
(1.53 KB)
📄
init.go
(479 B)
📄
init1.go
(1.08 KB)
📄
initcomma.go
(1.22 KB)
📄
initempty.go
(604 B)
📄
initexp.go
(1.74 KB)
📄
initialize.go
(1.24 KB)
📄
initializerr.go
(1.15 KB)
📄
initloop.go
(407 B)
📄
inline.go
(10.49 KB)
📄
inline_big.go
(12.67 KB)
📄
inline_caller.go
(1.36 KB)
📄
inline_callers.go
(1.87 KB)
📄
inline_endian.go
(849 B)
📄
inline_literal.go
(1.02 KB)
📄
inline_math_bits_rotate.go
(569 B)
📄
inline_sync.go
(1.52 KB)
📄
inline_variadic.go
(513 B)
📄
int_lit.go
(387 B)
📄
intcvt.go
(4.26 KB)
📁
interface
📁
intrinsic.dir
📄
intrinsic.go
(259 B)
📄
intrinsic_atomic.go
(807 B)
📄
iota.go
(1.59 KB)
📁
ken
📄
label.go
(1.02 KB)
📄
label1.go
(2.08 KB)
📄
linkmain.go
(236 B)
📄
linkmain_run.go
(1.75 KB)
📁
linkname.dir
📄
linkname.go
(456 B)
📄
linkname3.go
(597 B)
📄
linkobj.go
(3.2 KB)
📄
linkx.go
(741 B)
📄
linkx_run.go
(1.65 KB)
📄
literal.go
(4.99 KB)
📄
literal2.go
(2.22 KB)
📄
live.go
(18.06 KB)
📄
live1.go
(1.29 KB)
📄
live2.go
(963 B)
📄
live_regabi.go
(17.84 KB)
📄
live_uintptrkeepalive.go
(2.03 KB)
📄
loopbce.go
(12.03 KB)
📄
mainsig.go
(598 B)
📄
makechan.go
(1.04 KB)
📄
makemap.go
(1.3 KB)
📄
makenew.go
(605 B)
📄
makeslice.go
(5.49 KB)
📄
mallocfin.go
(1.18 KB)
📄
map.go
(14.91 KB)
📄
map1.go
(1.47 KB)
📄
mapclear.go
(1.49 KB)
📄
maplinear.go
(3.62 KB)
📄
maymorestack.go
(1.05 KB)
📄
mergemul.go
(3.16 KB)
📄
method.go
(5.24 KB)
📄
method1.go
(727 B)
📄
method2.go
(1.21 KB)
📄
method3.go
(570 B)
📁
method4.dir
📄
method4.go
(230 B)
📄
method5.go
(6.73 KB)
📄
method6.go
(467 B)
📄
method7.go
(1.15 KB)
📄
named.go
(4.61 KB)
📄
named1.go
(984 B)
📄
nil.go
(2.23 KB)
📄
nilcheck.go
(3.62 KB)
📄
nilptr.go
(3.15 KB)
📄
nilptr2.go
(3.6 KB)
📄
nilptr3.go
(5.39 KB)
📄
nilptr4.go
(428 B)
📄
nilptr5.go
(865 B)
📄
nilptr5_aix.go
(805 B)
📄
nilptr5_wasm.go
(812 B)
📄
nilptr_aix.go
(3.09 KB)
📄
nosplit.go
(11.48 KB)
📄
notinheap.go
(1.29 KB)
📄
notinheap2.go
(1.78 KB)
📄
notinheap3.go
(1.24 KB)
📄
nowritebarrier.go
(1.21 KB)
📄
nul1.go
(1.23 KB)
📄
opt_branchlikely.go
(2.08 KB)
📄
parentype.go
(424 B)
📄
peano.go
(2.22 KB)
📄
phiopt.go
(2.02 KB)
📄
print.go
(1.56 KB)
📄
print.out
(247 B)
📄
printbig.go
(315 B)
📄
printbig.out
(41 B)
📄
prove.go
(19.89 KB)
📄
prove_constant_folding.go
(602 B)
📄
range.go
(8.14 KB)
📄
recover.go
(10.64 KB)
📄
recover1.go
(2.5 KB)
📄
recover2.go
(1.22 KB)
📄
recover3.go
(1.64 KB)
📄
recover4.go
(2.2 KB)
📄
recover5.go
(408 B)
📄
reflectmethod1.go
(578 B)
📄
reflectmethod2.go
(719 B)
📄
reflectmethod3.go
(651 B)
📄
reflectmethod4.go
(573 B)
📄
reflectmethod5.go
(544 B)
📄
reflectmethod6.go
(555 B)
📄
reflectmethod7.go
(421 B)
📄
reflectmethod8.go
(479 B)
📄
rename.go
(1.52 KB)
📄
rename1.go
(1.13 KB)
📄
reorder.go
(2.28 KB)
📄
reorder2.go
(7.22 KB)
📁
retjmp.dir
📄
retjmp.go
(252 B)
📄
return.go
(32.69 KB)
📄
rotate.go
(3.27 KB)
📄
rotate0.go
(286 B)
📄
rotate1.go
(286 B)
📄
rotate2.go
(286 B)
📄
rotate3.go
(286 B)
📄
run.go
(58.47 KB)
📄
rune.go
(603 B)
📁
runtime
📄
runtime.go
(600 B)
📄
shift1.go
(9.43 KB)
📄
shift2.go
(1.31 KB)
📄
shift3.go
(834 B)
📄
sieve.go
(1 KB)
📄
sigchld.go
(365 B)
📄
sigchld.out
(17 B)
📄
simassign.go
(1.12 KB)
📄
sinit.go
(5.75 KB)
📄
sinit_run.go
(868 B)
📄
sizeof.go
(2.95 KB)
📄
slice3.go
(2.92 KB)
📄
slice3err.go
(5.19 KB)
📄
slicecap.go
(1.85 KB)
📄
sliceopt.go
(735 B)
📄
solitaire.go
(2.9 KB)
📄
stack.go
(1.69 KB)
📄
stackobj.go
(975 B)
📄
stackobj2.go
(1.55 KB)
📄
stackobj3.go
(1.42 KB)
📄
strcopy.go
(674 B)
📄
strength.go
(1.02 KB)
📁
stress
📄
string_lit.go
(3.58 KB)
📄
stringrange.go
(1.45 KB)
📄
struct0.go
(565 B)
📄
switch.go
(6.1 KB)
📄
switch2.go
(778 B)
📄
switch3.go
(1.24 KB)
📄
switch4.go
(526 B)
📄
switch5.go
(2.25 KB)
📄
switch6.go
(1.13 KB)
📄
switch7.go
(796 B)
📁
syntax
📄
tinyfin.go
(1.57 KB)
📄
torture.go
(7.69 KB)
📄
turing.go
(893 B)
📄
typecheck.go
(543 B)
📄
typecheckloop.go
(526 B)
📁
typeparam
📄
typeswitch.go
(1.83 KB)
📄
typeswitch1.go
(1.6 KB)
📄
typeswitch2.go
(655 B)
📄
typeswitch2b.go
(598 B)
📄
typeswitch3.go
(999 B)
📁
uintptrescapes.dir
📄
uintptrescapes.go
(250 B)
📄
uintptrescapes2.go
(2.16 KB)
📄
uintptrescapes3.go
(1.28 KB)
📄
uintptrkeepalive.go
(297 B)
📄
undef.go
(758 B)
📄
unsafebuiltins.go
(1.46 KB)
📄
used.go
(5.96 KB)
📄
utf.go
(1.19 KB)
📄
varerr.go
(449 B)
📄
varinit.go
(509 B)
📄
winbatch.go
(1.97 KB)
📄
writebarrier.go
(5.88 KB)
📄
zerodivide.go
(5.71 KB)
Editing: zerodivide.go
// run // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Test that zero division causes a panic. package main import ( "fmt" "math" "runtime" "strings" ) type ErrorTest struct { name string fn func() err string } var ( i, j, k int = 0, 0, 1 i8, j8, k8 int8 = 0, 0, 1 i16, j16, k16 int16 = 0, 0, 1 i32, j32, k32 int32 = 0, 0, 1 i64, j64, k64 int64 = 0, 0, 1 bb = []int16{2, 0} u, v, w uint = 0, 0, 1 u8, v8, w8 uint8 = 0, 0, 1 u16, v16, w16 uint16 = 0, 0, 1 u32, v32, w32 uint32 = 0, 0, 1 u64, v64, w64 uint64 = 0, 0, 1 up, vp, wp uintptr = 0, 0, 1 f, g, h float64 = 0, 0, 1 f32, g32, h32 float32 = 0, 0, 1 f64, g64, h64, inf, negInf, nan float64 = 0, 0, 1, math.Inf(1), math.Inf(-1), math.NaN() c, d, e complex128 = 0 + 0i, 0 + 0i, 1 + 1i c64, d64, e64 complex64 = 0 + 0i, 0 + 0i, 1 + 1i c128, d128, e128 complex128 = 0 + 0i, 0 + 0i, 1 + 1i ) // Fool gccgo into thinking that these variables can change. func NotCalled() { i++ j++ k++ i8++ j8++ k8++ i16++ j16++ k16++ i32++ j32++ k32++ i64++ j64++ k64++ u++ v++ w++ u8++ v8++ w8++ u16++ v16++ w16++ u32++ v32++ w32++ u64++ v64++ w64++ up++ vp++ wp++ f += 1 g += 1 h += 1 f32 += 1 g32 += 1 h32 += 1 f64 += 1 g64 += 1 h64 += 1 c += 1 + 1i d += 1 + 1i e += 1 + 1i c64 += 1 + 1i d64 += 1 + 1i e64 += 1 + 1i c128 += 1 + 1i d128 += 1 + 1i e128 += 1 + 1i } var tmp interface{} // We could assign to _ but the compiler optimizes it too easily. func use(v interface{}) { tmp = v } // Verify error/no error for all types. var errorTests = []ErrorTest{ // All integer divide by zero should error. ErrorTest{"int 0/0", func() { use(i / j) }, "divide"}, ErrorTest{"int8 0/0", func() { use(i8 / j8) }, "divide"}, ErrorTest{"int16 0/0", func() { use(i16 / j16) }, "divide"}, ErrorTest{"int32 0/0", func() { use(i32 / j32) }, "divide"}, ErrorTest{"int64 0/0", func() { use(i64 / j64) }, "divide"}, ErrorTest{"int 1/0", func() { use(k / j) }, "divide"}, ErrorTest{"int8 1/0", func() { use(k8 / j8) }, "divide"}, ErrorTest{"int16 1/0", func() { use(k16 / j16) }, "divide"}, ErrorTest{"int32 1/0", func() { use(k32 / j32) }, "divide"}, ErrorTest{"int64 1/0", func() { use(k64 / j64) }, "divide"}, // From issue 5790, we should ensure that _ assignments // still evaluate and generate zerodivide panics. ErrorTest{"int16 _ = bb[0]/bb[1]", func() { _ = bb[0] / bb[1] }, "divide"}, ErrorTest{"uint 0/0", func() { use(u / v) }, "divide"}, ErrorTest{"uint8 0/0", func() { use(u8 / v8) }, "divide"}, ErrorTest{"uint16 0/0", func() { use(u16 / v16) }, "divide"}, ErrorTest{"uint32 0/0", func() { use(u32 / v32) }, "divide"}, ErrorTest{"uint64 0/0", func() { use(u64 / v64) }, "divide"}, ErrorTest{"uintptr 0/0", func() { use(up / vp) }, "divide"}, ErrorTest{"uint 1/0", func() { use(w / v) }, "divide"}, ErrorTest{"uint8 1/0", func() { use(w8 / v8) }, "divide"}, ErrorTest{"uint16 1/0", func() { use(w16 / v16) }, "divide"}, ErrorTest{"uint32 1/0", func() { use(w32 / v32) }, "divide"}, ErrorTest{"uint64 1/0", func() { use(w64 / v64) }, "divide"}, ErrorTest{"uintptr 1/0", func() { use(wp / vp) }, "divide"}, // All float64ing divide by zero should not error. ErrorTest{"float64 0/0", func() { use(f / g) }, ""}, ErrorTest{"float32 0/0", func() { use(f32 / g32) }, ""}, ErrorTest{"float64 0/0", func() { use(f64 / g64) }, ""}, ErrorTest{"float64 1/0", func() { use(h / g) }, ""}, ErrorTest{"float32 1/0", func() { use(h32 / g32) }, ""}, ErrorTest{"float64 1/0", func() { use(h64 / g64) }, ""}, ErrorTest{"float64 inf/0", func() { use(inf / g64) }, ""}, ErrorTest{"float64 -inf/0", func() { use(negInf / g64) }, ""}, ErrorTest{"float64 nan/0", func() { use(nan / g64) }, ""}, // All complex divide by zero should not error. ErrorTest{"complex 0/0", func() { use(c / d) }, ""}, ErrorTest{"complex64 0/0", func() { use(c64 / d64) }, ""}, ErrorTest{"complex128 0/0", func() { use(c128 / d128) }, ""}, ErrorTest{"complex 1/0", func() { use(e / d) }, ""}, ErrorTest{"complex64 1/0", func() { use(e64 / d64) }, ""}, ErrorTest{"complex128 1/0", func() { use(e128 / d128) }, ""}, } func error_(fn func()) (error string) { defer func() { if e := recover(); e != nil { error = e.(runtime.Error).Error() } }() fn() return "" } type FloatTest struct { f, g float64 out float64 } var float64Tests = []FloatTest{ FloatTest{0, 0, nan}, FloatTest{nan, 0, nan}, FloatTest{inf, 0, inf}, FloatTest{negInf, 0, negInf}, } func alike(a, b float64) bool { switch { case math.IsNaN(a) && math.IsNaN(b): return true case a == b: return math.Signbit(a) == math.Signbit(b) } return false } func main() { bad := false for _, t := range errorTests { err := error_(t.fn) switch { case t.err == "" && err == "": // fine case t.err != "" && err == "": if !bad { bad = true fmt.Printf("BUG\n") } fmt.Printf("%s: expected %q; got no error\n", t.name, t.err) case t.err == "" && err != "": if !bad { bad = true fmt.Printf("BUG\n") } fmt.Printf("%s: expected no error; got %q\n", t.name, err) case t.err != "" && err != "": if !strings.Contains(err, t.err) { if !bad { bad = true fmt.Printf("BUG\n") } fmt.Printf("%s: expected %q; got %q\n", t.name, t.err, err) continue } } } // At this point we know we don't error on the values we're testing for _, t := range float64Tests { x := t.f / t.g if !alike(x, t.out) { if !bad { bad = true fmt.Printf("BUG\n") } fmt.Printf("%v/%v: expected %g error; got %g\n", t.f, t.g, t.out, x) } } if bad { panic("zerodivide") } }
Upload File
Create Folder