From 035adfb94399a2e2d5d4ca26aaa214576f5c0b64 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 4 Mar 2007 14:16:52 +0000 Subject: r21681: Fix bug in the parsing code that parsed "struct foo;" the same as "struct foo {};". Reported by one of the OpenChange folks, thanks! (This used to be commit d65b520f08ea4ee82c35ff334a58aa6ffc403d67) --- source4/pidl/tests/header.pl | 8 +++++++- source4/pidl/tests/parse_idl.pl | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'source4/pidl/tests') diff --git a/source4/pidl/tests/header.pl b/source4/pidl/tests/header.pl index 7092eb0d14..bb09969d0f 100755 --- a/source4/pidl/tests/header.pl +++ b/source4/pidl/tests/header.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 12; +use Test::More tests => 14; use FindBin qw($RealBin); use lib "$RealBin"; use Util; @@ -42,3 +42,9 @@ like(parse_idl("interface p { struct x { struct y z; }; };"), like(parse_idl("interface p { struct x { union y z; }; };"), qr/struct x.*{.*union y z;.*}.*;/sm, "tagged type union member"); + +like(parse_idl("interface p { struct x { }; };"), + qr/struct x.*{.*char _empty_;.*}.*;/sm, "empty struct"); + +like(parse_idl("interface p { struct x; };"), + qr/struct x;/sm, "struct declaration"); diff --git a/source4/pidl/tests/parse_idl.pl b/source4/pidl/tests/parse_idl.pl index 265ac7a2bd..727f41a293 100755 --- a/source4/pidl/tests/parse_idl.pl +++ b/source4/pidl/tests/parse_idl.pl @@ -4,7 +4,7 @@ # Published under the GNU General Public License use strict; -use Test::More tests => 62 * 2; +use Test::More tests => 63 * 2 + 2; use FindBin qw($RealBin); use lib "$RealBin"; use Util qw(test_errors); @@ -107,3 +107,17 @@ testfail "import-nosemicolon", "import \"foo.idl\"", ":0: Syntax error near 'foo.idl'\n"; testok "import-multiple", "import \"foo.idl\", \"bar.idl\";"; testok "include-multiple", "include \"foo.idl\", \"bar.idl\";"; +testok "empty-struct", "interface test { struct foo { }; }"; + +my $x = Parse::Pidl::IDL::parse_string("interface foo { struct x {}; }", ""); + +is_deeply($x, + [ { 'FILE' => '', 'NAME' => 'foo', 'DATA' => [ + { 'NAME' => 'x', 'TYPE' => 'STRUCT', ELEMENTS => [] } ], + 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]); + +$x = Parse::Pidl::IDL::parse_string("interface foo { struct x; }", ""); +is_deeply($x, + [ { 'FILE' => '', 'NAME' => 'foo', 'DATA' => [ + { 'NAME' => 'x', 'TYPE' => 'STRUCT' } ], + 'TYPE' => 'INTERFACE', 'LINE' => 0 } ]); -- cgit