Changed binary prefix from ! to % (as acme)
This commit is contained in:
parent
d57a40a7cf
commit
c543dde600
4 changed files with 8 additions and 8 deletions
|
|
@ -205,7 +205,7 @@ func TestByteCommand_Interpret(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "byte with binary",
|
name: "byte with binary",
|
||||||
text: "BYTE x = !11111111",
|
text: "BYTE x = %11111111",
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
checkVar: func(t *testing.T, ctx *compiler.CompilerContext) {
|
checkVar: func(t *testing.T, ctx *compiler.CompilerContext) {
|
||||||
sym := ctx.SymbolTable.Lookup("x", nil)
|
sym := ctx.SymbolTable.Lookup("x", nil)
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ func TestWordCommand_Interpret(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "word with binary",
|
name: "word with binary",
|
||||||
text: "WORD x = !1111111111111111",
|
text: "WORD x = %1111111111111111",
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
checkVar: func(t *testing.T, ctx *compiler.CompilerContext) {
|
checkVar: func(t *testing.T, ctx *compiler.CompilerContext) {
|
||||||
sym := ctx.SymbolTable.Lookup("x", nil)
|
sym := ctx.SymbolTable.Lookup("x", nil)
|
||||||
|
|
|
||||||
|
|
@ -232,8 +232,8 @@ func evaluateTerm(term string, lookup ConstantLookup) (int64, error) {
|
||||||
return val, nil
|
return val, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for binary: !11111111
|
// Check for binary: %11111111
|
||||||
if strings.HasPrefix(term, "!") {
|
if strings.HasPrefix(term, "%") {
|
||||||
val, err := strconv.ParseInt(term[1:], 2, 64)
|
val, err := strconv.ParseInt(term[1:], 2, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("invalid binary number: %w", err)
|
return 0, fmt.Errorf("invalid binary number: %w", err)
|
||||||
|
|
|
||||||
|
|
@ -204,14 +204,14 @@ func TestEvaluateExpression(t *testing.T) {
|
||||||
{name: "hex word", expr: "$C000", want: 0xC000},
|
{name: "hex word", expr: "$C000", want: 0xC000},
|
||||||
|
|
||||||
// Binary
|
// Binary
|
||||||
{name: "binary 8bit", expr: "!11111111", want: 255},
|
{name: "binary 8bit", expr: "%11111111", want: 255},
|
||||||
{name: "binary zero", expr: "!00000000", want: 0},
|
{name: "binary zero", expr: "%00000000", want: 0},
|
||||||
{name: "binary mixed", expr: "!10101010", want: 0xAA},
|
{name: "binary mixed", expr: "%10101010", want: 0xAA},
|
||||||
|
|
||||||
// Addition
|
// Addition
|
||||||
{name: "add decimal", expr: "10+20", want: 30},
|
{name: "add decimal", expr: "10+20", want: 30},
|
||||||
{name: "add hex", expr: "$10+$20", want: 0x30},
|
{name: "add hex", expr: "$10+$20", want: 0x30},
|
||||||
{name: "add binary", expr: "!1010+!0101", want: 15},
|
{name: "add binary", expr: "%1010+%0101", want: 15},
|
||||||
{name: "add multiple", expr: "10+20+30", want: 60},
|
{name: "add multiple", expr: "10+20+30", want: 60},
|
||||||
|
|
||||||
// Subtraction
|
// Subtraction
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue