Author: jelmer
Date: 2007-01-05 14:25:21 +0000 (Fri, 05 Jan 2007)
New Revision: 20545

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

Log:
Fix is_constant().

Modified:
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Util.pm
   branches/SAMBA_4_0/source/pidl/tests/util.pl


Changeset:
Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Util.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Util.pm       2007-01-05 
13:13:15 UTC (rev 20544)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Util.pm       2007-01-05 
14:25:21 UTC (rev 20545)
@@ -54,9 +54,8 @@
 sub is_constant($)
 {
        my $s = shift;
-       if (defined $s && $s =~ /^\d$/) {
-               return 1;
-       }
+       return 1 if (defined $s && $s =~ /^\d+$/);
+       return 1 if (defined $s && $s =~ /^0x[0-9A-Fa-f]+$/);
        return 0;
 }
 

Modified: branches/SAMBA_4_0/source/pidl/tests/util.pl
===================================================================
--- branches/SAMBA_4_0/source/pidl/tests/util.pl        2007-01-05 13:13:15 UTC 
(rev 20544)
+++ branches/SAMBA_4_0/source/pidl/tests/util.pl        2007-01-05 14:25:21 UTC 
(rev 20545)
@@ -3,7 +3,7 @@
 # Published under the GNU General Public License
 use strict;
 
-use Test::More tests => 25;
+use Test::More tests => 29;
 use FindBin qw($RealBin);
 use lib "$RealBin/../lib";
 use Parse::Pidl::Util;
@@ -16,6 +16,10 @@
 
 # is_constant()
 ok(is_constant("2"));
+ok(is_constant("256"));
+ok(is_constant("0x400"));
+ok(is_constant("0x4BC"));
+ok(not is_constant("0x4BGC"));
 ok(not is_constant("str"));
 ok(not is_constant("2 * expr"));
 

Reply via email to