keep the writer's own words to the head of a form
They were its own wherever they stood, so a name spelled like one -- (var array int), a parameter `define' -- came out %array, %define.
This commit is contained in:
@@ -1011,6 +1011,23 @@ whitespace aside, THEN?"
|
||||
(emits? "(fn take ((f (fn ((int)) (fn () void)))) void (return))"
|
||||
"take (void (*(*f)(int))())")))
|
||||
|
||||
;; the writer's own words were its own wherever they stood, so a
|
||||
;; name spelled like one came out `%array'
|
||||
(test-group "names the writer has words for"
|
||||
(test-assert "as variables"
|
||||
(emits? (in-fn "(var array int 1) (var define int 2) (var include int 3) (g array define include)")
|
||||
"g(array, define, include)"))
|
||||
(test-assert "as parameters"
|
||||
(emits? "(fn sum ((array (* int)) (pointer int)) int (return (+ [array 0] pointer)))"
|
||||
"sum (int * array, int pointer)"))
|
||||
(test-assert "as fields"
|
||||
(emits? "(struct s ((prototype int) (attribute int)))" "int prototype;"))
|
||||
(test-assert "as a typedef's name, and used as a type"
|
||||
(emits? "(typedef array int) (fn f () void (var a array 1))" " array a = 1;"))
|
||||
(test-assert "while at a form's head they are the writer's still"
|
||||
(emits? "(include stdio.h) (fn f () void (static-assert (== 1 1) \"x\"))"
|
||||
"_Static_assert(1 == 1, \"x\")")))
|
||||
|
||||
;; c-struct/aux wrote the tag and the first `*' after it, and
|
||||
;; dropped the rest of the chain
|
||||
(test-group "a pointer chain to a struct"
|
||||
|
||||
Reference in New Issue
Block a user