============================================================================== TestEvaluate tests the evaluation of consecutive cells.
(t *testing.T)
| 70 | |
| 71 | // TestEvaluate tests the evaluation of consecutive cells. |
| 72 | func TestEvaluate(t *testing.T) { |
| 73 | cases := []struct { |
| 74 | Input []string |
| 75 | Output string |
| 76 | }{ |
| 77 | {[]string{ |
| 78 | "a := 1", |
| 79 | "a", |
| 80 | }, "1"}, |
| 81 | {[]string{ |
| 82 | "a = 2", |
| 83 | "a + 3", |
| 84 | }, "5"}, |
| 85 | {[]string{ |
| 86 | "func myFunc(x int) int {", |
| 87 | " return x+1", |
| 88 | "}", |
| 89 | "myFunc(1)", |
| 90 | }, "2"}, |
| 91 | {[]string{ |
| 92 | "b := myFunc(1)", |
| 93 | }, ""}, |
| 94 | {[]string{ |
| 95 | "type Rect struct {", |
| 96 | " Width, Height int", |
| 97 | "}", |
| 98 | "Rect{10, 30}", |
| 99 | }, "{10 30}"}, |
| 100 | {[]string{ |
| 101 | "type Rect struct {", |
| 102 | " Width, Height int", |
| 103 | "}", |
| 104 | "&Rect{10, 30}", |
| 105 | }, "&{10 30}"}, |
| 106 | {[]string{ |
| 107 | "func a(b int) (int, int) {", |
| 108 | " return 2 + b, b", |
| 109 | "}", |
| 110 | "a(10)", |
| 111 | }, "12 10"}, |
| 112 | {[]string{ |
| 113 | `import "errors"`, |
| 114 | "func a() (interface{}, error) {", |
| 115 | ` return nil, errors.New("To err is human")`, |
| 116 | "}", |
| 117 | "a()", |
| 118 | }, "<nil> To err is human"}, |
| 119 | {[]string{ |
| 120 | `c := []string{"gophernotes", "is", "super", "bad"}`, |
| 121 | "c[:3]", |
| 122 | }, "[gophernotes is super]"}, |
| 123 | {[]string{ |
| 124 | "m := map[string]int{", |
| 125 | ` "a": 10,`, |
| 126 | ` "c": 30,`, |
| 127 | "}", |
| 128 | `m["c"]`, |
| 129 | }, "30 true"}, |
nothing calls this directly
no test coverage detected