mirror of
https://github.com/zellyn/go6502.git
synced 2026-04-26 07:17:48 +00:00
Working on SCMA-compatible assembler.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestExpressionString(t *testing.T) {
|
||||
tests := []struct {
|
||||
expr E
|
||||
want string
|
||||
}{
|
||||
{
|
||||
E{},
|
||||
"?",
|
||||
},
|
||||
{
|
||||
E{Op: OpLeaf, Text: "*"},
|
||||
"*",
|
||||
},
|
||||
{
|
||||
E{
|
||||
Op: OpPlus,
|
||||
Left: &E{Op: OpLeaf, Text: "Label"},
|
||||
Right: &E{Op: OpLeaf, Val: 42},
|
||||
},
|
||||
"(+ Label $002a)",
|
||||
},
|
||||
{
|
||||
E{
|
||||
Op: OpMinus,
|
||||
Left: &E{Op: OpLeaf, Text: "Label"},
|
||||
Right: &E{Op: OpLeaf, Val: 42},
|
||||
},
|
||||
"(- Label $002a)",
|
||||
},
|
||||
{
|
||||
E{
|
||||
Op: OpMinus,
|
||||
Left: &E{Op: OpLeaf, Val: 42},
|
||||
},
|
||||
"(- $002a)",
|
||||
},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
got := tt.expr.String()
|
||||
if got != tt.want {
|
||||
t.Errorf(`%d: want String(expr)="%s"; got "%s"`, i, tt.want, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user