Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 20 of 35 for shouldPanic (0.3 sec)

  1. test/fixedbugs/issue7550.go

    // run
    
    // Copyright 2014 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.
    
    package main
    
    func shouldPanic(f func()) {
            defer func() {
                    if recover() == nil {
                            panic("not panicking")
                    }
            }()
            f()
    }
    
    func f() {
            length := int(^uint(0) >> 1)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Apr 03 02:44:44 UTC 2014
    - 551 bytes
    - Viewed (0)
  2. test/fixedbugs/bug444.go

    import "reflect"
    
    type T interface {}
    
    var x bool
    
    func main() {
            reflect.TypeOf(nil)
            reflect.TypeOf(T(nil)) // used to miscompile
            shouldPanic()
    }
    
    func f() byte {
    	return []byte(nil)[0] // used to miscompile
    }
    
    func shouldPanic() {
    	defer func() {
    		if recover() == nil {
    			panic("not panicking")
    		}
    	}()
    	f()
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon May 02 13:43:18 UTC 2016
    - 645 bytes
    - Viewed (0)
  3. test/fixedbugs/issue6055.go

    		// make sure a traceback happens with jmpdefer on the stack
    		runtime.GC()
    	}()
    	var x Closer
    	defer x.Close()
    }
    
    func shouldPanic(f func()) {
    	defer func() {
    		if recover() == nil {
    			panic("did not panic")
    		}
    	}()
    	f()
    }
    
    func main() {
    	shouldPanic(nilInterfaceDeferCall)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon May 02 13:43:18 UTC 2016
    - 563 bytes
    - Viewed (0)
  4. test/fixedbugs/issue29190.go

    import (
    	"strings"
    )
    
    type T struct{}
    
    const maxInt = int(^uint(0) >> 1)
    
    func main() {
    	s := make([]T, maxInt)
    	shouldPanic("len out of range", func() { s = append(s, T{}) })
    	var oneElem = make([]T, 1)
    	shouldPanic("len out of range", func() { s = append(s, oneElem...) })
    }
    
    func shouldPanic(str string, f func()) {
    	defer func() {
    		err := recover()
    		if err == nil {
    			panic("did not panic")
    		}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Aug 08 16:58:57 UTC 2022
    - 707 bytes
    - Viewed (0)
  5. test/fixedbugs/issue65417.go

    import (
    	"strings"
    	"unsafe"
    )
    
    func main() {
    	shouldPanic("runtime error: index out of range", func() { f(0) })
    	shouldPanic("runtime error: index out of range", func() { g(0) })
    }
    
    func f[T byte](t T) {
    	const str = "a"
    	_ = str[unsafe.Sizeof(t)]
    }
    
    func g[T byte](t T) {
    	const str = "a"
    	_ = str[unsafe.Sizeof(t)+0]
    }
    
    func shouldPanic(str string, f func()) {
    	defer func() {
    		err := recover()
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Feb 20 22:29:14 UTC 2024
    - 752 bytes
    - Viewed (0)
  6. test/interface/fail.go

    package main
    
    type I interface {
    	Foo()
    }
    
    func main() {
    	shouldPanic(p1)
    }
    
    func p1() {
    	var s *S
    	var i I
    	var e interface{}
    	e = s
    	i = e.(I)
    	_ = i
    }
    
    type S struct{}
    
    func (s *S) _() {}
    
    func shouldPanic(f func()) {
    	defer func() {
    		if recover() == nil {
    			panic("function should panic")
    		}
    	}()
    	f()
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Oct 15 16:55:13 UTC 2014
    - 544 bytes
    - Viewed (0)
  7. test/typeparam/dottype.go

    }
    
    func main() {
    	var i interface{} = int(3)
    	var j I = myint(3)
    	var x interface{} = float64(3)
    	var y I = myfloat(3)
    
    	println(f[int](i))
    	shouldpanic(func() { f[int](x) })
    	println(f2[int](i))
    	println(f2[int](x))
    
    	println(g[myint](j))
    	shouldpanic(func() { g[myint](y) })
    	println(g2[myint](j))
    	println(g2[myint](y))
    
    	println(h[int](struct{ a, b int }{3, 5}).a)
    
    	println(k[int](mybar(3)).bar())
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Mar 01 19:45:34 UTC 2022
    - 1.4K bytes
    - Viewed (0)
  8. test/fixedbugs/issue15975.go

    	var x Closer
    	defer x.Close()
    	// if it panics when evaluating x.Close, it should not reach here
    	fail = true
    }
    
    func shouldPanic(f func()) {
    	defer func() {
    		if recover() == nil {
    			panic("did not panic")
    		}
    	}()
    	f()
    }
    
    func main() {
    	shouldPanic(nilInterfaceDeferCall)
    	if fail {
    		panic("fail")
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Jun 08 20:35:53 UTC 2016
    - 572 bytes
    - Viewed (0)
  9. test/fixedbugs/bug148.go

    	if x == nil {
    		return T{2, 3};
    	}
    
    	t := x.(T);
    	println(t.a, t.b);
    	return x;
    }
    
    func main() {
    	inner_T := f(nil);
    	f(inner_T);
    
    	shouldPanic(p1)
    }
    
    func p1() {
    	outer_T := T{5, 7};
    	f(outer_T);
    }
    
    func shouldPanic(f func()) {
    	defer func() {
    		if recover() == nil {
    			panic("function should panic")
    		}
    	}()
    	f()
    }
    
    /*
    This prints:
    
    2 3
    5 7
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Feb 17 04:49:30 UTC 2012
    - 750 bytes
    - Viewed (0)
  10. test/interface/noeq.go

    		m map[int]int
    		s struct{ x []int }
    		f func()
    	)
    	noCmp(m)
    	noCmp(s)
    	noCmp(f)
    }
    
    func cmp(x interface{}) bool {
    	return x == x
    }
    
    func noCmp(x interface{}) {
    	shouldPanic(func() { cmp(x) })
    }
    
    func shouldPanic(f func()) {
    	defer func() {
    		if recover() == nil {
    			panic("function should panic")
    		}
    	}()
    	f()
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon May 02 13:43:18 UTC 2016
    - 641 bytes
    - Viewed (0)
Back to top