MCPcopy Create free account
hub / github.com/ahmedakef/goshell / TestManager_RunProgram

Function TestManager_RunProgram

manager_test.go:11–107  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestManager_RunProgram(t *testing.T) {
12 tests := []struct {
13 name string
14 input []string
15 expectedOutput string
16 expectedError error
17 }{
18 {
19 name: "simple addition",
20 input: []string{
21 "1+1",
22 },
23 expectedOutput: "2\n",
24 expectedError: nil,
25 },
26 {
27 name: "function declaration and call",
28 input: []string{
29 "func add(a int, b int) int { return a+b }",
30 "add(2,3)",
31 },
32 expectedOutput: "5\n",
33 expectedError: nil,
34 },
35 {
36 name: "declation then experiment",
37 input: []string{
38 "a:=1",
39 "a",
40 "a=3",
41 "a",
42 },
43 expectedOutput: "3\n",
44 expectedError: nil,
45 },
46 {
47 name: "slice initialization",
48 input: []string{
49 "a:= []int{1}",
50 "a",
51 },
52 expectedOutput: "[]int{1}\n",
53 expectedError: nil,
54 },
55 {
56 name: "assignment, experiment, function declaration",
57 input: []string{
58 "a:=1",
59 "a",
60 "func add(a int, b int) int { return a+b }",
61 },
62 expectedOutput: "",
63 expectedError: nil,
64 },
65 {
66 name: "function declaration without return variables and call",
67 input: []string{
68 "func x() { fmt.Println(3) }",

Callers

nothing calls this directly

Calls 3

newManagerFunction · 0.85
addInputMethod · 0.80
runProgramMethod · 0.80

Tested by

no test coverage detected