summaryrefslogtreecommitdiff
path: root/debug/frames_test.go
blob: 40c10865036060abb3c7d5a39a02945ee47841ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package debug

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func TestRegex(t *testing.T) {
	tests := map[string]string{
		"attrs": `	attrs = Map(Some(attr), func(node Result) Result {`,
		"_value": `	_value = Any(_null, _true, _false, _string, _number, _array, _object)`,
		"_object": `_object = Map(Seq("{", Cut, _properties, "}"), func(n Result) Result {`,
		"expr":    `var expr = Exact("foo")`,
		"number":  `number := NumberLit()`,
	}
	for expected, input := range tests {
		t.Run(input, func(t *testing.T) {
			matches := varRegex.FindStringSubmatch(input)
			require.NotNil(t, matches)
			require.Equal(t, expected, matches[1])
		})
	}
}