From 6eaaf4cf80f2d31ab0524d2904ff2f5e1c81bafa Mon Sep 17 00:00:00 2001 From: dbaumgarten Date: Wed, 4 Aug 2021 11:33:01 +0200 Subject: [PATCH] Disallow abs() on basic chips #68 --- pkg/validators/available_ops.go | 2 +- pkg/validators/available_ops_test.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/validators/available_ops.go b/pkg/validators/available_ops.go index 5f3a8c7..40076de 100644 --- a/pkg/validators/available_ops.go +++ b/pkg/validators/available_ops.go @@ -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: {}, } diff --git a/pkg/validators/available_ops_test.go b/pkg/validators/available_ops_test.go index 1a7fcb0..5f2e4f7 100644 --- a/pkg/validators/available_ops_test.go +++ b/pkg/validators/available_ops_test.go @@ -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)