Skip to content

Commit

Permalink
Disallow abs() on basic chips #68
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaumgarten committed Aug 4, 2021
1 parent 4eb35c0 commit 6eaaf4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/validators/available_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var unavailableBinaryOps = map[string][]string{
}

var unavailableUnaryOps = map[string][]string{
ChipTypeBasic: {"!", "sqrt", "sin", "cos", "tan", "asin", "acos", "atan"},
ChipTypeBasic: {"!", "sqrt", "sin", "cos", "tan", "asin", "acos", "atan", "abs"},
ChipTypeAdvanced: {"sin", "cos", "tan", "asin", "acos", "atan"},
ChipTypeProfessional: {},
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/validators/available_ops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ func TestAvailableOps(t *testing.T) {
prog: "x=sin(13)",
chiptype: validators.ChipTypeProfessional,
},
{
prog: "x=abs(13)",
chiptype: validators.ChipTypeBasic,
expectErr: true,
},
{
prog: "x=abs(13)",
chiptype: validators.ChipTypeAdvanced,
},
}
for i, entry := range testdata {
parsed, err := parser.NewParser().Parse(entry.prog)
Expand Down

0 comments on commit 6eaaf4c

Please sign in to comment.