File: didyoumean_test.go

package info (click to toggle)
golang-github-hashicorp-hcl-v2 2.14.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 3,120 kB
  • sloc: ruby: 205; makefile: 72; python: 43; sh: 11
file content (51 lines) | stat: -rw-r--r-- 919 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package hclsyntax

import "testing"

func TestNameSuggestion(t *testing.T) {
	var keywords = []string{"false", "true", "null"}

	tests := []struct {
		Input, Want string
	}{
		{"true", "true"},
		{"false", "false"},
		{"null", "null"},
		{"bananas", ""},
		{"NaN", ""},
		{"Inf", ""},
		{"Infinity", ""},
		{"void", ""},
		{"undefined", ""},

		{"ture", "true"},
		{"tru", "true"},
		{"tre", "true"},
		{"treu", "true"},
		{"rtue", "true"},

		{"flase", "false"},
		{"fales", "false"},
		{"flse", "false"},
		{"fasle", "false"},
		{"fasel", "false"},
		{"flue", "false"},

		{"nil", "null"},
		{"nul", "null"},
		{"unll", "null"},
		{"nll", "null"},
	}

	for _, test := range tests {
		t.Run(test.Input, func(t *testing.T) {
			got := nameSuggestion(test.Input, keywords)
			if got != test.Want {
				t.Errorf(
					"wrong result\ninput: %q\ngot:   %q\nwant:  %q",
					test.Input, got, test.Want,
				)
			}
		})
	}
}