government / ast / reserved_test.go

@ 7fc9f65a585bd720d0768ecfb4755a050cfd6106 | history


package ast

import (
	"slices"
	"testing"

	"government/eval"
)

func TestBuiltinsMatchEvaluator(t *testing.T) {
	// The structural names are values in source (or reader syntax), not
	// symbols, so the evaluator never sees them as names.
	structural := []string{ListNode, Dot, True, False, Empty}
	var named []string
	for _, b := range builtinCodes {
		if !slices.Contains(structural, b.name) {
			named = append(named, b.name)
		}
	}
	slices.Sort(named)
	if reserved := eval.ReservedNames(); !slices.Equal(named, reserved) {
		t.Errorf("builtin codes name %v\nevaluator reserves %v", named, reserved)
	}
}