MCPcopy
hub / github.com/hashicorp/hcl / TestSourceRange

Function TestSourceRange

hcldec/public_test.go:1077–1153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1075}
1076
1077func TestSourceRange(t *testing.T) {
1078 tests := []struct {
1079 config string
1080 spec Spec
1081 want hcl.Range
1082 }{
1083 {
1084 "a = 1\n",
1085 &AttrSpec{
1086 Name: "a",
1087 },
1088 hcl.Range{
1089 Start: hcl.Pos{Line: 1, Column: 5, Byte: 4},
1090 End: hcl.Pos{Line: 1, Column: 6, Byte: 5},
1091 },
1092 },
1093 {
1094 `
1095b {
1096 a = 1
1097}
1098`,
1099 &BlockSpec{
1100 TypeName: "b",
1101 Nested: &AttrSpec{
1102 Name: "a",
1103 },
1104 },
1105 hcl.Range{
1106 Start: hcl.Pos{Line: 3, Column: 7, Byte: 11},
1107 End: hcl.Pos{Line: 3, Column: 8, Byte: 12},
1108 },
1109 },
1110 {
1111 `
1112b {
1113 c {
1114 a = 1
1115 }
1116}
1117`,
1118 &BlockSpec{
1119 TypeName: "b",
1120 Nested: &BlockSpec{
1121 TypeName: "c",
1122 Nested: &AttrSpec{
1123 Name: "a",
1124 },
1125 },
1126 },
1127 hcl.Range{
1128 Start: hcl.Pos{Line: 4, Column: 9, Byte: 19},
1129 End: hcl.Pos{Line: 4, Column: 10, Byte: 20},
1130 },
1131 },
1132 }
1133
1134 for i, test := range tests {

Callers

nothing calls this directly

Calls 4

ParseConfigFunction · 0.92
SourceRangeFunction · 0.85
RunMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected