forked from alex-eg/sex
tell an array's bound by the shape of its type
Whether a trailing name was the bound hinged on the word before it being a typedef Sex had seen, which a header's pthread_t never is, and a grouped (* T) never is either: [pthread-t N] became a two-word type. Fixes #56, #60.
This commit is contained in:
@@ -217,4 +217,24 @@
|
||||
(get-name-type 't-never-declared))
|
||||
(test "nor a return type"
|
||||
#f
|
||||
(get-return-type 't-never-declared)))
|
||||
(get-return-type 't-never-declared))
|
||||
|
||||
;; Where an array's element type ends is a matter of shape, not of
|
||||
;; what the database happens to hold: a typedef from a C header is
|
||||
;; never in it
|
||||
(test-group "array bounds"
|
||||
(test-assert "a number" (array-bound? '(¤ int 4)))
|
||||
(test-assert "a name after a specifier" (array-bound? '(¤ int N)))
|
||||
(test-assert "a name after a type name unknown to Sex"
|
||||
(array-bound? '(¤ pthread-t N)))
|
||||
(test-assert "a name after a grouped type"
|
||||
(array-bound? '(¤ (* t-point) N)))
|
||||
(test-assert "a name after a tag" (array-bound? '(¤ struct t-point N)))
|
||||
(test-assert "not a lone type" (not (array-bound? '(¤ pthread-t))))
|
||||
(test-assert "not a specifier" (not (array-bound? '(¤ unsigned int))))
|
||||
(test-assert "not a qualified name" (not (array-bound? '(¤ const t))))
|
||||
(test-assert "not a pointer's target" (not (array-bound? '(¤ * size-t))))
|
||||
(test-assert "not a tag" (not (array-bound? '(¤ struct t-point))))
|
||||
(test "the element of a grouped type is the group"
|
||||
'(* t-point)
|
||||
(array-element-type '(¤ (* t-point) N)))))
|
||||
|
||||
Reference in New Issue
Block a user