Skip to content

Commit

Permalink
Add repro for Issue #2
Browse files Browse the repository at this point in the history
ExtensionAndException is not handled for component type lists, and simple changes
did not make it work.
Grammar seems to contain quite a bit shift/reduce and reduce/reduce conficts, will
need to inspect more closely.
  • Loading branch information
chemikadze committed Oct 12, 2022
1 parent 0acf752 commit 05169b0
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,3 +525,63 @@ func TestDefaultTags(t *testing.T) {
t.Errorf("Module did not match expected, diff (-want, +got):\n%v", diff)
}
}

func TestSequenceSyntax(t *testing.T) {
testCases := []struct {
name string
content string
expected Type
skipReason string
}{
{
name: "empty sequence",
content: `
TestSpec DEFINITIONS ::= BEGIN
Sequence ::= SEQUENCE { }
END
`,
expected: SequenceType{},
},
{
name: "simple sequence",
content: `
TestSpec DEFINITIONS ::= BEGIN
Sequence ::= SEQUENCE {
field1 BOOLEAN,
field2 BOOLEAN
}
END
`,
expected: SequenceType{Components: ComponentTypeList{
NamedComponentType{NamedType: NamedType{Identifier: "field1", Type: BooleanType{}}},
NamedComponentType{NamedType: NamedType{Identifier: "field2", Type: BooleanType{}}},
}},
},
{
name: "sequence with ellipsis",
skipReason: "ExtensionAndException is not fully implemented in asn1.y",
content: `
TestSpec DEFINITIONS ::= BEGIN
Sequence ::= SEQUENCE {
field1 BOOLEAN,
...
}
END
`,
expected: SequenceType{Components: ComponentTypeList{
NamedComponentType{NamedType: NamedType{Identifier: "field1", Type: BooleanType{}}},
}},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
if tc.skipReason != "" {
t.Skip(tc.skipReason)
}
r := testNotFails(t, tc.content)
if diff := cmp.Diff(r.ModuleBody.AssignmentList.GetType("Sequence").Type, tc.expected); diff != "" {
t.Errorf("Module did not match expected, diff (-want, +got):\n%v", diff)
}
})
}
}

0 comments on commit 05169b0

Please sign in to comment.