github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/tests/files/type24b.gno (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/gnolang/gno/_test/net/http"
     7  	"github.com/gnolang/gno/_test/net/http/httptest"
     8  )
     9  
    10  func main() {
    11  	assertInt()
    12  	assertNil()
    13  	assertValue()
    14  }
    15  
    16  func assertInt() {
    17  	defer func() {
    18  		r := recover()
    19  		fmt.Println(r)
    20  	}()
    21  
    22  	var v interface{} = 1
    23  	println(v.(string))
    24  }
    25  
    26  func assertNil() {
    27  	defer func() {
    28  		r := recover()
    29  		fmt.Println(r)
    30  	}()
    31  
    32  	var v interface{}
    33  	println(v.(string))
    34  }
    35  
    36  func assertValue() {
    37  	defer func() {
    38  		r := recover()
    39  		fmt.Println(r)
    40  	}()
    41  
    42  	var v http.ResponseWriter = httptest.NewRecorder()
    43  	println(v.(http.Pusher))
    44  }
    45  
    46  // Output:
    47  // int is not of type string
    48  // interface{} is not of type string
    49  // *github.com/gnolang/gno/_test/net/http/httptest.ResponseRecorder doesn't implement interface{Push func(string;*github.com/gnolang/gno/_test/net/http.PushOptions)(.uverse.error)}