-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
106 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package main | ||
|
||
type consoleMock struct { | ||
linesIn []string | ||
lineIn int | ||
output string | ||
env *environment | ||
} | ||
|
||
func newConsoleMock(env *environment, linesIn []string) *consoleMock { | ||
var c consoleMock | ||
c.linesIn = linesIn | ||
c.output = "" | ||
c.env = env | ||
return &c | ||
} | ||
|
||
func (c *consoleMock) readline() (string, bool) { | ||
if c.lineIn >= len(c.linesIn) { | ||
c.env.stop = true | ||
return "", true | ||
} | ||
line := c.linesIn[c.lineIn] | ||
c.env.writeSpool(line) | ||
c.env.writeSpool("\n") | ||
c.lineIn++ | ||
return line, false | ||
} | ||
|
||
func (c *consoleMock) readChar() (uint8, bool) { | ||
s, stop := c.readline() | ||
if s == "" { | ||
return ' ', stop | ||
} else { | ||
return s[0], stop | ||
} | ||
} | ||
|
||
func (c *consoleMock) write(s string) { | ||
c.output += s | ||
c.env.writeSpool(s) | ||
} | ||
|
||
func (c *consoleMock) close() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package main | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func Test_OSCLI_HELP(t *testing.T) { | ||
|
||
def := "BASIC.ROM" | ||
roms := []*string{&def} | ||
|
||
env := newEnvironment(roms, false, false, false, false, false) | ||
con := newConsoleMock(env, []string{ | ||
"*HELP", | ||
}) | ||
env.con = con | ||
|
||
RunMOS(env) | ||
|
||
if !strings.Contains(con.output, "BBZ") { | ||
t.Log(con.output) | ||
t.Error("*HELP is not returning BBZ") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters