Skip to content

Commit

Permalink
compiler/testdata: add missing error cases
Browse files Browse the repository at this point in the history
This commit adds error cases that weren't covered before. They were
identified by looking at the coverage numbers for pkg/compiler.

Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
  • Loading branch information
pchaigno authored and a-nogikh committed Nov 29, 2023
1 parent 91df311 commit f819d6f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/compiler/testdata/errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ foo$70() ("foo") ### unexpected string "foo", expect attribute
foo$71() (42) ### unexpected int 42, expect attribute
foo$72() (disabled, disabled) ### duplicate syscall foo$72 attribute disabled
foo$73(a int32[int_flags, 2]) ### align argument of int32 is not supported unless first argument is a range
foo$74() (int8:1) ### unexpected ':'

opt { ### struct uses reserved name opt
f1 int32
Expand Down Expand Up @@ -167,6 +168,7 @@ s3 {
f7 int32:33 ### bitfield of size 33 is too large for base type of size 32
f8 const[0, int32:C1] ### literal const bitfield sizes are not supported
f9 const[0] ### wrong number of arguments for type const, expect value, base type
f10 int8:1:1 ### unexpected ':'
} [packed, align[4]]

s5 {
Expand Down Expand Up @@ -201,6 +203,10 @@ s13 {
f1 int8
} [size[0[0]]] ### size attribute has colon or args

s14 {
f1 int8
} [size[1, 2]] ### size attribute is expected to have 1 argument

u3 [
f1 int8
f2 int32
Expand Down
11 changes: 10 additions & 1 deletion pkg/compiler/testdata/errors2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,24 @@ slen1 {
f7 len[syscall:b, int32] ### len target b does not exist
f8 offsetof[parent, int32] ### offsetof must refer to fields
f9 offsetof[slen1, int32] ### offsetof must refer to fields
f10 len[f0:syscall:b, int32] ### syscall can't be in the middle of path expressions
f11 len[slen3:a, int32] ### len path slen3 does not refer to a struct
slen2 ptr[in, array[slen2]]
slen21 slen2
slen3 slen3
slen22 array[slen2]
}

slen2 {
f int32
f int32
f1 slen3
}

slen3 [
a int32
b int32
]

# Resource ctor tests.

resource r100[int32] ### resource r100 can't be created (never mentioned as a syscall return value or output argument/field)
Expand Down

0 comments on commit f819d6f

Please sign in to comment.