forked from alex-eg/sex
designate an initializer's element by its index
[3] in braces reached the writer as a subscript of one operand, and sexc died taking the second.
This commit is contained in:
@@ -1034,7 +1034,14 @@
|
||||
"{pp->x, pp->y}"))
|
||||
(test-assert "designated"
|
||||
(emits? (in-line "(var q (struct point) #(.y (. pp x)))")
|
||||
"{.y = pp->x}")))
|
||||
"{.y = pp->x}"))
|
||||
;; [3] reached the writer as a subscript of one operand, and died
|
||||
(test-assert "an element designated by its index"
|
||||
(emits? (in-fn "(var xs [int 5] #([3] 1 [1] 2))") "{[3] = 1, [1] = 2}"))
|
||||
(test-assert "among positional ones"
|
||||
(emits? (in-fn "(var xs [int 5] #(7 [3] 1 9))") "{7, [3] = 1, 9}"))
|
||||
(test-assert "and one with no value is an error"
|
||||
(reports? (in-fn "(var xs [int 5] #(1 [3]))") "designated initializer without a value")))
|
||||
|
||||
(test-group "member access"
|
||||
(test-assert "a value reads with a dot"
|
||||
|
||||
Reference in New Issue
Block a user