Author: jelmer
Date: 2007-01-05 14:55:26 +0000 (Fri, 05 Jan 2007)
New Revision: 20547

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20547

Log:
Add tests for expected errors/warnings.

Added:
   branches/SAMBA_4_0/source/pidl/tests/ndr_compat.pl
   branches/SAMBA_4_0/source/pidl/tests/test_util.pl
Modified:
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl.pm
   branches/SAMBA_4_0/source/pidl/tests/Util.pm


Changeset:
Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl.pm    2007-01-05 14:52:10 UTC 
(rev 20546)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl.pm    2007-01-05 14:55:26 UTC 
(rev 20547)
@@ -9,7 +9,7 @@
 
 require Exporter;
 @ISA = qw(Exporter);
[EMAIL PROTECTED] = qw(warning error fatal);
[EMAIL PROTECTED] = qw(warning error fatal);
 
 use strict;
 

Modified: branches/SAMBA_4_0/source/pidl/tests/Util.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/tests/Util.pm        2007-01-05 14:52:10 UTC 
(rev 20546)
+++ branches/SAMBA_4_0/source/pidl/tests/Util.pm        2007-01-05 14:55:26 UTC 
(rev 20547)
@@ -6,10 +6,28 @@
 
 require Exporter;
 @ISA = qw(Exporter);
[EMAIL PROTECTED] = qw(test_samba4_ndr);
[EMAIL PROTECTED] = qw(test_samba4_ndr test_warnings test_errors);
 
 use strict;
 
+use FindBin qw($RealBin);
+use lib "$RealBin/../lib";
+
+use Parse::Pidl;
+my $warnings = "";
+sub Parse::Pidl::warning($$) 
+{ 
+       my ($e, $l) = @_;
+       $warnings .= "$e->{FILE}:$e->{LINE}: $l\n";
+};
+
+my $errors = "";
+sub Parse::Pidl::error($$) 
+{ 
+       my ($e, $l) = @_;
+       $errors .= "$e->{FILE}:$e->{LINE}: $l\n";
+};
+
 use Test::More;
 use Parse::Pidl::IDL;
 use Parse::Pidl::NDR;
@@ -84,4 +102,25 @@
        }
 }
 
+sub test_warnings($$)
+{
+       my ($exp, $code) = @_;
+
+       $warnings = "";
+
+       $code->();
+
+       is($warnings, $exp);
+}
+
+
+sub test_errors($$)
+{
+       my ($exp, $code) = @_;
+       $errors = "";
+       $code->();
+
+       is($errors, $exp);
+}
+
 1;

Added: branches/SAMBA_4_0/source/pidl/tests/ndr_compat.pl
===================================================================
--- branches/SAMBA_4_0/source/pidl/tests/ndr_compat.pl  2007-01-05 14:52:10 UTC 
(rev 20546)
+++ branches/SAMBA_4_0/source/pidl/tests/ndr_compat.pl  2007-01-05 14:55:26 UTC 
(rev 20547)
@@ -0,0 +1,27 @@
+#!/usr/bin/perl
+# (C) 2007 Jelmer Vernooij <[EMAIL PROTECTED]>
+# Published under the GNU General Public License
+use strict;
+
+use Test::More tests => 3;
+use FindBin qw($RealBin);
+use lib "$RealBin";
+use Util; 
+use Parse::Pidl;
+use Parse::Pidl::IDL;
+
+sub parse_idl($) 
+{
+       my $idl = shift;
+       my $pidl = Parse::Pidl::IDL::parse_string("interface echo { $idl }; ", 
"nofile");
+       Parse::Pidl::NDR::Parse($pidl);
+}
+
+test_warnings("", sub {parse_idl("void x();"); });
+test_warnings("nofile:0: top-level [out] pointer `x' is not a [ref] 
pointer\n", sub {parse_idl("void x([out,unique] int *x);"); });
+
+test_warnings("nofile:0: pointer_default_top() is a pidl extension and should 
not be used\n", sub {
+       my $pidl = 
Parse::Pidl::IDL::parse_string("[pointer_default_top(unique)] interface echo { 
void x(); }; ", "nofile");
+       Parse::Pidl::NDR::Parse($pidl);
+});
+


Property changes on: branches/SAMBA_4_0/source/pidl/tests/ndr_compat.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: branches/SAMBA_4_0/source/pidl/tests/test_util.pl
===================================================================
--- branches/SAMBA_4_0/source/pidl/tests/test_util.pl   2007-01-05 14:52:10 UTC 
(rev 20546)
+++ branches/SAMBA_4_0/source/pidl/tests/test_util.pl   2007-01-05 14:55:26 UTC 
(rev 20547)
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+# (C) 2007 Jelmer Vernooij <[EMAIL PROTECTED]>
+# Published under the GNU General Public License
+use strict;
+
+use Test::More tests => 6;
+use FindBin qw($RealBin);
+use lib "$RealBin/../lib";
+use lib "$RealBin";
+use Util qw(test_warnings test_errors);
+use Parse::Pidl qw(warning error);
+
+test_warnings("", sub {});
+
+test_warnings("x:1: msg\n", sub { warning({FILE => "x", LINE => 1}, "msg"); });
+test_warnings("", sub {});
+
+test_errors("", sub {});
+
+test_errors("x:1: msg\n", sub { error({FILE => "x", LINE => 1}, "msg"); });
+test_errors("", sub {});
+


Property changes on: branches/SAMBA_4_0/source/pidl/tests/test_util.pl
___________________________________________________________________
Name: svn:executable
   + *

Reply via email to