]> git.draconx.ca Git - cdecl99.git/commitdiff
Add a couple more positive tests.
authorNick Bowler <nbowler@draconx.ca>
Wed, 24 Feb 2021 05:49:04 +0000 (00:49 -0500)
committerNick Bowler <nbowler@draconx.ca>
Wed, 3 Mar 2021 01:23:58 +0000 (20:23 -0500)
A review of the ChangeLog suggests we regressed on 'int **' at some
point, so it seems like a good idea to explicitly test this.

Also test int (*) because thought I had found an error but of course
the robot was correct and I was wrong: there was no such error.

Validate both the type name and declaration forms for each.

tests/decl-good.at

index 5b8b9a661f9c385ee9870d2c2aec1d7606d03c1d..b0e648e1b38d89c90243712af4eae4cb460268d6 100644 (file)
 
 AT_BANNER([C declarations])
 
-m4_define([CHECK_DECL],
-[AT_DATA([expout], [[$2]m4_newline])
-AT_CHECK([cdecl99 -e 'explain $1'], [0], [expout])])
+m4_define([CHECK_DECLS],
+[AT_CHECK([cdecl99 m4_map_args_sep([-e 'explain ], ['], [ ], m4_shift($@))],
+  [0], [[$1]m4_ifval([$1], [
+])])])
 
-m4_define([SIMPLE_DECL],
-[AT_SETUP([$1])
-CHECK_DECL([$1], [$2])
+m4_define([SIMPLE_DECLS],
+[AT_SETUP([Accept m4_car($1)])
+CHECK_DECLS(m4_join([
+], $2), $1)
 AT_CLEANUP])
+m4_define([SIMPLE_DECL], [SIMPLE_DECLS([[$1]], [[$2]])])
 
+SIMPLE_DECLS([[int **], [int **x]],
+  [[type pointer to pointer to int],
+   [declare x as pointer to pointer to int]])
+SIMPLE_DECLS([[int (*x)], [int (*)]],
+  [[declare x as pointer to int],
+   [type pointer to int]])
 SIMPLE_DECL([int (x*)], [type function (pointer to x) returning int])